IBM Support

java.lang.UnsatisfiedLinkError: SQLConnect error connecting to DB2 type 2 datasource

Troubleshooting


Problem

When trying to connect to a DB2® type 2 datasource from WebSphere® Application Server error java.lang.UnsatisfiedLinkError: SQLConnect occurs.

Symptom

A type 2 driver has a native library that must be loaded by the jvm process. A java.lang.UnsatisfiedLinkError means that the WebSphere Application Server jvm process could not find or could not load the DB2 library.

The following java stack is typical of an UnsatisfiedLinkError using the DB2 legacy driver

java.lang.UnsatisfiedLinkError:
COM/ibm/db2/jdbc/app/DB2Connection.SQLConnect(Ljava/lang/String;II)I
at COM.ibm.db2.jdbc.app.DB2Connection.connect(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2Connection.<init>(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2ReusableConnection.<init>(Unknown
Source)
at COM.ibm.db2.jdbc.DB2PooledConnection.getConnection(Unknown
Source)
at
com.ibm.ws.rsadapter.spi.WSRdbDataSource.getConnection(WSRdbDataSource.j
ava:1768)


The DB2 legacy driver uses these two files
  • db2java.zip -- this is the file that contains the java portion of the driver
  • libdb2jdbc.a|so or db2jdbc.dll -- this is the native library for the legacy driver.
The following java stack is typical of an UnsatisfiedLinkError using the DB2 universal driver.
[7/22/10 4:29:14:723 PDT] 00000023 SystemOut O com.ibm.db2.jcc.am.
SqlException: [jcc][10389][12245][3.59.81] Failure in loading native
library db2jcct2, java.lang.UnsatisfiedLinkError: /opt/IBM/db2/V9.
7/lib32/libdb2jcct2.so: load ENOEXEC on shared library(s)
/opt/IBM/db2/V9.7/lib32/libdb2jcct2.so
/udb1/bassprod/sqllib/lib64/libdb2.a: ERRORCODE=-4472, SQLSTATE=null
at com.ibm.db2.jcc.am.dd.a(dd.java:660)
at com.ibm.db2.jcc.am.dd.a(dd.java:60)
at com.ibm.db2.jcc.am.dd.a(dd.java:94)
at com.ibm.db2.jcc.t2.a.a(a.java:37)
at com.ibm.db2.jcc.t2.T2Configuration.<clinit>(T2Configuration.
java:95)
at com.ibm.db2.jcc.DB2BaseDataSource.instantiateLogWriter
(DB2BaseDataSource.java:10185)
at com.ibm.db2.jcc.DB2BaseDataSource.
computeJccLogWriterForNewConnection(DB2BaseDataSource.java:10106)
at com.ibm.db2.jcc.DB2BaseDataSource.
computeJccLogWriterForNewConnection(DB2BaseDataSource.java:10062)
at com.ibm.db2.jcc.DB2ConnectionPoolDataSource.
getPooledConnection(DB2ConnectionPoolDataSource.java:218)

The DB2 universal (UDB) driver uses these two files
  • db2jcc.jar -- this is the file that contains the java portion of the driver
  • libdb2jcct2.a|so or db2jcct2.dll -- this is the native library for the DB2 universal driver.

Cause

The most likely causes of this issue are these.

1. a 32-bit vs. 64-bit mismatch between the jvm process and the library version.

2. the location of the driver is not configured correctly in the WebSphere Application Server configuration.

3. the operating system userid does not have permission to load the driver or access the directory on which the library is located.

Diagnosing The Problem

Checking for a 32-bit vs. 64-bit mismatch

1. From a command prompt, run the setupCmdLine.sh|bat file. Then run 'java -fullversion' and confirm if the
java sdk is 32-bit or 64-bit.

2. Run db2level and confirmed whether the db2client is 32-bit or 64-bit.

The location of the library also indicates if it is a 32-bit or 64-bit driver.

* db2instance_user_home/sqllib/lib64 (for a 64-bit instance of DB2)
* db2instance_user_home/sqllib/lib32 (for a 32-bit instance of DB2)

NOTE: By default in DB2 V9.5, the default environment is always 64-bit.

Validating the location of the driver.
1. Determine from where the Application Server jvm is trying to load the DB2 library.
2. Confirm that the DB2 library is located in this directory.

Checking permissions on the directory and the driver.
1. Determine from where the Application Server jvm is loading the library.
2. Confirm whether the userid used to run the Application Server jvm has execution permission on the directory on the the db2jcct2 library.

Resolving The Problem

If the problem is due to a 32-64 bit mismatch between the Application Server jvm version and the driver version, then make sure that the jvm is using the appropriate library version.
1. From the Administrative Console, select Resources > JDBC > JDBC Providers.
2. Confirm that the native library path is set to the location of the driver that matches the jvm version.

  • for the legacy driver the location of the 32-bit library is X and the location of the 64-bit driver is Y.
  • for the universal driver the location of the 32-bit library is X and the location of the 64-bit driver is Y.

If the problem is due to the driver not being found, then there are a couple of things to try to resolve the problem.
1. Check the Native Library Path on the JDBC Provider configuration.
  • From the Administrative Console, select Resources > JDBC > JDBC Providers
  • Check the native libary path setting
  • List the files in the native library path to determine if the library is located in that directory.
2. Ensure that db2profile has been run in the shell starting WebSphere Application Server. You can find db2profile in the following directory:
  • For DB2 8.2 and later:

  • instance_root/sqllib/lib

  • For releases earlier than DB2 8.2:

  • instance_root/sqllib

Also, the shared library path environment variable (LIBPATH in AIX®, LD_LIBRARY_PATH in the other UNIX® platforms) should be extended to include the following:

DB2_instance_root/sqllib/java12

This directory contains the appropriate library needed to support the DB2 (type 2) JDBC driver being used.

Another solution is to use the Universal (type 4) driver.


If the problem is with the permissions granted to the userid, then either grant the Application Server userid the proper permissions to access the native library and directory OR change the userid used to execute the Application Server jvm process to one that does have the permissions to access the DB2 library and directory. For example, for the DB2 legacy driver the OS permissions should be
-r-xr-xr-x 1 bin bin 156153 Jan 22 2008 libdb2jdbc.so

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Java 2 Connectivity (J2C)","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF012","label":"IBM i"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF035","label":"z\/OS"}],"Version":"9.0;8.5.5;8.0;7.0","Edition":"Base;Express;Network Deployment","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SSNVBF","label":"Runtimes for Java Technology"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Java SDK","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB36","label":"IBM Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21110708