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

Scenario : Your Java program, either standalone or Java spider web application is trying to connect to Oracle database using type four JDBC sparse driver "oracle.jdbc.driver.oracledriver", JVM is non able to uncovering this shape at runtime. This JAR comes inwards ojdbc6.jar or ojdbc6_g.jar which is most in all likelihood non available inwards classpath.

Cause : When y'all connect to Oracle database from Java program, your plan loads the implementation of Driver interface provided past times the database vendor using class.forName() method, which throws ClassNotFoundException when driver shape is non constitute inwards classpath. In instance of Oracle the driver implementation is oracle.jdbc.driver.oracledriver and "java.lang.classnotfoundexception oracle.jdbc.driver.oracledriver" error betoken that this shape is  not available inwards classpath. Since this shape is bundled into ojdbc6.jar, its commonly the instance of this JAR non introduce inwards Classpath


As I said this fault may come upwards fifty-fifty if y'all are connecting to Oracle database from spider web server similar Tomcat. This is the stack-trace from Tomcat, when my Java app was failed to charge this shape :

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

You tin run into that due to a telephone telephone to Class.forName(), WebappClassLoader tries to charge this shape file, it only looks at WEB-INF/lib directory, hence if this shape is non introduce inwards whatever JAR file at that place hence it volition throw java.lang.classnotfoundexception oracle.jdbc.driver.oracledriver



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

Solution : If y'all already accept this JAR hence include this inwards your classpath, for illustration if y'all are running nub Java application using main() method hence merely brand certain that y'all purpose a custom classpath specified past times -cp or -classpath parameter to coffee ascendence too place of this JAR there.

If y'all are connecting to oracle database using Java spider web application (Servlet, JSP) hence brand certain that this JAR is introduce inwards WEB-INF/lib folder. If y'all are using tomcat to deploy your Java spider web application, You tin every bit good pose this ojdbc.jar inwards apache-tomcat/lib directory, but recollect that hence it volition non endure loaded past times WebAppClassLoader but its parent, which way it volition endure available to all spider web application too volition non endure unloaded when y'all withdraw your spider web application.

If y'all don't accept ojdbc6.jar or ojdbc_g.jar hence download them from " target="_blank"> java.lang.classnotfoundexception oracle.jdbc.driver.oracledriver fault inwards Java

 either standalone or Java spider web application is trying to connect to Oracle database using  How to Fix java.lang.classnotfoundexception oracle.jdbc.driver.oracledriver [Solved]


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

Oracle driver, oracle.jdbc.driver.oracledriver is available inwards ojdbc6.jar too ojdbc_g.jar for Oracle 11g, but if y'all are connecting to Oracle 10g database too running on Java 1.4 or Java 1.5 hence y'all should either purpose ojdbc14.jar, or purpose classes12.jar if your Java application is running on JDK 1.2 too JDK 1.3. Though I advise to purpose debug JAR files e.g. ojdbc14_g.jar or classes12_g.jar because they are compiled using javac -g selection too incorporate useful tracing information.

You tin download Oracle JDBC driver Jar files from http://www.oracle.com/technetwork/apps-tech/jdbc-10201-088211.html. ojdbc6.jar incorporate classes for purpose amongst Java 1.6 version, hence if your application is running on Java vi too connecting to Oracle 11g database hence purpose ojdbc6 too ojdbc6_g.jar. If your plan is running on Java five too connecting ot Oracle 11g hence purpose ojdbc5.jar or ojdbc5_g.jar. You tin download Oracle 11g JDBC drive JAR files from http://www.oracle.com/technetwork/apps-tech/jdbc-112010-090769.html.


Summary

  • If y'all are connecting to Oracle 11g from Java too running on version Java vi hence include ojdbc6.jar or ojdbc6_g.jar inwards your application's classpath.
  • If y'all are connecting to Oracle 11g from Java five hence include ojdbc5.jar or ojdbc5_g.jar in your application's classpath.
  • Difference betwixt ojdbc6.jar too ojdbc6_g.jar is that subsequently is debug version, created past times compiling root file using javac -g command. They include to a greater extent than debugging information, useful spell troubleshooting.
  • If y'all are connecting to Oracle 10g database from Java 1.4 or Java five hence purpose ojdbc14.jar or ojdbc14_g.jar files.
  • If your Java plan is connecting to Oracle 10g database too running on Java 1.2 or Java 1.3 hence delight use classes12.jar and classes12_g.jar. Again deviation betwixt hence is merely additional debug information.

That's all almost how to solve java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver fault inwards Java. In 99% cases this fault is solved past times putting correct Oracle driver JAR into classpath, but if y'all notwithstanding non able to solve this problem, hence I advise to depository fiscal establishment jibe for whatever classpath effect e.g. sometime y'all are putting it into a directory which is non included inwards CLASSPATH or another setting is overriding your expected classpath. If y'all are unsure almost how to bargain amongst that error, I advise reading my tutorial How Java CLASSPATH Works? That volition plough over y'all proficient sentiment almost where to facial expression for when classpath issues surfaces.

You tin every bit good depository fiscal establishment jibe next articles if y'all are facing whatever effect spell connecting to other pop database e.g. Oracle, SQL Server too MySQL from Java programs :
  • General Guide to solve java.lang.ClassNotFoundException inwards Java [guide]
  • How to solve java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver inwards Java? [solution]
  • How to fix java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver inwards Java? [solution]
  • How to cook java.lang.ClassNotFoundException: org.postgresql.Driver fault inwards Java? [solution]
  • How to solve java.lang.ClassNotFoundException:org.Springframework.Web.Context.ContextLoaderListener [solution]
  • How to solve java.lang.ClassNotFoundException: com.mysql.jdbc.Driver inwards Java MySQL? [solution]
  • java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory? [solution]
  • How to connect to MySQL database from Java Program [steps]

Subscribe to receive free email updates:

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

Posting Komentar