Connect oracle 11g database using java 1.7

对着背影说爱祢 提交于 2019-12-11 01:27:33

问题


Please help me.I have installed Oracle 11g on Windows 7 (32 bit) and i'm trying to connect database with jdk 1.7

but i get an error saying

package oracle.jdbc.driver does not exist

Oracle 11g is installed in E: Drive.

I have pointed my Path and CLASSPATH as following

CLASSPATH

C:\Program Files\Java\jdk1.7.0

E:\app\malisa\product\11.2.0\dbhome_1\jdbc\lib

The following jar files are in the location E:\app\malisa\product\11.2.0\dbhome_1\jdbc\lib

ojdbc5

ojdbc5_g

ojdbc5dms

ojdbc5dms_g

ojdbc6

ojdbc6_g

ojdbc6dms

ojdbc6dms_g

simplefan

Thanks in advance

Malisa


回答1:


Specifying just a directory does not add the jar files in that directory to the classpath. You must add the jar file explicitly to your classpath like so --

E:\app\malisa\product\11.2.0\dbhome_1\jdbc\lib\ojdbc.jar

Or if you want to add multiple jar files, then you could use wildcards like this

E:\app\malisa\product\11.2.0\dbhome_1\jdbc\lib\*

Take a look at how to set classpath in Java 7.




回答2:


You could put the JAR file in the JRE/lib/ext directory. That means it will be on the classpath of every Java application. This is a little heavy handed though.



来源:https://stackoverflow.com/questions/7149626/connect-oracle-11g-database-using-java-1-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!