• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC Oracle

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Or we might never have existed at all. Freaky. So we should cherish everything. Even this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic