aspose file tools*
The moose likes JDBC and the fly likes JDBC Oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC Oracle" Watch "JDBC Oracle" New topic
Author

JDBC Oracle

kalyani Sharma
Greenhorn

Joined: Nov 29, 2004
Posts: 3
Hi,

I am having problem during driver loading using
Class.forName("oracle.jdbc.driver.OracleDriver");

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

Thanks
Kalyani

[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
Greenhorn

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

hi,

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 fine....one 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
Marshal

Joined: May 26, 2003
Posts: 30929
    
158

Kalyani,
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!


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, 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.

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

The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny Gill Tweets
 
 
subject: JDBC Oracle