Preparing for Java and Spring Boot Interview?

Join my Newsletter, its FREE

How to Fix java.lang.classnotfoundexception oracle.jdbc.driver.oracledriver [Solved]

Scenario : Your Java program, either standalone or Java web application is trying to connect to Oracle database using type 4 JDBC thin driver "oracle.jdbc.driver.oracledriver", JVM is not able to find this class at runtime. This JAR comes in ojdbc6.jar or ojdbc6_g.jar which is most probably not available in classpath.

Cause : When you connect to Oracle database from Java program, your program loads the implementation of Driver interface provided by the database vendor using class.forName() method, which throws ClassNotFoundException when driver class is not found in classpath. In case of Oracle the driver implementation is oracle.jdbc.driver.oracledriver and "java.lang.classnotfoundexception oracle.jdbc.driver.oracledriver" error indicate that this class is  not available in classpath. Since this class is bundled into ojdbc6.jar, its usually the case of this JAR not present in Classpath

As I said this error may come even if you are connecting to Oracle database from web server like Tomcat. This is the stack-trace from Tomcat, when my Java app was failed to load this class :

java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
at org.apache.catalina.loader.WebappClassLoader
at org.apache.catalina.loader.WebappClassLoader
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)

You can see that due to a call to Class.forName(), WebappClassLoader tries to load this class file, it only looks at WEB-INF/lib directory, so if this class is not present in any JAR file at that location then it will throw java.lang.classnotfoundexception oracle.jdbc.driver.oracledriver

How to solve  java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver

Solution : If you already have this JAR then include this in your classpath, for example if you are running core Java application using main() method then just make sure that you use a custom classpath specified by -cp or -classpath parameter to java command and location of this JAR there.

If you are connecting to oracle database using Java web application (Servlet, JSP) then make sure that this JAR is present in WEB-INF/lib folder. If you are using tomcat to deploy your Java web application, You can also put this ojdbc.jar in apache-tomcat/lib directory, but remember that then it will not be loaded by WebAppClassLoader but its parent, which means it will be available to all web application and will not be unloaded when you remove your web application.

If you don't have ojdbc6.jar or ojdbc_g.jar then download them from, both contains oracle.jdbc.driver.oracledriver, only difference is that ojdbc_g.jar has been compiled using Javac -g parameter to include more debug information, useful while debugging and printing stacktrace. Once you add this JAR file in your application's classpath there will be no more  java.lang.classnotfoundexception oracle.jdbc.driver.oracledriver error in Java

java.lang.classnotfoundexception oracle.jdbc.driver.oracledriver Solution

Where to download Oracle 11g and 10g JDBC driver JARs

Oracle driver, oracle.jdbc.driver.oracledriver is available in ojdbc6.jar and ojdbc_g.jar for Oracle 11g, but if you are connecting to Oracle 10g database and running on Java 1.4 or Java 1.5 then you should either use ojdbc14.jar, or use classes12.jar if your Java application is running on JDK 1.2 and JDK 1.3. Though I suggest to use debug JAR files e.g. ojdbc14_g.jar or classes12_g.jar because they are compiled using javac -g option and contain useful tracing information.

You can download Oracle JDBC driver Jar files from ojdbc6.jar contain classes for use with Java 1.6 version, so if your application is running on Java 6 and connecting to Oracle 11g database then use ojdbc6 and ojdbc6_g.jar. If your program is running on Java 5 and connecting ot Oracle 11g then use ojdbc5.jar or ojdbc5_g.jar. You can download Oracle 11g JDBC drive JAR files from


  • If you are connecting to Oracle 11g from Java and running on version Java 6 then include ojdbc6.jar or ojdbc6_g.jar in your application's classpath.
  • If you are connecting to Oracle 11g from Java 5 then include ojdbc5.jar or ojdbc5_g.jar in your application's classpath.
  • Difference between ojdbc6.jar and ojdbc6_g.jar is that later is debug version, created by compiling source file using javac -g command. They include more debugging information, useful while troubleshooting.
  • If you are connecting to Oracle 10g database from Java 1.4 or Java 5 then use ojdbc14.jar or ojdbc14_g.jar files.
  • If your Java program is connecting to Oracle 10g database and running on Java 1.2 or Java 1.3 then please use classes12.jar and classes12_g.jar. Again difference between then is just additional debug information.

That's all about how to solve java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver error in Java. In 99% cases this error is solved by putting right Oracle driver JAR into classpath, but if you still not able to solve this problem, then I suggest to check for any classpath issue e.g. sometime you are putting it into a directory which is not included in CLASSPATH or some other setting is overriding your expected classpath. If you are unsure about how to deal with that error, I suggest reading my tutorial How Java CLASSPATH Works? That will give you good idea about where to look for when classpath issues surfaces.

