Saturday 6 February 2016

How to make datasource connection in JBOSS server

For data-source set-up on JBoss AS
1)  Make changes  in standalone.xml or standalone-full.xml  whichever you use
2)  Under <datasources> element add the below one
<xa-datasource jndi-name="java:jboss/datasources/appDS" pool-name="appDS" enabled="true" use-ccm="false">
                    <xa-datasource-property name="URL">
                        jdbc:oracle:thin:@//<ip address>:<port no>/<database environment>
                    </xa-datasource-property>
                    <driver>oracle</driver>
                    <xa-pool>
                        <is-same-rm-override>false</is-same-rm-override>
                        <interleaving>false</interleaving>
                        <pad-xid>false</pad-xid>
                        <wrap-xa-resource>false</wrap-xa-resource>
                    </xa-pool>
                    <security>
                        <user-name></user-name>
                        <password></password>
                    </security>
                    <validation>
                        <validate-on-match>false</validate-on-match>
                        <background-validation>false</background-validation>
                    </validation>
                    <statement>
                        <share-prepared-statements>false</share-prepared-statements>
                    </statement>
                </xa-datasource>

3) Provide the driver depending upon the database that you use say for Oracle add the below elements under <drivers> element ,

<driver name="oracle" module="com.oracle.db">
                        <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
                    </driver>

Note : Important is that driver refers module: com.oracle.db.So please create folders in such a way as follows for Oracle

<JBOSS_HOME>\modules\system\layers\base\com\oracle\db\main\

4) Usually for Oracle there will be three files required such as Module.xml,ojdbc6.jar &  ojdbc6.jar.index
5) Module.xml will have the following entries
<?xml version="1.0" encoding="UTF-8"?>

<module xmlns="urn:jboss:module:1.1" name="com.oracle.db">

    <resources>
        <resource-root path="ojdbc6.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>

No comments:

Post a Comment