File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Connecting Java with Oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connecting Java with Oracle" Watch "Connecting Java with Oracle" New topic
Author

Connecting Java with Oracle

besian hoxha
Greenhorn

Joined: May 21, 2012
Posts: 3
Hi,

I'm trying to connect with Oracle but there are some problem..
Can anyone help me please?

There is the code:





PROBLEM:



ConnectOracle@130c19b databaseoracle
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at ConnectOracle.getOracleConnection(ConnectOracle.java:83)
at ConnectOracle.getConnection(ConnectOracle.java:46)
at ConnectOracle.getModeli(ConnectOracle.java:125)
at ConnectOracle.main(ConnectOracle.java:205)
java.lang.NullPointerException
at ConnectOracle.getModeli(ConnectOracle.java:126)
at ConnectOracle.main(ConnectOracle.java:205)


[Added code tags - see UseCodeTags for details]
Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
Did you get the jar file containing the oracle connection driver and put it in your classpath?
It seems you didn't.

Bye,
Nicola
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40059
    
  28
I think this thread would sit better in the databases forum (connections probably fit better there than in the Oracle forum). Moving discussion.
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

Nicola is correct.

Class.forName() will look in the $CLASSPATH/%CLASSPATH% of the application server at run-time.

Either include the oracle supplied jar in your web-inf/lib or install in the appservers shared lib folders.

WP
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3611
    
  60

If needed, you can find links to Oracle JDBC drivers, as well as other useful Oracle related advice, in our Oracle FAQ page.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Connecting Java with Oracle