Skip to content

MySQL Database Configuration

Jeff Yu edited this page May 2, 2013 · 1 revision

This page illustrates the steps if you want to switch the database to MySQL. (It is using the h2 in-memory database by default)

Adding the mysql driver module

  • Creating the mysql/main folder in the $JBossAS/moudles/.

  • Putting the mysql driver jar in the $JBossAS/modules/mysql/main, like mysql-connector-java-5.1.12.jar.

  • Creating a module.xml along with it, the content is as following:

<module xmlns="urn:jboss:module:1.1" name="mysql">
   <resources>
     <resource-root path="mysql-connector-java-5.1.12.jar"/>
   </resources>
   <dependencies>
     <module name="javax.api"/>
     <module name="javax.transaction.api"/>
   </dependencies>
</module>

Adding the mysql driver in standalone-full.xml file

<subsystem xmlns="urn:jboss:domain:datasources:1.0">
        <datasources>
            .....
            <drivers>
                ...
                <driver name="mysql" module="mysql">
                    <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                </driver>
            </drivers>
        </datasources>
    </subsystem>

Creating the rtgov mysql datasource file, rtgov-mysql-ds.xml

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
	<datasource jndi-name="java:jboss/GadgetServer" pool-name="GadgetServer" enabled="true" use-java-context="true">
                <connection-url>jdbc:mysql://localhost:3306/gs</connection-url>
		<driver>mysql</driver>
		<security>
			<user-name>root</user-name>
			<password></password>
		</security>
	</datasource>
</datasources>