After reading many posts, I finally configured the MYSQL5 data source in JBOSS4.22!
Step 1: Go to the next JDBC driver on the MySQL official website (Click here to download it ). Then copy the extracted file mysql-connector-java-5.0.7-bin.jar to % JBoss %/server/default/lib. It is better to add the path of the mysql-connector-java-5.0.7-bin.jar to CLASSPATH.
Step 2, copy % JBoss %/docs/examples/jca/mysql-ds.xml to the % JBoss %/server/default/deploy folder. Modify the following lines:
<Jndi-name> MySqlDS </jndi-name> <! -- Enter the JNDI name you want here -->
<Connection-url> jdbc: mysql: // localhost: 3306/mysql </connection-url> <! -- Here I use the mysql database for testing -->
<Driver-class> com. mysql. jdbc. Driver </driver-class> <! -- This does not need to be changed -->
<User-name> root </user-name> <! -- Enter the database username here -->
& Lt; password & gt; 1234 & lt;/password & gt; & lt! -- Enter the Database Password here -->
Step 3: Modify the standardjbosscmp-jdbc.xml file in % JBoss % \ server \ default \ conf. Unlike other online tutorials, you only need to modify <datasource> java:/MySqlDS </datasource>. Note that here MySqlDS is the JNDI name configured in the mysql-ds.xml in step 2. The <datasource-mapping> parameter does not need to be changed.
Step 4: Modify the login-config.xml file in % JBoss % \ server \ default \ conf. Add the code before the last </policy> of the file:
<! -- MySQL Data-Source Settings -->
<Application-policy name = "MySqlDbRealm">
<Authentication>
<Login-module code =
"Org. jboss. resource. security. ConfiguredIdentityLoginModule"
Flag = "required">
<Module-option name = "principal"> MySqlDS </module-option>
<Module-option name = "userName"> root </module-option>
<Module-option name = "password"> 1234 </module-option>
<Module-option name = "managedConnectionFactoryName">
Jboss. jca: service = LocalTxCM, name = MySqlDS
</Module-option>
</Login-module>
</Authentication>
</Application-policy>