my dog learned polymorphism
The moose likes JDBC and Relational Databases and the fly likes Classpath in JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Classpath in JDBC" Watch "Classpath in JDBC" New topic

Classpath in JDBC

Asad Salim

Joined: May 31, 2011
Posts: 13
Hey guys,

I m confused where actually I m going wrong with the classpath settings in order to user JDBC-OracleDriver Connection

Below is my JAVA Code

CLASSPATH setting is :

Path Setting is
C:\oraclexe\app\oracle\product\10.2.0\server\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\Program Files\Java\jdk1.6.0\bin;

JDK version is 1.6
Oracle version is Oracle 10g

My Code works perfect when i try to on command prompt using -cp , but it doesn't work on Eclipse , it cannot detect the classpath file (i guess so, although being specified)

It throws the below exception
Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at SampleDatabaseConn.main(

Could you guys provide some inputs.

joy b chakravarty
Ranch Hand

Joined: May 16, 2011
Posts: 62

In eclipse add these jars in your build path.
Right click on your project > Build Path > Configure Build Path > Add the external jars

Or you might restart eclipse for it to pick up system env variables.

Cheers, Joy [SCJP 1.4, SCBCD 5.0]
get high on alcohol, algorithm or both
Asad Salim

Joined: May 31, 2011
Posts: 13
Thanks Joy , that did solve my problem
I agree. Here's the link:
subject: Classpath in JDBC
It's not a secret anymore!