Adding a Mysql datasource to JBoss AS 7

I haven’t used JBoss since 4.x days. Seems adding a datasource is a few steps more complicated than it used to be. To summarize this post, the steps you need are:

  1. create a com/mysql/main dir under /
  2. drop your mysql connector in this dir
  3. create a module.xml file in the same dir with the following content:
  4. <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.0" name="com.mysql">
        <resource-root path="mysql-connector-java-5.1.18-bin.jar"/>
        <module name="javax.api"/>
  5. modify your jboss-install-dir/standalone/configuration/standalone.xml file and define your datasource by adding a section like this to the subsystem datasources section:
    <datasource jndi-name="java:jboss/datasources/MysqlDS" pool-name="MysqlDS" enabled="true" use-java-context="true">
                        <driver name="mysql" module="com.mysql">

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.