Monday, December 7, 2020

How to create DataSource in JBOSS

 Follow below steps for creating Data Source in JBOSS which will help for Application to connect DB using it .

STEP 1:
For MySQL
create directory structrue in /jboss/AppServer/jboss-eap-6.4/modules/
com/mysql .with in this create module.xml file with below content and copy driver jar file into this location
module.xml
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.0.8-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>

For MariaDB
copy jar to JBOSS_HOME/modules/org/mariadb/main/
copy jar to JBOSS_HOME/modules/org/mariadb/
create module.xml with the below . Maria DB jar and will beloaded during jboss startup and the class from the jar refered in DataSource for connecting to DB
<module xmlns="urn:jboss:module:1.1" name="org.mariadb">
<resources>
<resource-root path="mariadb-java-client-1.3.3.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
STEP 2:Install Driver

Add driver with in <drivers> tag on domain.xml under full-ha profile .This diver will be visible when we create datasouce from JBOSS console .
For mysql
<driver name="mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
For db2
<driver name="mariadb" module="com.mariadb">
<xa-datasource-class>org.mariadb.jdbc.MariaDbDataSource</xa-datasource-class>
<drivers>
<driver name="db2" module="com.ibm.db2">
<driver-class>com.ibm.db2.jcc.DB2Driver</driver-class>
</driver>
For MariaDB
<driver name="mariadb" module="com.mariadb">
<xa-datasource-class>org.mariadb.jdbc.MariaDbDataSource</xa-datasource-class>
STEP 3:Creation DATA SOURCE

Login to JBOSS consile using jbadmin
Go to Configuration tab --> Select full-ha profile in dropdown box -->click on ADD Enter Name :MySqlDS JNDI Name:java:/jdbc/MySqlDS
-->click on next select the previously added driver and click on next
-->Provide Conection url UserName & Password then SAVE and do test connection .


No comments:

Post a Comment

Featured

Weblogic Domain Migration

 In this blog we will see domain re-configuration which will be done as part of Weblogic migration from lower version to higher version [ Ex...