Mike Fontaine
Mike Fontaine

Reputation: 11

Oracle JDBC driver not found

I created a simple java program to connect to Oracle that uses the OracleDriver class. The CLASSPATH variable is set but I still get CLassNotFoundException.

Any help figuring this out would be appreciated.

Specifics:

$echo $CLASSPATH
/usr/lib/oracle/11.2/client64/lib:.


$jar tf /usr/lib/oracle/11.2/client64/lib/ojdbc6.jar | grep OracleDriver
oracle/jdbc/OracleDriver.class
oracle/jdbc/driver/OracleDriver$1.class
oracle/jdbc/driver/OracleDriver.class
oracle/jdbc/driver/OracleDriverExtension.class

$java OracleCon
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

Upvotes: 1

Views: 2025

Answers (1)

Nicolas Filotto
Nicolas Filotto

Reputation: 44965

When you specify a folder to your CLASSPATH, only folder of classes or resources are expected. In your case, it is a jar file so you have to provide the name of the jar too which means that your CLASSPATH variable should rather be set to /usr/lib/oracle/11.2/client64/lib/ojdbc6.jar:..

Starting from Java 6, you can also use the wildcard notation to refer to all jar files directly located in a given folder, in your case, your CLASSPATH variable could then be /usr/lib/oracle/11.2/client64/lib/*:..

More details about Setting the class path

Upvotes: 3

Related Questions