Tuesday, 29 March 2016

JBoss Connection Pooling


Deploying Driver Jars:

  1. Deploy driver jar file as an application. There is a structure for this jar file that needs to be followed.It needs to follow J2EE structure. Check this jar how it's structured inside.       mysql-connector-java-5.1.7-bin.jar
  2. Deploy jar file as a global module.

For testing JBoss Jdbc connection purpose I've used here MySQL DB with Navicat 8 Light for MySQL.

Data Sources are installed as subsystems in JBoss.

server -> server group -> profile -> (default,ha,full and full-ha)

subsystems - default,ha,full and full-ha

You must create data source for subsystem on which your JBoss got configured.


DATASOURCES - ONE PHASE TRANSACTIONS
XA DATASOURCES - TWO PHASE TRASACTIONS /GLOBAL TRASACTIONS

JTA API -USED FOR TWO PHASE TRASACTIONS 

copy the follwing FILE TO 

Documents\vamsi\EAP-6.4.0\modules\system\layers\base\com\h2database\h2\main\module.xml
TO 
\Documents\vamsi\EAP-6.4.0\modules\system\layers\base\com\mysql\datasource\main\module.xmL

and 
mysql-connector.jar (mysql-connector-java-5.1.7-bin.jar , renamed) to 
\DOCUMENTS\VAMSI\EAP-6.4.0\MODULES\SYSTEM\LAYERS\BASE\COM\MYSQL\DATASOURCE\MAIN\MODULE.XML

Change the HIGHLIGHTED entries.

<module xmlns="urn:jboss:module:1.1" name="com.mysql.datasource">

    <properties>
        <property name="jboss.api" value="unsupported"/>
    </properties>

    <resources>
        <resource-root path="mysql-connector.jar"/>
        <!-- Insert resources here -->
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
        <module name="javax.servlet.api" optional="true"/>
    </dependencies>

</module>


Change the fillowing tag in Documents\vamsi\DC_replica\dc\configuration\domain.xml

<subsystem xmlns="urn:jboss:domain:datasources:1.2">
                <datasources>
                    <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
                        <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
                        <driver>h2</driver>
                        <security>
                            <user-name>sa</user-name>
                            <password>sa</password>
                        </security>
                    </datasource>
                    <drivers>
                        <driver name="h2" module="com.h2database.h2">
                            <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                        </driver>
                        <driver name="mysql" module="com.mysql.datasource"/>
                         
                        
                    </drivers>
                </datasources>

            </subsystem>



JNDI NAME : jbtravel

JNDI : java:jboss/jbtravel


Connection URL: jdbc:mysql://localhost/jbtraveljdbc:mysql://localhost/jbtravel
USER NAME : root

Password : 1234









No comments:

Post a Comment