JBoss Community

Data Source Configuration in AS 7

new comment by jarkko rantavuori View all comments on this document

Note that the steps in the article only allow creation of non-xa datasources with mysql.

 

If you need xa-datasources, you need to have something like this in your module.xml (note the dependency to transaction api):

 

<module xmlns="urn:jboss:module:1.0" name="com.mysql">

  <resources>

    <resource-root path="mysql-connector-java-5.1.22-bin.jar"/>

  </resources>

  <dependencies>

    <module name="javax.api"/>

    <module name="javax.transaction.api" />

  </dependencies>

</module>

 

As explained in this irc log: http://echelog.com/logs/browse/jboss-as7/1327618800

 

Note also that at the time of this writing (14.12.2012) current mysql connector (5.1.22) already contains the file mentioned for type 4 drivers, java.sql.Driver.

 

Here's a working configuration that defines a non-xa and an xa datasource for mysql:

 

<datasource jndi-name="java:jboss/datasources/MySqlDS" pool-name="MySqlDS" enabled="true">

    <connection-url>jdbc:mysql://localhost:3306/test</connection-url>

    <driver>com.mysql</driver>

    <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>

    <pool>

        <min-pool-size>10</min-pool-size>

        <max-pool-size>100</max-pool-size>

        <prefill>true</prefill>

    </pool>

    <security>

        <user-name>root</user-name>

        <password>mysqlpass</password>

    </security>

    <statement>

        <prepared-statement-cache-size>32</prepared-statement-cache-size>

        <share-prepared-statements>true</share-prepared-statements>

    </statement>

</datasource>

<xa-datasource jndi-name="java:jboss/datasources/MySqlXADS" pool-name="MySqlXADS" enabled="true" use-ccm="false">

    <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>

        <xa-datasource-property name="ServerName">

            localhost

        </xa-datasource-property>

        <xa-datasource-property name="DatabaseName">

            test

        </xa-datasource-property>

        <xa-datasource-property name="User">

            root

        </xa-datasource-property>

        <xa-datasource-property name="Password">

            mysqlpass

        </xa-datasource-property>

    <driver>com.mysql</driver>

    <xa-pool>

        <is-same-rm-override>false</is-same-rm-override>

        <interleaving>false</interleaving>

        <pad-xid>false</pad-xid>

        <wrap-xa-resource>false</wrap-xa-resource>

    </xa-pool>

    <security>

        <user-name>root</user-name>

        <password>mysqlpass</password>

    </security>

    <validation>

        <validate-on-match>false</validate-on-match>

        <background-validation>false</background-validation>

    </validation>

    <statement>

        <share-prepared-statements>false</share-prepared-statements>

    </statement>

</xa-datasource>

<drivers>

    <driver name="com.mysql" module="com.mysql">

        <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>

    </driver>

</drivers>