java.lang.UnsatisfiedLinkError:java 中没有 ocijdbc11。库.path

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19223416/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 15:12:38  来源:igfitidea点击:

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

javaoraclejdbcoci

提问by Mahmoud Saleh

i am trying to make jdbc oci connectionto oracle 11gthat uses os authentication

我正在尝试将jdbc oci 连接到使用os 身份验证的oracle 11g

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

我制作了一个示例控制台应用程序来测试某些客户端计算机上的连接

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

我在具有jdk 6 的机器上开发了应用程序,并在项目中使用了 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:\orant\jdk\bin

我试图从安装了 oracle11g 的客户端机器上运行这个应用程序,并且 oracle home 的路径设置为: C:\orant\jdk\bin

also the path: C:\orant\bincontains oci.dlland doesn't contain ocijdbc11.dll

还有路径:C:\orant\bin包含oci.dll并且不包含ocijdbc11.dll

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

客户端安装了jre7,没有jdk。

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

尝试在已通过 oracle 数据库进行 os 身份验证的客户端计算机上运行上述代码时,出现以下异常:

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.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.

请告知我如何解决此异常。

采纳答案by Mahmoud Saleh

i was able to make successful os connection to oracle database with jdbc in this post:

在这篇文章中,我能够使用 jdbc 成功建立到 oracle 数据库的 os 连接:

How to connect to oracle database with os authentication?

如何使用 os 身份验证连接到 oracle 数据库?

回答by Prasad

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.

如果您使用 OCI url( "jdbc:oracle:oci:/@"+tnsName),那么您需要在类路径上使用 oracle 客户端库。所以你需要在机器上有 oracle 客户端。

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

但是如果你使用瘦驱动并指定如下url,你就不需要oracle客户端。

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

回答by shcherbak

try set correct values in /usr/share/tomcat/conf/tomcat.conffor ld_path:

尝试在 / 中usr/share/tomcat/conf/tomcat.conf为 ld_path设置正确的值:

LD_LIBRARY_PATH="/usr/lib/oracle/11.2/client64/lib:/usr/lib64"

回答by karthic T.j

If u are using Eclipse with Jboss 6.1.0 disturbution .it will shown error Exception in thread "main" java.lang.UnsatisfiedLinkError: no ocijdbc11 in java. library.path Solution : copy ocijdbc11.dll from oracle\product\11.2.0\client_1\BIN and paste in to

如果您使用带有 Jboss 6.1.0 干扰的 Eclipse。它会在线程“main”java.lang.UnsatisfiedLinkError: no ocijdbc11 in java 中显示错误异常。library.path 解决方法:从oracle\product\11.2.0\client_1\BIN复制ocijdbc11.dll,粘贴到

D:\jboss-6.1.0.Final\bin\native

D:\jboss-6.1.0.Final\bin\native

回答by mayank singh chaudhary

I think you are getting this problem because you are using JRE 1.6 or below version of Java with type-2 driver. Please replace your JRE 1.6 buildpath by JRE 1.7 or JRE 1.8. It will solve the problem.

我认为您遇到此问题是因为您使用的是带有 type-2 驱动程序的 JRE 1.6 或更低版本的 Java。请将您的 JRE 1.6 构建路径替换为 JRE 1.7 或 JRE 1.8。它将解决问题。

Please follow the steps:

请按照以下步骤操作:

  1. Right Click on your project folder
  2. Click on Properties
  3. Click on java build path.
  4. Select "jre system library" which is jre 1.6 or below from libraries and remove it cause this is becoming the source of cause.
  5. Now click add library
  6. Click jre system library
  7. Click next
  8. Select execution environment as JavaSE-1.8(jre1.8.0_144) by clicking environment button and then press ok.
  9. Click installed jre button
  10. Select jre1.8 from it (if jre1.8 is not present the click on add button and add it).
  11. Click Finish.
  12. Click ok.
  13. valah! you will find your code running.
  1. 右键单击您的项目文件夹
  2. 点击属性
  3. 单击 java 构建路径。
  4. 从库中选择 jre 1.6 或更低版本的“jre 系统库”并将其删除,因为这正在成为原因。
  5. 现在点击添加库
  6. 点击jre系统库
  7. 点击下一步
  8. 单击环境按钮选择执行环境为 JavaSE-1.8(jre1.8.0_144),然后按确定。
  9. 单击已安装的 jre 按钮
  10. 从中选择 jre1.8(如果不存在 jre1.8,则单击添加按钮并添加它)。
  11. 单击完成。
  12. 单击确定。
  13. 哇!你会发现你的代码正在运行。