4 Replies Latest reply on Feb 1, 2007 10:24 AM by Adrian Pillinger

    Configuring a DB2 XA connection

    Mike Hostetler Newbie

      I'm trying to get a DB2 XA connection.

      I copied the db2-xa-ds.xml file into server/default/deploy. I also copied db2jcc.jar into server/default/lib (I'm using DB2 UDB 8.1, so I can't use db2java.zip). I edited my db2-xa-ds.xml file to look like this:

       <xa-datasource>
       <jndi-name>jdbc/WPDS</jndi-name>
      
       <xa-datasource-class>com.ibm.db2.jcc.DB2XADataSource</xa-datasource-class>
      
       <xa-datasource-property name="URL">jdbc:db2://acio-wpdbs:50000/mh331b13</x>
       <xa-datasource-property name="User">db2inst1</xa-datasource-property>
       <xa-datasource-property name="Password">db2inst1</xa-datasource-property>
       </xa-datasource>
      


      When I try to use the connection, I get the following error:
       SQLException occurred: Could not create connection; - nested throwable:
      (com.ibm.db2.jcc.b.SQLException: Driver type 2 not enabled for XA
      connections); - nested throwable:
      (org.jboss.resource.JBossResourceException: Could not create connection;
       - nested throwable: (com.ibm.db2.jcc.b.SQLException: Driver type 2 not
      enabled for XA connections))
      


      So it defaulted to a Type 2 connection. DB2 Type 4 connections have XA ( I think) but I don't know how to set it. I've tried:
      <xa-datasource-property name="DriverType">4</xa-datasource-property>
      


      But I got the same error.

      Anyone have this working??

        • 1. Re: Configuring a DB2 XA connection
          Adrian Brock Master

          8.2 definitley works with the type 4 driver.
          But you need to add

          <track-connection-by-tx/>
          


          • 2. Re: Configuring a DB2 XA connection
            Mike Hostetler Newbie

            When I try putting the "<track-connection-by-tx/>" tag in my db2-xa-ds.xml I get the following exception:

            12:07:20,303 INFO [STDOUT] 2004-11-01 12:07:20,303 [RMI TCP
            Connection(2)-172.16.21.70] ERROR com.workpoint.server.ejb.GenericBean
             - SQLException occurred: Could not create connection; - nested throwable:
            (org.jboss.resource.JBossResourceException: Could not find accessor on
            XADataSource: ; - nested throwable: (java.lang.NoSuchMethodException:
            com.ibm.db2.jcc.DB2XADataSource.setURL(java.lang.String))); - nested
            throwable: (org.jboss.resource.JBossResourceException: Could not create
            connection; - nested throwable:
            (org.jboss.resource.JBossResourceException: Could not find accessor on
            XADataSource: ; - nested throwable: (java.lang.NoSuchMethodException:
            com.ibm.db2.jcc.DB2XADataSource.setURL(java.lang.String)))



            • 3. Re: Configuring a DB2 XA connection
              k_r_ashwin Newbie

              This is sample datasource configuration which is working for me

              <xa-datasource>
              <track-connection-by-tx/>

              <jndi-name>WmxJmsDataSource</jndi-name>
              <xa-datasource-property name="PortNumber">15020</xa-datasource-property>
              <xa-datasource-property name="DatabaseName">TEST</xa-datasource-property>
              <xa-datasource-property name="ServerName">192.168.1.134</xa-datasource-property>

              <xa-datasource-class>com.ibm.db2.jcc.DB2XADataSource</xa-datasource-class>
              <xa-datasource-property name="User">ashwin</xa-datasource-property>
              <xa-datasource-property name="Password">ashwin</xa-datasource-property>
              <xa-datasource-property name="DriverType">4</xa-datasource-property>


              <type-mapping>DB2</type-mapping>

              </xa-datasource>

              • 4. Re: Configuring a DB2 XA connection
                Adrian Pillinger Newbie

                K R Ashwin...

                Which version of DB2 are you using and which version of the driver?

                Thanks.