Version 15

    Set up a DB2 datasource

     

    Local-XA

     

    Copy $db2_install_dir/java/db2jcc.jar and $db2_install_dir/java/db2jcc_license_cu.jar into $jboss_install_dir/server/default/lib. The db2java.zip (part of the legacy CLI driver) is normally not required when using the DB2 Universal JDBC driver (DB2 v8.1+)!

     

     

    <datasources>
    
      <local-tx-datasource>
        <jndi-name>DB2DS</jndi-name>
        <!-- Use the syntax 'jdbc:db2:yourdatabase' for jdbc type 2 connection -->
        <!-- Use the syntax 'jdbc:db2://serveraddress:port/yourdatabase' for jdbc type 4 connection -->
        <connection-url>jdbc:db2://serveraddress:port/yourdatabase</connection-url>
        <driver-class>com.ibm.db2.jcc.DB2Driver</driver-class>
        <user-name>x</user-name>
        <password>y</password>
        <min-pool-size>0</min-pool-size>
            <!-- sql to call when connection is created
            <new-connection-sql>some arbitrary sql</new-connection-sql>
            -->
    
            <!-- sql to call on an existing pooled connection when it is obtained from pool 
            <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
            -->
    
          <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
          <metadata>
             <type-mapping>DB2</type-mapping>
          </metadata>
      </local-tx-datasource>
    
    </datasources>
    

     

    XA

     

    Copy $db2_install_dir/java/db2jcc.jar and $db2_install_dir/java/db2jcc_license_cu.jar into $jboss_install_dir/server/default/lib.

     

    The db2java.zip is required when using the DB2 Universal JDBC driver (type 4) for XA on DB2 v8.1 fixpak 14 (and the corresponding DB2 v8.2 fixpak 7).

     

     

    <datasources>
       <!--
           XADatasource for DB2 v8.x (app driver)
       -->
    
       <xa-datasource>
         <jndi-name>DB2XADS</jndi-name>
    
         <xa-datasource-class>com.ibm.db2.jcc.DB2XADataSource</xa-datasource-class>
         <xa-datasource-property name="ServerName">your_server_address</xa-datasource-property>
         <xa-datasource-property name="PortNumber">your_server_port</xa-datasource-property>
         <xa-datasource-property name="DatabaseName">your_database_name</xa-datasource-property>
         <!-- DriverType can be either 2 or 4, but you most likely want to use the JDBC type 4 as it doesn't require a DB" client -->
         <xa-datasource-property name="DriverType">4</xa-datasource-property>
         <!-- If driverType 4 is used, the following two tags are needed -->     
         <track-connection-by-tx></track-connection-by-tx>
         <isSameRM-override-value>false</isSameRM-override-value>
    
         <xa-datasource-property name="User">your_user</xa-datasource-property>
         <xa-datasource-property name="Password">your_password</xa-datasource-property>
    
          <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
          <metadata>
             <type-mapping>DB2</type-mapping>
          </metadata>
       </xa-datasource>
    
    </datasources>
    

     

    DB2 on AS/400

     

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!-- ===================================================================== -->
    <!--                                                                       -->
    <!--  JBoss Server Configuration                                           -->
    <!--                                                                       -->
    <!-- ===================================================================== -->
    
    <!-- $Id: db2-400-ds.xml,v 1.1.4.2 2004/10/27 18:44:10 pilhuhn Exp $ -->
    
    <!-- You need the jt400.jar that is delivered with IBM iSeries Access or the
         OpenSource Project jtopen.
    
         [systemname] Hostame of the iSeries
         [schema]     Default schema is needed so jboss could use metadat to test if the tables exists
      -->
    
    <datasources>
      <local-tx-datasource>
        <jndi-name>DB2-400</jndi-name>
        <connection-url>jdbc:as400://[systemname]/[schema];extended dynamic=true;package=jbpkg;package cache=true;package library=jboss;errors=full</connection-url>
        <driver-class>com.ibm.as400.access.AS400JDBCDriver</driver-class>
        <user-name>[username]</user-name>
        <password>[password]</password>
        <min-pool-size>0</min-pool-size>
            <!-- sql to call when connection is created
            <new-connection-sql>some arbitrary sql</new-connection-sql>
            -->
    
            <!-- sql to call on an existing pooled connection when it is obtained from pool 
            <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
            -->
          <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
          <metadata>
             <type-mapping>DB2/400</type-mapping>
          </metadata>
    
      </local-tx-datasource>
    
    </datasources>
    

     

    DB2 on AS/400 "native"

     

    The "Native" JDBC driver. This is shipped as part of the IBM Developer Kit for Java (57xxJV1). It is implemented by making native method calls to the SQL CLI (Call Level Interface). Consequently, it only runs on the i5/OS JVM. The class name to register is com.ibm.db2.jdbc.app.DB2Driver . The URL subprotocol is db2. See JDBC FAQKS (http://www-03.ibm.com/systems/i/software/toolbox/faqjdbc.html#faqA1).

     

     

    <?xml version="1.0" encoding="UTF-8"?> 
    <!-- ===================================================================== --> 
    <!--                                                                       --> 
    <!--  JBoss Server Configuration                                           --> 
    <!--                                                                       -->
    <!-- ===================================================================== --> 
    <!-- $Id: db2-400-ds.xml,v 1.1.4.2 2004/10/27 18:44:10 pilhuhn Exp $       --> 
    <!-- You need the jt400.jar that is delivered with IBM iSeries Access or the      
         OpenSource Project jtopen.      
              [systemname] Hostame of the iSeries      
              [schema]     Default schema is needed so jboss could use metadat to test if the tables exists  --> 
    <datasources>  
         <local-tx-datasource>    
              <jndi-name>DB2-400</jndi-name>    
                   <connection-url>jdbc:db2://[systemname]/[schema];extended dynamic=true;package=jbpkg;package cache=true;package library=jboss;errors=full</connection-url>    
                   <driver-class>com.ibm.db2.jdbc.app.DB2Driver</driver-class>    
                   <user-name>[username]</user-name>    
                   <password>[password]</password>    
                   <min-pool-size>0</min-pool-size>        
                   <!-- sql to call when connection is created
                        <new-connection-sql>some arbitrary sql</new-connection-sql>        -->        
    
                   <!-- sql to call on an existing pooled connection when it is obtained from pool        
                        <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>        -->      
                   <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->      
                   <metadata>          
                        <type-mapping>DB2/400</type-mapping>      
                   </metadata>  
         </local-tx-datasource> 
    </datasources>
    

     

    Tips:

    • This driver is sensitive to job’s CCSID, it works fine with CCSID=37.
    • [systemname] must be defined as entry “WRKRDBDIRE “  like *local.