File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes HibernateException: JDBC Driver class not found: oracle.jdbc.driver.OracleDriver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "HibernateException: JDBC Driver class not found: oracle.jdbc.driver.OracleDriver" Watch "HibernateException: JDBC Driver class not found: oracle.jdbc.driver.OracleDriver" New topic
Author

HibernateException: JDBC Driver class not found: oracle.jdbc.driver.OracleDriver

Deepak Kumar Jena
Ranch Hand

Joined: Sep 08, 2010
Posts: 68

Trying to create a standalone application using Hibernate 3.0 and Oracle 10g. The Client Application, POJO class, Mapping File and Configuration File are placed in the same folder, and all the required jar files including ojdbc14.jar are included in the classpath. Compilation is Fine, but during execution throwing HibernateException: JDBC Driver class not found: oracle.jdbc.driver.OracleDriver.

The driver_class, url, username, password are mapped in configuration file and using the same in normal jdbc application able to insert data in the table. But in this case it is throwing exception.

Please suggest.


dkj4jdk
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Verify your classpath settings for the location of that driver. That driver cannot be resolved, which points to a classpath issue.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
Your missing the oracle jdbc jar.

http://findjar.com is a handy resource.
Deepak Kumar Jena
Ranch Hand

Joined: Sep 08, 2010
Posts: 68

The ojdbc14.jar has been copied from the Oracle installation folder and placed in a folder named Libraries. The jar has been added to the classpath. I am able to write/run normal jdbc applications and even the same in Struts application. But in case of Hibernate it is generating exception.
Waswani Naresh
Ranch Hand

Joined: May 01, 2008
Posts: 66
Please provide your DB configuration file.

Regards,
Naresh


Naresh Waswani
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
How are you compiling and executing? Ant?

Your hibernate jar's are in the same directory as the oracle jdbc jar correct?

Deepak Kumar Jena
Ranch Hand

Joined: Sep 08, 2010
Posts: 68

I am compiling the files using javac in command prompt. The hibernate.jar and ojdbc14.jar are placed under the same folder i.e. C:\Libraries and both has been added to the classpath.
Deepak Kumar Jena
Ranch Hand

Joined: Sep 08, 2010
Posts: 68

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Deepak Kumar Jena wrote:I am compiling the files using javac in command prompt. The hibernate.jar and ojdbc14.jar are placed under the same folder i.e. C:\Libraries and both has been added to the classpath.


That has nothing at all to do with errors which happen at run time.
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
Are you compiling a executable jar file?

If so, have you included the oracle jar path in the executable jar's Manifest?


Ant usually eliminates (or minimizes) these types of issues.


Deepak Kumar Jena
Ranch Hand

Joined: Sep 08, 2010
Posts: 68

Deepak Kumar Jena
Ranch Hand

Joined: Sep 08, 2010
Posts: 68

Deepak Kumar Jena
Ranch Hand

Joined: Sep 08, 2010
Posts: 68

Deepak Kumar Jena
Ranch Hand

Joined: Sep 08, 2010
Posts: 68

I am getting error during compilation (Not using Ant). The jar files are placed in the classpath and they are visible in command prompt (using classpath). Database is also up. I have doubts about the version of the JARS. Suggest about all the required JARS with version detail.
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
Sounds like to are compiling EmployeeBean with the c:\libraries classpath set in javac,
then run the EmployeeBean class directly with the java command right?


Here's what I would do if I had this problem:

I would change the directory structure:

myproject\
myproject\lib <-- put all jars in this directory.
myproject\src <-- your EmployeeBean and other java files here.
myproject\build
myproject\build.xml

Then using ant, I would compile the code in src to create a jar file that has a class-path specified relative to the current location..


Here's a sample:



Then from your command line...run the ant tasks defined for compiling and building..

afterwords..once you compile your runnable jar...you can simply run it by...

#>java -jar myRunnableJar.jar

Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
What is your command syntax for compiling and executing?

Deepak Kumar Jena
Ranch Hand

Joined: Sep 08, 2010
Posts: 68

I am using javac *.java at the command prompt. The POJO class (EmployeeBean.java) is getting compiled into .class file while the Hibernate Client Application (EmployeeClient.java) is throwing Exception during compile-time.

Actually, I am interested in compiling the files manually through Command prompt, but not interested in using tools like Ant for this purpose.
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
You will consistently run into these types of issues with your build process.

Deepak Kumar Jena
Ranch Hand

Joined: Sep 08, 2010
Posts: 68

I am looking forward to debug the issue to find out the root cause. Using tools to avoid the errors is not a good move. As per my knowledge the issues are related to the dtd schema (XML) and may be specific to the environment (jar versions, classpath settings,etc). Even the same Exception is getting generated in MyEclipse.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HibernateException: JDBC Driver class not found: oracle.jdbc.driver.OracleDriver
 
Similar Threads
Web application
JDBC help required.
Doubt on Hibernate application
driver class problem
driver class problem