Soham Banerjee
Soham Banerjee

Reputation: 117

IllegalStateException: Could not load jdbc driver

I am getting the same error as in exception is java.lang.IllegalStateException: Could not load JDBC driver class. I have added ojdbc14.jar inside src/main/resources/lib. Still getting:-

    PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ds' defined in class path resource [dbOperations.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]

I am loading the jdbc driver :-

    context = new ClassPathXmlApplicationContext("dbOperations.xml");

Upvotes: 0

Views: 862

Answers (1)

Chris S.
Chris S.

Reputation: 192

Placing the jar into the src/resources/lib isn't going to put the class files on your classpath.

Depending on if you're using something like Maven or Gradle, you'll need to add the ojdbc jar as a dependency in your pom or gradle file.

If you're not using this, you'll have to make sure the ojdbc jar file is listed in your -classpath arguments when you start up the JVM.

Upvotes: 4

Related Questions