Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

oracle - java.lang.UnsatisfiedLinkError: no ocijdbc11 in java. library.path

i am trying to make jdbc oci connection to oracle 11g that uses os authentication

i made a sample console application to test the connection on some client machine

i developed the application on machine that has jdk 6 and used in the project the jar ojdbc6.jar.

the code i am using to connect to database is as follows:

OracleDataSource ods = new OracleDataSource();
String tnsName="Prod";
ods.setURL("jdbc:oracle:oci:/@"+tnsName);
Connection conn = ods.getConnection();

i am trying to run this application from client machine that has the oracle11g installed, and the oracle home is set on path to be: C:orantjdkin

also the path: C:orantin contains oci.dll and doesn't contain ocijdbc11.dll

the client has jre7 installed and doesn't have jdk.

when trying to run the above code on client machine that is os authenticated to oracle database i am getting following exception:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no ocijdbc11 in java.
library.path
        at java.lang.ClassLoader.loadLibrary(Unknown Source)
        at java.lang.Runtime.loadLibrary0(Unknown Source)
        at java.lang.System.loadLibrary(Unknown Source)
        at oracle.jdbc.driver.T2CConnection$1.run(T2CConnection.java:3178)
        at java.security.AccessController.doPrivileged(Native Method)
        at oracle.jdbc.driver.T2CConnection.loadNativeLibrary(T2CConnection.java
:3174)
        at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:233)
        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:
508)
        at oracle.jdbc.driver.T2CConnection.<init>(T2CConnection.java:133)
        at oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtensio
n.java:53)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:510)
        at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSou
rce.java:275)
        at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java
:206)
        at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java
:156)
        at auth.Main.main(Main.java:42)

please advise how can i fix this exception.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you use an OCI url("jdbc:oracle:oci:/@"+tnsName) then you need oracle client libraries on the classpath. So you need have oracle client on the machine.

But if you use a thin driver and specify the url as the following, you don't need the oracle client.

"jdbc:oracle:thin:@"+dbServer+":"+port+":"+SID; 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...