简体   繁体   中英

ClassNotFoundException: oracle.jdbc.driver.OracleDriver

I wrote a java servlet program but when i run it, It was showing the Exception java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

My code

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection(url, "username", "pass");

I am using Oracle 10.2.0. I added also ojdbc14.jar and ojdbc14_g.jar.

When I give the below command to command line. I get Error: Main method not found in class oracle.jdbc.driver.OracleDriver

I added also ojdbc14.jar and ojdbc14_g.jar

When adding third party libraries to your application, you must be sure they are in the Build Path of your application. In case of web applications, every third party library must be inside the WEB-INF/lib of the application so when deployed to the server (Tomcat, JBoss, etc.) they can be recognized and loaded when running your application.

Steps to rectify (if running from command prompt) Step 1- Copy the ojdbc6 jar file from C:\\oraclexe\\app\\oracle\\product\\11.2.0\\server\\jdbc\\lib (Note- this path may differ as per the installation).

Step 2- Paste the ojdbc6 jar file in the Location C:\\Program Files\\Java\\jre1.8.0_45\\lib\\ext (Note- this path may differ as per the installation).

Step 3- Now run the programme java -cp . . It should successfully run without any error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM