JBoss Community

Data Source Configuration in AS 7

new comment by Karsten Wutzke View all comments on this document

In any case, whatever I tried, I only got the MySQL driver to work as a module. Here's my final <datasources> element from standalone.xml using the MySQL driver installed as a module:


<datasources>

    ...

    <datasource jndi-name="java:jboss/datasources/YourDS" pool-name="MySqlDS" enabled="true" jta="true" use-java-context="true" use-ccm="true">

        <connection-url>

            jdbc:mysql://localhost:3306/yourdb

        </connection-url>

        <driver>

            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>

            <use-strict-min>

                false

            </use-strict-min>

            <flush-strategy>

                FailingConnectionOnly

            </flush-strategy>

        </pool>

        <security>

            <user-name>

                user

            </user-name>

            <password>

                pass

            </password>

        </security>

        <statement>

            <prepared-statement-cache-size>

                32

            </prepared-statement-cache-size>

        </statement>

    </datasource>

    <drivers>

        ...

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

            <xa-datasource-class>

                com.mysql.jdbc.jdbc2.optional.MysqlXADataSource

            </xa-datasource-class>

        </driver>

    </drivers>

</datasources>

Note that the way you install the driver (deployment vs. module) is independent from the server operating mode (standalone vs. domain), even though you drop the driver JAR into the standalone/deployments directory, see https://docs.jboss.org/author/display/AS7/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7. So you effectively get a matrix of four driver installation - operating mode possibilities, aside from the JDBC 4 compliance (which simply defines whether you need to specify the driver name somewhere) and the choice of XA or plain datasource (adjust tag and class names as appropriate). Note, for whatever reason, there's no such thing as a <datasource-class> tag, hence the use of <xa-datasource-class>.

 

I have also just gotten through all this and I definitely need to re-read documentation like https://docs.jboss.org/author/display/AS7/Operating+modes myself. Hopefully this will help someone else.