This is my code for which I am getting error. My classes12.jar
has been imported as an external jar.
import java.io.IOException;
import java.io.
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
1.Right click on your java project.
2.Select "RUN AS".
3.Select "RUN CONFIGURATIOS...".
4.Here select your server at left side of the page and then u would see "CLASS PATH" tab at riht side,just click on it.
5.Here clilck on "USER ENTRIES" and select "ADD EXTERNAL JARS".
6.Select "ojdbc14.jar" file.
7.Click on Apply.
8.Click on Run.
9.Finally Restart your server then it would be execute.
Method 1: Download ojdbc.jar
add ojdbc6.jar to deployment assembly. Right click on project->properties->select deployment assembly->click on 'Add' ->select 'Archives from File System'->browse to the folder where ojdbc6.jar is saved.->add the jar->click finish->Apply/OK.
Method 2:
if you want to add ojdbc.jar to your maven dependencies you follow this link: http://www.mkyong.com/maven/how-to-add-oracle-jdbc-driver-in-your-maven-local-repository/ . . Even if you're using a maven project it is not necessary to add ojdbc to maven dependencies(method 2), method 1 (adding directly to deployment assembly) works just fine.
try to add ojdbc6.jar or other version through the server lib "C:\apache-tomcat-7.0.47\lib",
Then restart the server in eclipse.
In Eclipse , rightclick 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 !!
In Eclipse,
When you use JDBC in your servlet, the driver jar must be placed in the WEB-INF/lib directory of your project.