Configuring JBoss to use MySQL


For JBoss 3.0.8 see JbossMySql


I'm not sure which items are case-significant. Play safe and assume they all are!

  • Download the MySql jdbc drivers from http://www.mysql.com/downloads/api-jdbc.html

  • Extract mysql-connector-java-3.0.11-stable-bin.jar from the download and copy it to jboss-3.2.6/server/xxx/lib

  • copy jboss/docs/examples/jca/mysql-ds.xml to jboss-3.2.6/server/xxx/deploy directory

  • edit jboss-3.2.6/server/xxx/deploy/mysql-service.xml

And amend the connection-url property from to something like 'jdbc:mysql://localhost:3306/mydbname'.

Note: MySql uses lowercase for table names. This causes problems with JBoss if you used any upper-case characters when defining the table name. Most things work fine, but creating and deleting tables fails. Best use all lower-case characters for table names.


I use XDoclet to create my deployment descriptors (and more!) and updated the <jboss> subtask of my ant <ejbdoclet> task in build.xml to include them, e.g.

            <jboss version="${jboss.version}"
                xmlencoding="UTF-8"
                typemapping="mySQL"
                datasource="java:/MySqlDS"
                destdir="${build.dir}/META-INF"
                validateXml="false"
            />

Note: These instructions will leave JBoss using Hypersonic for the jbossmq persistence manager. Options to consider persuing are:

  • Change the "jdbc2" mq persistence manager to use the mysql datasource
  • Change jbossmq to use a non-jdbc persistence manager
  • Rename or copy the MySQL datasource to DefaultDS

See also JbossMySql, MySql, JbossHintsAndTips, JbossPostgreSql

-- Frank Dean - 21 Mar 2005