問題描述
我嘗試將jboss-seam與db2數(shù)據(jù)庫(kù)一起使用,出現(xiàn)以下錯(cuò)誤
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
我嘗試設(shè)置 -Djava.library.path=/opt/IBM/db2/V9.5/lib64
以及
-Djava.library.path=/opt/IBM/db2/V9.5/lib32
兩個(gè)路徑都包含 libdb2jcct2.so
我也嘗試設(shè)置 LD_LIBRARY_PATH
無效.
I also tried to set LD_LIBRARY_PATH
with no effect.
操作系統(tǒng)是 MacOs
OS is MacOs
編輯我還嘗試使用 JDBC4 驅(qū)動(dòng)程序 db2jcc4.jar,因?yàn)?jdbc4 驅(qū)動(dòng)程序不應(yīng)該依賴本機(jī)庫(kù).
EDIT I also tried to use a JDBC4 driver , db2jcc4.jar since jdbc4 drivers shouldn't rely on native libs.
推薦答案
適用于 JDBC 和 SQLJ 的 IBM 數(shù)據(jù)服務(wù)器驅(qū)動(dòng)程序包括 Type 2 和 Type 4 JDBC 驅(qū)動(dòng)程序.請(qǐng)檢查以下內(nèi)容:
The IBM Data Server Driver for JDBC and SQLJ includes both Type 2 and Type 4 JDBC drivers. Please check the following:
1) 確保驅(qū)動(dòng)程序位于您的類路徑中:db2jcc.jar.或者,您可以使用 JDBC4 驅(qū)動(dòng)程序 (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) 確保您在應(yīng)用配置中指定了 JCC 驅(qū)動(dòng)程序 (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,那么驅(qū)動(dòng)程序?qū)㈤_始尋找本機(jī)庫(kù).
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.
這篇關(guān)于加載 DB2 JDBC 驅(qū)動(dòng)程序時(shí)出現(xiàn) java.lang.UnsatisfiedLinkError的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!