7.2.3. Testing the MySQL DataSource

7.2.3. Testing the MySQL DataSource

We’ll use the CMP roster application to test the new database connection. In order to use MySql in our application, we'll need to set the datasource name a nd type-mapping in the jbosscmp-jdbc.xml file in the dd/team directory of the CMP roster application. Edit the file and add the following datasource and datasource-mapping elements to the defaults element.

<jbosscmp-jdbc>
    <defaults>
        <datasource>java:/MySqlDS</datasource>
        <datasource-mapping>mySQL</datasource-mapping>
    </defaults>

    <enterprise-beans>
...
    </enterprise-beans>
</jbosscmp-jdbc>

After restarting JBoss, you should be able to deploy the application and see the tables being created. . The tables should be visible from the MySQL client.

mysql> show tables; 
+-----------------------------------+
| Tables_in_jboss                   |
+-----------------------------------+
| LeagueBean                        |
| PlayerBean                        |
| PlayerBean_teams_TeamBean_players |
| TeamBean                          |
+-----------------------------------+
4 rows in set (0.00 sec) 

You can see the JMS persistence tables in there too since we’re using MySQL as the default datasource.