oracle ocijdbc11 在 java.library.path 中找不到
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45223862/
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
ocijdbc11 Not found in java.library.path
提问by Vikora
I inherited a small java utility from other developer -- just a couple of .java files and executable .jar.
我从其他开发人员那里继承了一个小型 java 实用程序——只有几个 .java 文件和可执行的 .jar。
I run java program by passes a connection string. Now I need to change the connection string to Oracle from jdbc:oracle:thin:<user>/<password>@host
to jdbc:oracle:oci:<user>/<password>@host
to start using thick instead of thin driver.
我通过传递连接字符串来运行 java 程序。现在我需要连接字符串到Oracle从改变jdbc:oracle:thin:<user>/<password>@host
到jdbc:oracle:oci:<user>/<password>@host
开始使用的,而不是瘦驱动程序厚。
As a result I get the error: "ocijdbc11 (Not found in java.library.path)".
结果我收到错误:“ocijdbc11(在 java.library.path 中未找到)”。
Here my questions:
这是我的问题:
- Is ocijdbc11 a part of ojdbc7.jar? Or what file do java need?
ANSW: ocijdbc11 is a library:
/oracle/client/o11r2/lib/libocijdbc11.so
- How can I see which paths java uses to find that
ocijdbc11
?
- ocijdbc11 是 ojdbc7.jar 的一部分吗?或者java需要什么文件?ANSW:ocijdbc11 是一个库:
/oracle/client/o11r2/lib/libocijdbc11.so
- 我如何才能看到 java 使用哪些路径来找到它
ocijdbc11
?
Just in case:
以防万一:
$ ls /oracle/client/o12r1/
assistants diagnostics jlib oui slax
bin dmu ldap owm sqlplus
cdata has lib perl srvm
cfgtoollogs hs network plsql ucp
clone install nls precomp usm
crs instantclient odbc QOpatch utl
css inventory OPatch racg wwg
cv javavm opmn rdbms xdk
dc_ocm jdbc oracore relnotes
deinstall jdk oraInst.loc root.sh
UPDI tried to use option -Djava.library.path=/oracle/client/o11r2
and got other error. But I still don't know how to use Oracle 12.1 instead of 11.2.
UPD我尝试使用选项-Djava.library.path=/oracle/client/o11r2
并遇到其他错误。但是我仍然不知道如何使用Oracle 12.1而不是11.2。
UPD2I've changed environment paths to use Oracle 12 instead of 11. And now error looks like ocijdbc12 (Not found in java.library.path)
. The file /oracle/client/o12r1/lib/libocijdbc12.so exists.
UPD2我已更改环境路径以使用 Oracle 12 而不是 11。现在错误看起来像ocijdbc12 (Not found in java.library.path)
. 文件 /oracle/client/o12r1/lib/libocijdbc12.so 存在。
I added /oracle/client/o11r2/lib
to LD_LIBRARY_PATH
-- the same error (ocijdbc12 (Not found in java.library.path)
). I tried option -Djava.library.path=/oracle/client/o12r2/lib
-- the same error. Could you please help me to fix it?
我添加/oracle/client/o11r2/lib
到LD_LIBRARY_PATH
-- 同样的错误 ( ocijdbc12 (Not found in java.library.path)
)。我试过选项-Djava.library.path=/oracle/client/o12r2/lib
——同样的错误。你能帮我修一下吗?
回答by Jean de Lavarene
ocijdbc11 is a native libary (.so or .dll) which you can download from the Oracle Instant Client. It's the layer that contains the JNI calls into the OCI. This library is needed if you want to use the thick driver. Be sure to install the version that matches your ojdbc jar (i.e. it looks like you're using the JDBC jar from 11.2 otherwise if you were using ojdbc jar from 12.1 the error would have complained about ocijdbc12 missing).
ocijdbc11 是一个本地库(.so 或 .dll),您可以从 Oracle Instant Client 下载它。它是包含 JNI 调用到 OCI 的层。如果要使用厚驱动程序,则需要此库。确保安装与您的 ojdbc jar 匹配的版本(即看起来您正在使用 11.2 中的 JDBC jar,否则如果您使用 12.1 中的 ojdbc jar,错误会抱怨 ocijdbc12 丢失)。
回答by Zsigmond L?rinczy
To run your program, you will need both ojdbcN.jar
and libocijdbcM.so
. These components have to come from the same Oracle-client; Nrefers to the Java version, Mrefers to the Oracle-version.
要运行您的程序,您将需要ojdbcN.jar
和libocijdbcM.so
。这些组件必须来自同一个 Oracle 客户端;N代表Java版本,M代表Oracle-version。
Of course you will need libclntsh.so
and its dependent libraries, too.
当然,您也需要libclntsh.so
及其依赖库。
You could try this (supposing java7, 64-bit):
你可以试试这个(假设 java7,64 位):
export ORACLE_HOME=/oracle/client/o12r1
export LIBPATH=$ORACLE_HOME/lib
java -cp $ORACLE_HOME/jdbc/lib/ojdbc7.jar:... -Djava.library.path=$ORACLE_HOME/lib
Edit: the java executable and the libraries should have the same bitnumber (32 or 64), eg this combination will not work:
编辑:java 可执行文件和库应该具有相同的位数(32 或 64),例如这种组合将不起作用:
$ file $JAVA_HOME/bin/java $ORACLE_HOME/lib/libclntsh.so $ORACLE_HOME/lib/libocijdbc12.so
/usr/java6/bin/java: executable (RISC System/6000) or object module not stripped
/orabin/OraHome_Current/lib/libclntsh.so: 64-bit XCOFF executable or object module not stripped
/orabin/OraHome_Current/lib/libocijdbc12.so: 64-bit XCOFF executable or object module not stripped
Here java is of 32-bit, Oracle is of 64-bit.
这里java是32位的,Oracle是64位的。
Edit: This question is flagged AIX. Is that intentional?
编辑:这个问题被标记为 AIX。这是故意的吗?