Configuration IBM DB2 & Oracle Data Source to JBOSS
7.1.1
Step 1:
Open Standalone.xml file
add following code into subsystem of data source and edit following code as per
your database url and username and password for data sources.
Standalone.xml
<subsystem
xmlns="urn:jboss:domain:datasources:1.0">
<datasources>
<datasource
jndi-name="java:jboss/jdbc/ OracleDatasourceName "
pool-name="OracleDatasourceName"
enabled="true" use-java-context="true">
<connection-url>jdbc:oracle:thin:@url </connection-url>
<driver>oracle</driver>
<security>
<user-name>userName</user-name>
<password>password</password>
</security>
<validation>
<valid-connection-checker class-
name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
<stale-connection-checker class-
name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/>
<exception-sorter class-
name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
</validation>
</datasource>
<datasource
jndi-name="java:jboss/jdbc/dataSourceName"
pool-name="DataSourceName"
enabled="true" use-java-context="true">
<connection-url>jdbc:db2://url</connection-url>
<driver>db2</driver>
<security>
<user-name>UserName</user-name>
<password>Password</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2ValidConnectionChecker"/>
<stale-connection-checker
class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2StaleConnectionChecker"/>
<exception-sorter
class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2ExceptionSorter"/>
</validation>
</datasource>
<drivers>
<driver
name="oracle" module="com.oracle.ojdbc6">
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
<driver
name="db2" module="com.ibm.db2">
<xa-datasource-class>com.ibm.db2.jcc.DB2XADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem
-------------------------------------------------------------------------------------------------------------------
Step 2:
Go to JBOSS Installation directory
Like c:\ jboss-as-7.1.1.Final\modules\
Inside Modules create folder structure as below
For Oracle: \com\oracle\ojdbc6\main
Create Module.xml as below example
<?xml
version="1.0" encoding="UTF-8"?>
<module
xmlns="urn:jboss:module:1.1" name="com.oracle.ojdbc6">
<resources>
<resource-root
path="ojdbc6.jar"/>
<resource-root
path="orai18n.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module
name="javax.api"/>
<module
name="javax.transaction.api"/>
</dependencies>
</module>
After that place ojdbc6.jar and orai18n.jar inside main
folder
Step 3:
Inside modules folder create IBM DB2 folder structure as
below
We Can use db2jcc,jar or db2jcc4.jar as per our requirement
For Oracle: \ com\ibm\db2\main
Create Module.xml inside main as
--------------------------------------------------------------------------
<?xml
version="1.0" encoding="UTF-8"?>
<module
xmlns="urn:jboss:module:1.1" name="com.ibm.db2">
<resources>
<resource-root
path="db2jcc4.jar"/>
<resource-root
path="db2jcc_license_cu.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module
name="javax.api"/>
<module
name="javax.transaction.api"/>
</dependencies>
</module>
--------------------------------------------------------------
Inside main directory add db2jcc4.jar and db2jcc_license_cu.jar
Configuration Completed ....