问题描述
我尝试用db2数据库使用jboss-seam,发生以下错误
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
EDIT
我也试图使用JDBC4驱动程序,db2jcc4.jar,因为jdbc4驱动程序不应该依赖本机库。
EDITI also tried to use a JDBC4 driver , db2jcc4.jar since jdbc4 drivers shouldn't rely on native libs.
推荐答案
用于JDBC和SQLJ的IBM Data Server驱动程序包括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) 4 URL如 jdbc:db2:// server:port / database
。如果您指定了类似于 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!