I trying to configure an XA DB2 DataSource, xa-datasource
(based on http://community.jboss.org/wiki/SetUpADB2Datasource) using com.ibm.db2.jcc.DB2XADataSource
class (local-tx-datasource
works using the com.ibm.db2.jcc.DB2Driver
). The target server is DB2 Connect V9.7
Actual xa-datasource config:
<xa-datasource>
<jndi-name>jdbc/DB2ServerDS</jndi-name>
<use-java-context>false</use-java-context>
<track-connection-by-tx>true</track-connection-by-tx>
<xa-datasource-class>com.ibm.db2.jcc.DB2XADataSource</xa-datasource-class>
<xa-datasource-property name="URL">jdbc:db2://db2server:50000/FINDB</xa-datasource-property>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.DB2ExceptionSorter</exception-sorter-class-name>
<xa-datasource-property name="DriverType">4</xa-datasource-property>
<check-valid-connection-sql>SELECT * FROM ACC.SETTINGS 1=2</check-valid-connection-sql>
<user-name>findbuser</user-name>
<password>findbuser</password>
<min-pool-size>2</min-pool-size>
<max-pool-size>10</max-pool-size>
<blocking-timeout-millis>10000</blocking-timeout-millis>
<type-mapping>DB2</type-mapping>
<no-tx-separate-pools/>
</xa-datasource>
and the following jar in the JBoss node lib directory:
db2umplugin.jar
db2policy.jar
db2dbgm.jar
db2jcc_license_cu.jar
db2jcc.jar
db2jcc4.jar
db2java.zip
db2jcc_license_cisuz.jar
but i'm getting the error:
Caused by: com.ibm.db2.jcc.am.SqlException: [jcc][10389][12245][3.57.82] Failure in loading native library db2jcct2, java.lang.UnsatisfiedLinkError: no db2jcct2 in java.library.path: ERRORCODE=-4472, SQLSTATE=null
The driver for XA is trying to use native libraries, despite the fact that i'm using a JDBC Type 4 driver.
Why is the driver trying to use native libraries? Is there anything i need to add to my config?
The solution is not to use the URL to specify the connection settings.
<xa-datasource>
<jndi-name>jdbc/DB2ServerDS</jndi-name>
<use-java-context>false</use-java-context>
<track-connection-by-tx>true</track-connection-by-tx>
<xa-datasource-class>com.ibm.db2.jcc.DB2XADataSource</xa-datasource-class>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.DB2ExceptionSorter</exception-sorter-class-name>
<xa-datasource-property name="ServerName">db2server</xa-datasource-property>
<xa-datasource-property name="PortNumber">50000</xa-datasource-property>
<xa-datasource-property name="DatabaseName">FINDB</xa-datasource-property>
<xa-datasource-property name="DriverType">4</xa-datasource-property>
<xa-datasource-property name="User">findbuser</xa-datasource-property>
<xa-datasource-property name="Password">findbuser</xa-datasource-property>
<xa-datasource-property name="DriverType">4</xa-datasource-property>
<check-valid-connection-sql>SELECT * FROM ACC.SETTINGS 1=2</check-valid-connection-sql>
<user-name>findbuser</user-name>
<password>findbuser</password>
<min-pool-size>2</min-pool-size>
<max-pool-size>10</max-pool-size>
<blocking-timeout-millis>10000</blocking-timeout-millis>
<type-mapping>DB2</type-mapping>
<no-tx-separate-pools/>
</xa-datasource>
Credit to http://dev.wavemaker.com/forums/?q=node/3127
The correct JARs are
db2jcc_license_cu.jar
db2jcc4.jar
db2jcc_license_cisuz.jar
Should you get an error like:
org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-5042, SQLSTATE= , SQLERRMC= ;1208;FINDBUSER;FINDB;QDB2; ; ; ;1208; , DRIVER=4.7.85)
check http://www-01.ibm.com/support/docview.wss?uid=swg21405243&myns=swgimgmt&mynp=OCSSEPGG&mync=R for the solution.
I hope this saves others some frustration and time.