JDBC Slim in Oracle 11g with java

I am using oracle 11g. I am writing code to connect oracle database with java 1.6, but I cannot connect to it. When adjust the guide line below:

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

.

I have set Class_Path:

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

      

After that I run the java code example to connect to oracle database, but I came across 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

      

Can anyone help me solve this problem?

Thanks, Sopolin

+2


source to share


2 answers


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



+1


source


Try adding ojdbc6.jar to the compilation libraries list.



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

0


source







All Articles