Skip to content

Instantly share code, notes, and snippets.

@roncat
Last active December 14, 2018 18:44
Show Gist options
  • Save roncat/8d33f07853d99532c57a to your computer and use it in GitHub Desktop.
Save roncat/8d33f07853d99532c57a to your computer and use it in GitHub Desktop.
Install MySQL on DataSource on JBoss EAP 6
Example to install MySQL driver on DataSource JBoss EAP 6
=========================================================
First we will create a new module. A module in this sense is a package of classes that will be available to all our application through your JBoss node. This is a big differences compared with older JBoss version where all deployed archive where directly available to other deployed application when deployed in the deployment root folder.
You find module in $JBOSS_HOME/modules folder. To create a new module you need to do three things:
1 - Create a folder hierarchy for files.
$ mkdir -p $JBOSS_HOME/modules/com/mysql/main
2 - Copy module jar files.
$ cp mysql-connector-java-5.x.jar $JBOSS_HOME/modules/com/mysql/mainmysql-connector-java-5.x.jar
3 - Create module configuration file (module.xml)
$ touch $JBOSS_HOME/modules/com/mysql/main/module.xml
4 - Now edit the module.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.x.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
5 - Now you are ready to use configure your DataSource. Here I will use the JBoss Standalone.
The configuration of the JBoss can be done in several way:
1. CLI 2. Web interface 3. or manually through editing xml file. Which way you choose is up to you, here I will show the result.
$JBOSS_HOME/standalone/configuration/standalone.xml:
<subsystem xmlns="urn:jboss:domain:datasources:1.1">
<datasources>
<datasource jndi-name="java:jboss/datasources/YourProjectDS" pool-name="YourProjectDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/YourProjectDB</connection-url>
<driver>com.mysql</driver>
<security>
<user-name>uid</user-name>
<password>pwd</password>
</security>
</datasource>
<drivers>
<driver name="com.mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment