The default database for the JBOSS-3.2.3 uses hypersonic. For engineering use, we need to switch the database to a database with high performance such as MySQL and Oracle. What files need to be modified?
The following uses the MySQL database as an example to switch the default JBoss database to MySQL.
1. Slave.
2. You must delete the hsqldb-ds.xml under $ jboss_disc/Server/default/deploy, add a mysql-ds.xml file, and include the following content:
<? XML version = "1.0" encoding = "UTF-8"?>
<Datasources>
<Local-TX-datasource>
<JNDI-Name> defaultds </JNDI-Name>
<Connection-URL> JDBC: mysql: /localhost: 3306/test </connection-URL>
<Driver-class> com. MySQL. JDBC. Driver </driver-class>
<User-Name> test </user-Name>
<Password> test </password>
</Local-TX-datasource>
</Datasources>
The database name, user name, and password here are all replaced by test. You need to change it to the actual name.
In fact, the hsqldb-ds.xml here is not necessarily to delete, as long as the default name in the JNDI name defaultds does not conflict on the line.
3. Use $ jboss_disc/Server/default/deploy/JMS
Mysql-jdbc2-service.xml to replace the hsql-jdbc2-service.xml. Put
Modify defads ds to mysqlds. This file is responsible for persistent storage of message quene.
4. If you want to use the CMP feature, you have two ways to modify it: add the jbosscmp-jdbc.xml
In or modifying the EJB deployment unit
$ Jboss_disc/Server/default/CONF/standardjbosscmp-jdbc.xml, editing
Edit the element datasource-mapping to MySQL, as shown below:
<Jbosscmo-jdbc>
<Defaults>
<Datasource> JAVA:/defaultds </datasource>
<Datasource-mapping> mysql </datasource-mapping>
The second method is relatively simple, because you do not need to repackage the application. The disadvantage is that you must restart JBoss.
Now, restart JBoss to work in the MySQL database.