Ryainad
Ryainad

Reputation: 219

Connect To Oracle DB Via JDBC Driver

I'm trying to connect Oracle database using this tutorial. It is working when I use command line: java -cp c:\jdbc-test\ojdbc6.jar;c:\jdbc-test OracleJDBC I have put ojdbc6.jar in the same folder with OracleJDBC.java. Now I need to run it on Eclipse, but it gives me an error:

Output: *Where is your Oracle JDBC Driver?

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:190) at OracleJDBC.main(OracleJDBC.java:32)*

Is it because of ojdbc6.jar location?

Upvotes: 0

Views: 1595

Answers (3)

SpringLearner
SpringLearner

Reputation: 13844

you need to keep the jar file in external library follow this way

  1. right click on your project
  2. click "build path"
  3. click "configure build path"
  4. click "library " tab
  5. click "add external jars"
  6. give the path of the jar file

Then run it Please see the screenshots enter image description here enter image description here

Upvotes: 0

Narendra Pathai
Narendra Pathai

Reputation: 41935

Add the library in the project build path.

  • Right click on project
  • Build Path
  • Go to Libraries Tab
  • Add external jar (ODBC jar) there

Right Click on project for Build Path option

Java Build Path libraries configuration

Upvotes: 1

Viktor Ozerov
Viktor Ozerov

Reputation: 326

You just need to add ojdbc6.jar into classpath of your application.

Upvotes: 0

Related Questions