1. Add User to WildFly for JDBC Datasource configuration

  1. go to {wildfly-8.2.0}\bin
  2. run add-users.bat
  3. follow the instructions for cuser creating

2. Add MySQL Driver to WildFly

  1. Download the mysql-driver mysql-connector-java-{last_version}.jar from any Maven Repository e.g.: http://repo1.maven.org/maven2/mysql/mysql-connector-java/
  2. go to WildFly modules Directory:
    cd {wildfly-8.2.0}/modules/system/layers/base
    mkdir -p mysql/mysql-connector-java/main

    copy  mysql-driver mysql-connector-java-{last_version}.jar here.

  3. add a file module.xml with content:

    <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.1" 
            name="mysql.mysql-connector-java">
        <resources>
            <resource-root path="mysql-connector-java-5.1.22.jar"/>
            <!-- Insert resources here -->
        </resources>
        <dependencies>
            <module name="javax.api"/>
            <module name="javax.transaction.api"/>
            <module name="javax.servlet.api" optional="true"/>
        </dependencies>
    </module>
  4. Add Driver in standalone.xml

    cd {wildfly-8.2.0}/standalone/configuration/
    edit standalone.xml

    add to drivers:

    <driver name="com.mysql" module="mysql.mysql-connector-java">
      <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
     </driver>
  </drivers>

3. Add Datasource to WildFly

  1. open http://localhost:9990/console/App.htm
  2. go to Connector->Datasources
  3. add new Datasource
  4. Give the name and JNDI name.
  5. choose your created driver
  6. enter your connection URL like: jdbc:mysql://localhost/mydatabase and database cridentials
  7. test your connection