Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting Java with Oracle

 
besian hoxha
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you get the jar file containing the oracle connection driver and put it in your classpath?
It seems you didn't.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49776
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If needed, you can find links to Oracle JDBC drivers, as well as other useful Oracle related advice, in our Oracle FAQ page.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic