0

But how come it did not get the ojdbc7.jar from lib folder that i had created in the Project root ????

I added the following

  Class.forName("oracle.jdbc.driver.OracleDriver"); 

code in the Constructor of my Controller and it threw an Exception.So i followed this link, oracle.jdbc.driver.OracleDriver ClassNotFoundException in that link i did the following,

In Eclipse,right click on your application

Run As -> Run configurations -> select your server from type filter text box

Then in Classpath under Bootstrap Entries add your classes12.jar File and Click on Apply Now, run the file.This worked for me !!....

This did work. But how come it did not get the ojdbc7.jar from lib folder ??

I have created a lib folder in my project root and kept the ojdbc7.jar in it.

But still i am getting the below error,

Property 'driverClassName' threw exception; nested exception is 
java.lang.IllegalStateException: Could not load JDBC driver class 
[oracle.jdbc.driver.OracleDriver]    

I searched the net for the same error and all say that keep the jar in the classpath. I think i have it in the classpath. But still the error persists.

I have the ojdbc7.jar. im using Oracle 12c.

Can anybody help me with it please.

In employeeServlet-servlet.xml, i have defined Datasource as,

<!-- DataSource -->
    <bean id="dataSource" 
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${database.driver}"> 
 </property>
        <property name="url" value="${database.url}"></property>
        <property name="username" value="${database.user}"></property>
        <property name="password" value="${database.password}"></property>
    </bean>   

In application.properties i have,

#Database related properties
database.driver=oracle.jdbc.driver.OracleDriver
database.url=jdbc:oracle:thin:@localhost:1521:orcl
database.user=system
database.password=oracle

In pom.xml, i have

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc7</artifactId>
    <version>${oracle.version}</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/lib/ojdbc7.jar</systemPath> <!-- must match file name -->
</dependency>  
1
  • I added the Class.forName code in the Constructor of my Controller and it threw an Exception.So i followed this link, stackoverflow.com/questions/15598757/… in that link i did the following ..In Eclipse,right click on your application Run As -> Run configurations -> select your server from type filter text box Then in Classpath under Bootstrap Entries add your classes12.jar File and Click on Apply Now, run the file.This worked for me !!....This did work. But how come it did not get the ojdbc7.jar from lib folder ?? Commented Aug 9, 2018 at 6:41

1 Answer 1

0

You got this error popping up:

Property 'driverClassName' threw exception; nested exception is 

java.lang.IllegalStateException: Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]

Test if "oracle.jdbc.driver.OracleDriver" is on your classpath like so:

try {
  Class.forName("oracle.jdbc.driver.OracleDriver");
  //on classpath
} catch(ClassNotFoundException e) {
  //not on classpath
}

If an exception occurs in Class.forName("oracle.jdbc.driver.OracleDriver");

this line causes ClassNotFoundException, because you haven't placed ojdbc14.jar file in your lib folder of the project. or You haven't set the classpath of the required jar

You might wanna read these question: Property 'driverClassName' threw exception; Could not load JDBC driver class [org.postgresql.Driver]

oracle.jdbc.driver.OracleDriver ClassNotFoundException

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the reply @Alien. My problem is not solved and its been more than 2 days that i'm working on it. Please help me....I wrote a class to test the Driver as mentioned by you, but it did not throw any exception. I have followed the following link to create the project...javawebtutor.com/articles/spring/…... The link used MySQL db and I use Oracle DB. As mentioned in the question, i downloaded the ojdbc7.jar and placed it in the lib folder in the project root and mentioned it in the pom.xml.
please refer this to configure oracle for your project mkyong.com/hibernate/…
I added the code that you mentioned in the Constructor of my Controller and it threw an Exception.So i followed this link, stackoverflow.com/questions/15598757/… in that link i did the following ..In Eclipse,right click on your application Run As -> Run configurations -> select your server from type filter text box Then in Classpath under Bootstrap Entries add your classes12.jar File and Click on Apply Now, run the file.This worked for me !!....This did work. But how come it did not get the ojdbc7.jar from lib folder ??
sometimes eclipse sucks bro..and may be that is the reason here also.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.