You can also check following articles if you are facing any issue while connecting to other popular database e.g. Oracle, SQL Server and MySQL from Java programs :
  • General Guide to solve java.lang.ClassNotFoundException in Java [guide]
  • How to solve java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver in Java? [solution]
  • How to fix java.lang.ClassNotFoundException: in Java? [solution]
  • How to fix java.lang.ClassNotFoundException: org.postgresql.Driver error in Java? [solution]
  • How to solve java.lang.ClassNotFoundException:org.Springframework.Web.Context.ContextLoaderListener [solution]
  • How to solve java.lang.ClassNotFoundException: com.mysql.jdbc.Driver in Java MySQL? [solution]
  • java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory? [solution]
  • How to connect to MySQL database from Java Program [steps]


  1. I am getting java.lang.classnotfoundexception oracle.jdbc.driver.oracledriver in Spring. I am using JdbcTemplate class and I believe I have ojdbc6.jar in my classpath, basically on Eclipse's build path, but I am still getting this error. Can you please suggest if anything special required when you connect to Oracle DB from Spring? I am using DataSource and no connection pool so far. Thanks

  2. Thaks for this step by step solution. I was stuck with java.lang.classnotfoundexception oracle.jdbc.driver.oracledriver error from last two hours, thanks for helping us out.

  3. I'm trying to move to Java 8 and I'm getting the same error. Any suggestions for that?

    1. Java 8 shoudn't be the reason of this error, must be something else. check if you have Oracle's JDBC driver in your classpath or not.

  4. Is it applicable on Android Development too?
    Cause i am getting this error , although, ojdbc6.jar is added as library in my android project.

    1. Yes Duke, it does apply to Android development, provided you are using Java JDBC to connect to Oracle database.

  5. As a new comer for Java (switched from .Net) I was also trying to connect MSAccess 2007 under Java-8 using Class.forName syntax but getting classnotfound exception.
    Sie, Still wrestling, I will certainly appreciate if connection code is emailed at Thanks in anticipation

  6. It was a right on time solution for me. Thank you.

  7. I think adding ojdbc6.jar and ojdbc6_g.jar is enough at the class path...

  8. Thank you so much son you have saved my sleep today,

    adding the jar to web-inf/lib solved my issue

  9. Exception in thread "main" java.lang.findClassnotFoundException: Oracle.jdbc.OracleDriver how to solve it. plz help me.

  10. Thank you. Adding jar file to tomcat/lib actually solved my issue for ClassNotFoundException

  11. Hi I Have an errorin my java code oracle.jdbc.driver.OracleDriverjava.lang.ClassNotFoundException
    but i already configured OJDBC14

  12. Exception class Not found PLZ help Me

    package myPackage;
    import java.sql.*;

    public class dbConnection {
    public boolean validate(LoginBean loginBean) throws ClassNotFoundException
    boolean status=false;

    try {

    Connection connection=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","admin");

    // Step 2:Create a statement using connection object
    PreparedStatement ps = connection.prepareStatement("select * from adminlog where username=? and password=?");


    ResultSet rs = ps.executeQuery();
    status =;

    catch (Exception e) {
    return status;


  13. main 07/13/2020 02:04:05.0683 INFO : Successfully created db connection pool to CC database:
    main 07/13/2020 02:04:05.0684 DEBUG: Setup XML bypass for CC
    main 07/13/2020 02:04:05.0762 DEBUG: Oracle cache manager - DB connections in pool: 0 available; 1 active
    main 07/13/2020 02:04:07.0134 DEBUG: Connected to db:
    main 07/13/2020 02:04:07.0135 DEBUG: Using the RTARM Mobile Oracle connection:
    main 07/13/2020 02:04:07.0137 ERROR: Database driver not found.
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(
    at com.logica.fieldit.refdata.RefDataBaselineHelper.getConnection(
    at com.logica.fieldit.refdata.RefDataBaselineHelper.getSAConnection(
    at com.logica.fieldit.refdata.RefDataBaselineServiceUtility.setupMobileProcessorsAPI(
    at com.logica.fieldit.refdata.RefDataBaselineServiceUtility.(
    at com.logica.fieldit.refdata.RefDataBaselineServiceUtility.main(

    Iam using Oracle 19 and getting this error(ERROR: Database driver not found.). Can anyone please help me.

    1. do you have Oracle JDBC Driver JAR in your classpath?

  14. am still getting same thing "ava.lang.classnotfoundexception oracle.jdbc.driver.oracledriver"
    and am using Java 14.0.1 and Oracle 11g XE.

  15. am still getting same thing "ava.lang.classnotfoundexception oracle.jdbc.driver.oracledriver"
    and am using Java 14.0.1 and Oracle 11g XE.

    1. bro try pasting ojdbc6.jar in tomcat/lib folder

  16. Is 11g and 19c of Oracle Database is same? can any one clarifies?

  17. i am getting this error while using 18c | though classpath have required jar files

  18. I was in trouble for about a week. Even stack Over Flow didn't work for me. I am damn thankful to you Sir.

  19. I am using old application with hibernate 3 configuration which works fine with oracle 11g but not with oracle 18c. Can anybody help me on this?

  20. I am able to compile however getting this error at run time. pfb error :

    javac -cp ojdbc6.jar

    java -cp ojdbc6.jar Main

    Error: Could not find or load main class Main
    Caused by: java.lang.ClassNotFoundException: Main


Feel free to comment, ask questions if you have any doubt.