Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.UnsatisfiedLinkError while loading DB2 JDBC driver

Tags:

java

macos

jdbc

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

I tried setting -Djava.library.path=/opt/IBM/db2/V9.5/lib64 as well as

-Djava.library.path=/opt/IBM/db2/V9.5/lib32

Both paths include libdb2jcct2.so

I also tried to set LD_LIBRARY_PATH with no effect.

OS is MacOs

EDIT I also tried to use a JDBC4 driver , db2jcc4.jar since jdbc4 drivers shouldn't rely on native libs.

like image 688
stacker Avatar asked Oct 18 '10 07:10

stacker


4 Answers

The IBM Data Server Driver for JDBC and SQLJ includes both Type 2 and Type 4 JDBC drivers. Please check the following:

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) Make sure that you're specifying the JCC driver (com.ibm.db2.jcc.DB2Driver) in your app configuration.

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.

like image 92
Ian Bjorhovde Avatar answered Nov 15 '22 15:11

Ian Bjorhovde


Have you tried setting DYLD_LIBRARY_PATH too? Might be worth a shot.

like image 45
dogbane Avatar answered Nov 15 '22 16:11

dogbane


From the path, this looks a linux /unix platform. Try running strace/truss to see which directories are getting opened for library.

like image 2
Jayan Avatar answered Nov 15 '22 17:11

Jayan


Append a "driverType=4;" to your URL.

like image 2
Antonio Varela Avatar answered Nov 15 '22 15:11

Antonio Varela