JDBC Driver class not found: oracle.jdbc.OracleDri

2020-07-18 09:48发布

I have installed a third party java webservice which uses Oralce jdbc thin driver to write data into Oracle database. When i run this, i get the following error;

JDBC Driver class not found: oracle.jdbc.OracleDriver

I have oracle installed and set classpath variable to following value:

*D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.zip;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.zip;C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar*

and path variable to following value;

*D:\oracle\product\10.2.0\client_1\bin;C:\Program Files\Java\jdk1.7.0\bin\;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.zip;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.zip*

Any suggestion why web service is not able to identify jdbc driver?

Thanks

标签: oracle jdbc
5条回答
在下西门庆
2楼-- · 2020-07-18 10:23

Make sure you have the ojdbc jar file (make sure you are using the correct one because depending on java version you may need to choose a different one).

use ojdbc14.jar for Java 1.4 use ojdbc5.jar for Java 1.5 ojdbc6.jar for Java 1.6 here is linke where you can download ojdbc6.jar file http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html

查看更多
虎瘦雄心在
3楼-- · 2020-07-18 10:25

Method 1: Download ojdbc.jar

add ojdbc6.jar to deployment assembly. Right click on project->properties->select deployment assembly->click on 'Add' ->select 'Archives from File System'->browse to the folder where ojdbc6.jar is saved.->add the jar->click finish->Apply/OK.

Method 2:

if you want to add ojdbc.jar to your maven dependencies you follow this link: http://www.mkyong.com/maven/how-to-add-oracle-jdbc-driver-in-your-maven-local-repository/ . . Even if you're using a maven project it is not necessary to add ojdbc to maven dependencies(method 2), method 1 (adding directly to deployment assembly) works just fine.

查看更多
贪生不怕死
4楼-- · 2020-07-18 10:25

add ojdbc-6.jar to your lib directory of tomcat installation. Maven will downlowd this jar for you in .m2 directory, but you need to have this jar in tomcat lib as well.

查看更多
兄弟一词,经得起流年.
5楼-- · 2020-07-18 10:27

You also have to add the jdbc jar to your server classpath. if tomcat, rigth-click on your Project->run as->run configurations, click on classpath and add your jdbc jar in Add external jars option

查看更多
萌系小妹纸
6楼-- · 2020-07-18 10:32

I know 2 ways of turning Java app into Windows service and both do not use CLASSPATH. One is Java Service Wrapper by Tanuki Software. This tool uses wrapper.conf where you can show directories with .jar libraries:

# Java Classpath (include wrapper.jar)  Add class path elements as
#  needed starting from 1
wrapper.java.classpath.1=c:\jars\*
wrapper.java.classpath.2=myservice.jar

Second tool I know is JSL: Java Service Launcher. In this tool there is jsl.ini where you put command line to run your server. It can use java with -cp option to show location of .jar libraries:

[defines]
MY_LIBS=d:\jars\*
AXIS_LIBS=d:\axis2-1.5.4\lib\*
CLASSPATH=.;%MY_LIBS%;%AXIS_LIBS%
export = CLASSPATH
...

[java]
...
cmdline = -Dfile.encoding=utf8 -cp %CLASSPATH% example.my.server

In both configuration you can use * to add all .jar files or you can show those files one by one (just like in CLASSPATH).

At first you should know what Windows is trying to execute. Check it in the service properties page. Then try to localize its configuration. If it uses one of tools I know then you know what to change. Other tools probably have similar configuration.

查看更多
登录 后发表回答