8.2.2. Installing the JDBC Driver and Deploying the Datasource
To add MySQL database connection support to JBoss Enterprise Application Platform:
Procedure 8.1. Red Hat Enterprise Linux 6
- Run the following command to install the connector:
yum install mysql-connector-java
- Run the following command to link the new connector to the JBoss Enterprise Application Platform installation:
ln -s /usr/lib[64]/gcj/mysql-connector-java/mysql-connector-java<version>.jar.so jboss-as/server/common/lib/mysql-connector-java.jar
Procedure 8.2. Other Platforms
- Download the MySQL Connector/J JDBC Connector from http://www.mysql.com
- Deploy the connector:
To make the connector available to all server profiles;
Extract themysql-connector-java-<version>.jar
file to<JBOSS_HOME>/server/common/lib
.To make the connector available to selected profiles only;
Extract the file to thelib
directory in those server profile directories.
Then create a file in the deploy directory called
mysql-ds.xml
with the following datasource configuration. Note that the database user name and password corresponds to the MySQL user that we created in the previous section:
<?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>DefaultDS</jndi-name> <connection-url>jdbc:mysql://localhost:3306/jboss</connection-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>jboss</user-name> <password>password</password> <metadatda> <type-mapping>mySQL</type-mapping> </metadata> <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation> </local-tx-datasource> </datasources>
To ensure that you have correctly configured the datasource in
<JBOSS_HOME>/jboss-as/server/<PROFILE>/deploy
folder, start the server and you will notice messages like these in the logs:
INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=MySqlDS' to JNDI name 'java:MySqlDS'
Note
Configuring other datasources is a similar process.