Uncategorized

Datasource Configuration In Jboss 7

Follow the below steps to add datasource in jboss 7

1. edit standalone.xml to add datasource in subsystem

Note: standalone.xml location jboss-as-7.1.1.Final/standalone/configuration

 <datasource jndi-name="java:/jdbc/mydatasource" pool-name="mydatasource" enabled="true" use-java-context="true">
                    <connection-url>jdbc:mysql://localhost:3306/mydb</connection-url>
                    <driver>mysql</driver>
                    <security>
                        <user-name>root</user-name>
                        <password></password>
                    </security>
                </datasource>

2. Add the MySql Driver in the same place

 <driver name="mysql" module="com.mysql.jdbc">
                        <driver-class>com.mysql.jdbc.Driver</driver-class>
                    </driver>

3. Create following folder structure in jboss module directory.

jboss-as-7.1.1.Final/modules/com/mysql/jdbc/main

4. create module.xml file with following entry

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql.jdbc">
    <resources>
        <resource-root path="mysql-connector-java-5.1.21.jar"/>
        <!-- Insert resources here -->
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>

5. add mysql connector jars. finally main folder should contain below files

module.xml
mysql-connector-java-5.1.21.jar.index
mysql-connector-java-5.1.21.jar

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s