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

  1. Run the following command to install the connector:
    yum install mysql-connector-java
    Copy to Clipboard Toggle word wrap
  2. 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
    Copy to Clipboard Toggle word wrap

Procedure 8.2. Other Platforms

  1. Download the MySQL Connector/J JDBC Connector from http://www.mysql.com
  2. Deploy the connector:
    1. To make the connector available to all server profiles;

      Extract the mysql-connector-java-<version>.jar file to <JBOSS_HOME>/server/common/lib.
    2. To make the connector available to selected profiles only;

      Extract the file to the lib 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>
Copy to Clipboard Toggle word wrap
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'
Copy to Clipboard Toggle word wrap

Note

Configuring other datasources is a similar process.
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat