This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes JDBC Oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JDBC Oracle" Watch "JDBC Oracle" New topic

JDBC Oracle

kalyani Sharma

Joined: Nov 29, 2004
Posts: 3

I am having problem during driver loading using

I have tnsnames.ora set, classes12.jar in classpath.
Please help me.


[Bear edit: not so URGENT]
[ November 29, 2004: Message edited by: Bear Bibeault ]
Raj Chila
Ranch Hand

Joined: Mar 18, 2004
Posts: 128

if you could paste the actual VM error / exception then it could give us some lead to suggest you some thing.

Right now I feel that you are having some classpath resolution problem...(if you are using some IDE to both develop and test then may be its some other kind of a problem).You dont need the tnsnames.ora file for JDBC based applications.
kalyani Sharma

Joined: Nov 29, 2004
Posts: 3
This is my code

I am getting the error statement Failed to load driver

I am not using an IDE .. I am getting null pointer exception.

[edited to add code tags]
[ November 29, 2004: Message edited by: Jeanne Boyarsky ]
Raj Chila
Ranch Hand

Joined: Mar 18, 2004
Posts: 128


the "failed to load driver" statement is evident that your classpath is not set properly...and hence the nullpointer exceptions becuase you do not throw the exception after catching it.

because the driver is loaded at runtime...the programming will compile making you think every thing went simple trick is, run a javap command and see if you can actually print the class on your console or not. or load the driver by creating an instance of it like OracleDriver myDriver = new OracleDriver();

I think this should help.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32507

If you are setting the classpath in the command line, make sure it is there for the "java" command, not just the "javac" command.

And welcome to JavaRanch!

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

I am getting the error statement Failed to load driver

Check that the driver class name is not oracle.jdbc.OracleDriver (instead of oracle.jdbc.driver.OracleDriver!)

Also, it is a very bad idea to consume an exception like this -

At the very least, print the stack trace, or log the exception keeping all the information provided with it. In many cases, it would be better to let the exception propagate to the calling code, and let the calling code handle it in any way it sees fit.

[ November 29, 2004: Message edited by: Sonny Gill ]

The future is here. It's just not evenly distributed yet. - William Gibson
Sonny Gill LinkedIn
I agree. Here's the link:
subject: JDBC Oracle
It's not a secret anymore!