問題描述
我嘗試將jboss-seam與db2數據庫一起使用,出現以下錯誤
I try to use jboss-seam with a db2 database, the following error occurs
com.ibm.db2.jcc.a.SqlException: [jcc][10389][12245][3.52.95] while loading the native
library db2jcct2, java.lang.UnsatisfiedLinkError: no db2jcct2 in java.library.path
an error occurred ERRORCODE=-4472, SQLSTATE=null
我嘗試設置 -Djava.library.path=/opt/IBM/db2/V9.5/lib64
以及
-Djava.library.path=/opt/IBM/db2/V9.5/lib32
兩個路徑都包含 libdb2jcct2.so
我也嘗試設置 LD_LIBRARY_PATH
無效.
I also tried to set LD_LIBRARY_PATH
with no effect.
操作系統是 MacOs
OS is MacOs
編輯我還嘗試使用 JDBC4 驅動程序 db2jcc4.jar,因為 jdbc4 驅動程序不應該依賴本機庫.
EDIT I also tried to use a JDBC4 driver , db2jcc4.jar since jdbc4 drivers shouldn't rely on native libs.
推薦答案
適用于 JDBC 和 SQLJ 的 IBM 數據服務器驅動程序包括 Type 2 和 Type 4 JDBC 驅動程序.請檢查以下內容:
The IBM Data Server Driver for JDBC and SQLJ includes both Type 2 and Type 4 JDBC drivers. Please check the following:
1) 確保驅動程序位于您的類路徑中:db2jcc.jar.或者,您可以使用 JDBC4 驅動程序 (db2jcc4.jar),但不要將兩者都放在類路徑中.
1) Make sure the driver is in your classpath: db2jcc.jar. Alternatively you can use the JDBC4 driver (db2jcc4.jar), but don't put both in the classpath.
2) 確保您在應用配置中指定了 JCC 驅動程序 (com.ibm.db2.jcc.DB2Driver
).
2) Make sure that you're specifying the JCC driver (com.ibm.db2.jcc.DB2Driver
) in your app configuration.
3) 使用像 jdbc:db2://server:port/database
這樣的 Type-4 URL.如果您指定像 jdbc:db2:database
這樣的 Type-2 URL,那么驅動程序將開始尋找本機庫.
3) Use a Type-4 URL like jdbc:db2://server:port/database
. If you specify a Type-2 URL like jdbc:db2:database
then the driver will start looking for native libraries.
這篇關于加載 DB2 JDBC 驅動程序時出現 java.lang.UnsatisfiedLinkError的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!