Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC Oracle

 
kalyani Sharma
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic