이 콘텐츠는 선택한 언어로 제공되지 않습니다.

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.
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat