Este contenido no está disponible en el idioma seleccionado.

B.2. DB2


Example B.1. DB2 Local-XA

Copy the $db2_install_dir/java/db2jcc.jar and $db2_install_dir/java/db2jcc_license_cu.jar files into the $jboss_install_dir/server/default/lib directory. The db2java.zip file, which is part of the legacy CLI driver, is normally not required when using the DB2 Universal JDBC driver included in DB2 v8.1 and later.
<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>
Copy to Clipboard Toggle word wrap

Example B.2. DB2 XA

Copy the $db2_install_dir/java/db2jcc.jar and $db2_install_dir/java/db2jcc_license_cu.jar files into the $jboss_install_dir/server/default/lib directory.
The db2java.zip file 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 does not 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>
Copy to Clipboard Toggle word wrap

Example B.3. 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>
Copy to Clipboard Toggle word wrap

Example B.4. DB2 on AS/400 "native"

The Native JDBC driver 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), and 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. Refer to the JDBC FAQs at http://www-03.ibm.com/systems/i/software/toolbox/faqjdbc.html#faqA1 for more information.
<?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>
Copy to Clipboard Toggle word wrap

Tips

  • This driver is sensitive to the job’s CCSID, but works fine with CCSID=37.
  • [systemname] must be defined as entry WRKRDBDIRE like *local.
Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat