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:
- create a com/mysql/main dir under /jobss-as-7.1.final-install-dir/modules
- drop your mysql connector in this dir
- create a module.xml file in the same dir with the following content:
-
<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.0" name="com.mysql"> <resources> <resource-root path="mysql-connector-java-5.1.18-bin.jar"/> </resources> <dependencies> <module name="javax.api"/> </dependencies> </module>
- 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"> <connection-url>jdbc:mysql://localhost:3306/your_db_name</connection-url> <driver>mysql</driver> <security> <user-name>your_userid</user-name> <password>your_password</password> </security> </datasource> <drivers> <driver name="mysql" module="com.mysql"> <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class> </driver> </drivers>