加载 DB2 JDBC 驱动程序时出现 java.lang.UnsatisfiedLinkError
我尝试将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.
相关文章