A.2. DB2
例A.1 DB2 Local-XA
$db2_install_dir/java/db2jcc.jar
and $db2_install_dir/java/db2jcc_license_cu.jar
ファイルを $jboss_install_dir/server/default/lib
ディレクトリにコピーします。DB2 バージョン 8.1 以降に含まれている DB2 Universal JDBC ドライバーを使うと、レガシーの CLI ドライバーの一部である db2java.zip
ファイルは、通常必要ありません。
<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>
<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>
例A.2 DB2 XA
$db2_install_dir/java/db2jcc.jar
と $db2_install_dir/java/db2jcc_license_cu.jar
ファイルを$jboss_install_dir/server/default/lib
ディレクトリにコピーします。
DB2 v8.1 修正パック 14 (および該当のDB2 v8.2 修正パック 7) で XA 向け DB2 Universal JDBC ドライバー (type 4) を使う場合、
db2java.zip
ファイルが必要になります。
<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>
<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>
例A.3 AS/400 上の DB2
<?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>
<?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>
例A.4 AS/400 「ネーティブ」での DB2
ネーティブ のJDBCドライバは、IBM Developer Kit for Java (57xxJV1) の一部として同梱されています。これは、SQL CLI (Call Level Interface) にネーティブのメソッド呼出しを行うことで実装されており、i5/OS JVM でのみ稼働します。登録クラス名は、
com.ibm.db2.jdbc.app.DB2Driver
となっており、URL サブプロトコルは db2
です。詳細情報については、http://www-03.ibm.com/systems/i/software/toolbox/faqjdbc.html#faqA1 のJDBC FAQKS を参照してください。
<?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>
<?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>
ヒント
- このドライバーは、ジョブの CCSID を区別しますが、
CCSID
=37
で問題なく機能します。 [systemname]
は、WRKRDBDIRE
のエントリを*local
のように定義する必要があります。