2
votes

I am using oracle 11g. I write code to connect oracle database with java 1.6, but I can't connect to it. When configure the guide line to below:

I have ojdbc6.jar,orai18n.jar, and class12.jar.

I set Class_Path:

%ORACLE_HOME%\jlib\orai18n.jar;r;%Oracle_home%\jdbc\ojdbc6.jar

After that I run sample java code connect to oracle database, but I met this error below:

C:\Program Files\Java\jdk1.6.0_11\bin>javac c:\JDBCVersion.java
c:\JDBCVersion.java:2: package oracle.jdbc does not exist
import oracle.jdbc.*;
^
c:\JDBCVersion.java:3: package oracle.jdbc.pool does not exist
import oracle.jdbc.pool.OracleDataSource;
                       ^
c:\JDBCVersion.java:8: cannot find symbol
symbol  : class OracleDataSource
location: class JDBCVersion
OracleDataSource ods = new OracleDataSource();
^
c:\JDBCVersion.java:8: cannot find symbol
symbol  : class OracleDataSource
location: class JDBCVersion
OracleDataSource ods = new OracleDataSource();
                           ^
4 errors

Could anyone help me to settle this problem?

Thanks, Sopolin

2
Belongs on Stack Overflow ? stackoverflow.comMac
The environment variable is CLASSPATH, not Class_Path by the way. What is the "...;r;..." in the middle of your classpath?Nick Pierpoint

2 Answers

1
votes

This looks like the jar is not on the CLASSPATH. Can you print your CLASSPATH?
Why are you using CLASS_PATH instead of CLASSPATH?

0
votes

Try adding ojdbc6.jar to the compile library list.

If that doesn't work try using the ojdbc14.jar instead, that's the thin JDBC driver.