Sunday, June 08, 2008

Glassfish configuration for DB2


I ran into this problem at least twice, so here is the solution (at least for my own reference in the future):

If you want to use a DB2 (UDB) database from glassfish v2 using a Type 2 JDBC driver [1], you must make sure that the (native) library db2jcct2.dll (or .so) is in the (native) library path. The error message usually says something like "Failure in loading T2 native library db2jcct2".

This DLL resides in your DB2 install directory bin directory, e.g. C:\Programme\IBM\SQLLIB\BIN\db2jcct2.dll on windows, so you have to add this directory (C:\Programme\IBM\SQLLIB\BIN) to the glassfish (!!) native library path in the JVM settings

In the domain.xml config file this is the
native-library-path-prefix="c:\programme\IBM\SQLLIB\BIN" option of the java-config setting.

In the admin web GUI it is on the Application Server page;



under the JVM Settings -> Path Settings you will find the option Native Library Path Prefix:


One additional note:
[1] The IBM Type 2 JDBC driver is the one that uses the native DB2 client (used to be called Client Application Enabler or short CAE at my times with DB2 UDB v5) for DB2 access and connectivity. Hence, the necessity to be able to locate the native DLLs... So when the appserver and the DB2 engine run on the same host, you should use type 2 as well.

No comments: