Monday, June 8, 2009

Spring, DB2 and Atomikos

A while back I had a really hard time finding out how to configure a DB2 XA datasource using Spring and Atomikos. So this is for all you other people battling DB2. Posting this on a google blog will hopefully make google pick it up :-)

<bean id="dataSourceSelmaXA" class="com.atomikos.jdbc.AtomikosDataSourceBean" destroy-method="shutdown">
<property name="xaDataSourceClassName"><value></value></property>
<property name="uniqueResourceName"><value>UNIQUENAME</value></property>
<property name="xaProperties">
<prop key="serverName">HOSTNAME</prop>
<prop key="portNumber">PORTNE</prop>
<prop key="databaseName">DBNAME</prop>
<prop key="user">USER</prop>
<prop key="password">PASS</prop>
<prop key="driverType">4</prop>

Make sure you use driverType 4. Otherwise you'll most likely need a local DB2 client installation. That's what the error messages lead me to believe anyway.


Guy said...


With your permission, I would like to post this in the Atomikos wiki (if you register then you can, too, btw).

Just one small thing: I recommend adding init-method="init" to make sure recovery does its work at the earliest time possible.


John said...

Permission granted :-)

Anything that can make life with DB2 easier is welcome.