tags:

views:

478

answers:

2

Hi all,

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

A: 

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.

ojdbc6.jar is effectively/generally the same thin driver as ojdbc14.jar - it is just optimized for java 1.6 instead of 1.4
Goyuix
+1  A: 

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

Padmarag