Skip to content
Sandny Blog
  • Home
  • Java
  • JavaScript
  • AWS
  • Embedded
  • About
wildfly 10 xa datasource Server

How to create a XA datasource in Wildfly 10…

  • May 21, 2017August 29, 2018
  • by Coder Kai

I wanted to use mysql XA-Datasource to connect mysql datasources using the Wildfly 10 server. XA Datasources are better as it can span multiple resources.

Create the folder structure as /modules/system/layers/base/com/sql/mysql/main

Then create a file as module.xml in the main folder containing following data

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.sql.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.41-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.servlet.api" optional="true"/>
<module name="javax.validation.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.3" name="com.sql.mysql"> <resources> <resource-root path="mysql-connector-java-5.1.41-bin.jar"/> </resources> <dependencies> <module name="javax.api"/> <module name="javax.servlet.api" optional="true"/> <module name="javax.validation.api"/> <module name="javax.transaction.api"/> </dependencies> </module>
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.sql.mysql">
  <resources>
     <resource-root path="mysql-connector-java-5.1.41-bin.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
    <module name="javax.servlet.api" optional="true"/>
    <module name="javax.validation.api"/>
    <module name="javax.transaction.api"/>
  </dependencies>
</module>

 

Then copy the MySQL JDBC connector to the folder. The latest version that I had was mysql-connector-java-5.1.41-bin.jar. Change the name in module.xml accordingly.

Download: https://dev.mysql.com/downloads/connector/j/

(note: modify the xml resource-root according to the latest version of the connector jar )

Then go to the standalone/configuration folder and edit standalone.xml. Include following in the datasource part of the xml.

<datasources>
<xa-datasource jndi-name="java:jboss/datasources/madeinsl" pool-name="madeinsl" enabled="true" use-java-context="true">
<xa-datasource-property name="ServerName">
localhost
</xa-datasource-property>
<xa-datasource-property name="DatabaseName">
dbname
</xa-datasource-property>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>password</password>
</security>
<statement>
<prepared-statement-cache-size>100</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</xa-datasource>
<drivers>
<driver name="mysql" module="com.sql.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
<datasources> <xa-datasource jndi-name="java:jboss/datasources/madeinsl" pool-name="madeinsl" enabled="true" use-java-context="true"> <xa-datasource-property name="ServerName"> localhost </xa-datasource-property> <xa-datasource-property name="DatabaseName"> dbname </xa-datasource-property> <driver>mysql</driver> <security> <user-name>root</user-name> <password>password</password> </security> <statement> <prepared-statement-cache-size>100</prepared-statement-cache-size> <share-prepared-statements>true</share-prepared-statements> </statement> </xa-datasource> <drivers> <driver name="mysql" module="com.sql.mysql"> <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class> </driver> </drivers> </datasources>
<datasources>
               <xa-datasource jndi-name="java:jboss/datasources/madeinsl" pool-name="madeinsl" enabled="true" use-java-context="true">
                   <xa-datasource-property name="ServerName">
                       localhost
                   </xa-datasource-property>
                   <xa-datasource-property name="DatabaseName">
                       dbname
                   </xa-datasource-property>
                   <driver>mysql</driver>
                   <security>
                       <user-name>root</user-name>
                       <password>password</password>
                   </security>
                   <statement>
                       <prepared-statement-cache-size>100</prepared-statement-cache-size>
                       <share-prepared-statements>true</share-prepared-statements>
                   </statement>
               </xa-datasource>
               <drivers>
                   <driver name="mysql" module="com.sql.mysql">
                       <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                   </driver>
               </drivers>
           </datasources>

 

Then test connection after login to the admin console. Then create a Datasource using the MySQL xa driver or use the Datasource properties that I have included in the xml.

Installing Nios II Eclipse on Ubuntu
Use JBLAS library in spark-shell
Coder Kai
A humble developer
JDBC MySQL Wildfly 10 XA-Datasourse

Related articles

AWS Ingress ALB with EKS
How to use AWS Ingress…
modular approach to create API
A Modular Approach to create…
nodemon to build api
babel + express.js + node.js…
create a Vertx Eventbus js client
How to create a Vertx…
neo4j boltdriver
How to create a neo4j…

Categories

  • android 3
  • Apollo Client 1
  • AWS 8
    • AppSync 5
    • EC2 1
    • EKS 1
    • Route53 1
    • S3 1
  • AWS Amplify 1
  • Chakra UI 1
  • Docker 1
  • Embedded 1
  • EmberJS 1
  • FCM 1
  • Godaddy 1
  • GraphQL 3
  • ios 1
  • Jasper 1
  • Java 10
    • Java 11 1
    • Java 14 1
  • JavaEE 2
  • JavaScript 39
    • Express.js 4
    • Javascript Guide 7
    • Node.js 3
    • react-native 4
    • React.js 17
    • Typescript 1
  • Kubernetes 1
  • machine learning 1
  • Maven 2
  • OCaml 3
  • PostgreSQL 1
  • Python 2
  • react-native 4
  • ReactJS 3
  • sass 1
  • Server 6
  • spark 1
  • Terraform 2
  • Ubuntu 4
  • Uncategorized 1
  • webpack 2

Recent Comments

  • binance create account on Jasper Subreporting for a CV generator
  • Telsiz su kaçak tespiti on How to create Lambda function with Terraform
  • anak sial on How to create Lambda function with Terraform

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Archives

  • October 2022 3
  • September 2022 7
  • May 2022 1
  • December 2021 1
  • August 2021 1
  • July 2021 6
  • June 2021 3
  • February 2021 1
  • July 2020 1
  • December 2019 5
  • November 2019 6
  • October 2019 3
  • August 2019 1
  • March 2019 1
  • February 2019 1
  • January 2019 2
  • December 2018 1
  • September 2018 2
  • August 2018 1
  • June 2018 1
  • February 2018 1
  • November 2017 2
  • October 2017 5
  • September 2017 1
  • June 2017 1
  • May 2017 10
Sandny Blog space
Theme by Colorlib Powered by WordPress