Tuesday, March 31, 2009

Swollen Joints And Hives

Glassfish, JDBC, DB / 2

The JDBC driver from IBM for DB / 2 has it all: work normal connections from DriverManager, but accessing a data source - which makes the glass Fish - fails with an error message saying

Caused by: com.ibm.db2.jcc.a . SqlException: jcc10389122453.51.90
When you load the native library db2jcct2,
java.lang.UnsatisfiedLinkError: no db2jcct2 in java.library.path is a error occurred: ERROR CODE =- 4472, SQLSTATE = null

This comes from the fact that the driver will default as type 2 driver reload a native library. I got it even after copying of 36 MB only managed libraries that he does not more complains about missing libraries, but crashes with a segmentation fault. The solution to the problem is to tell the driver that he should be a type 4 driver. With the DriverManager this is sufficient to specify the port in the URL. Calling In the DataSource must be the method "setType (4):

DB2DataSource dB2DataSource com.ibm.db2.jcc.DB2DataSource = new ();
dB2DataSource.setDriverType (4);
dB2DataSource.setServerName ("192.168.1.194");
dB2DataSource.setPortNumber (50000);
dB2DataSource.setUser ("XXX");
dB2DataSource.setPassword ("YYY");
dB2DataSource.setDatabaseName ("ZZZ");
dB2DataSource.setSysSchema ("XYZ");
dB2DataSource.getConnection ();

in and it works. In Glassfish, this is set up as follows: one selects from a database DB / 2, the Data Source class will change to "com.ibm.db2.jcc.DB2XADataSource", and as type "javax.sql.XADataSource.



The Properties have to insert an additional property "driver type" and set to the value 4:


one has done that, we ping green and all without native libraries. Of course not forget to copy the driver file in the lib directory of Glassfish domain, so that he can find him at all.

0 comments:

Post a Comment