JBOSS Topic - Understanding datasource subsystem
1) types of data source xa & non-xa
2) in our environment we are using both xa & non-xa
How to create a datasource:
Three ways
1) Admin console
2) Using CLI
3) Direct edit of standalone.xml in case of standalone mode
domain.xml/host.xml in case of domain mode
==> Using Admin console
Just show how we can do it.
==> Using CLI(command line interface) mode:
First need to add the module
module add --name=com.oracle.jdbc --resources=/path/to/ojdbc6.jar --dependencies=javax.api,javax.transaction.api
Second define the driver as below
/subsystem=datasources/jdbc-driver=oracle:add(driver-module-name=com.oracle.jdbc,driver-name=oracle,driver-xa-datasource-class-name=oracle.jdbc.xa.client.OracleXADataSource)
Third create a datasource
/subsystem=datasources/data-source=OracleDS:add(jndi-name="java:jboss/datasources/oracleDS",connection-url="jdbc:oracle:thin:@oraclehost:1521:SID",driver-name=oracle,user-name=scott,password=tiger)
Fourth enable the datasource
/subsystem=datasources/data-source=OracleDS:enable(persistent=true)
Fifth To check if your datasource is working correctly, use one of these:
/subsystem=datasources/data-source=OracleDS:test-connection-in-pool
==> Using Direct edit of standalone.xml file
INSTALLING ORACLE JDBC-DRIVER ON WILDFLY / JBOSS
Download the driver: ojdbc[VERSION].jar
Create subfolders [EAP_HOME]/modules/system/layers/base/com/oracle/main/
Copy the downloaded ojdbc[VERSION].jar into the freshly created folder
Create a file module.xml, in the same folder as above, with the contents:
<module xmlns="urn:jboss:module:1.1" name="com.oracle">
<resources>
<resource-root path="ojdbc[VERSION].jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
In the configuration file standalone.xml add the entry:
<driver name="oracle" module="com.oracle">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
</driver>
within the <drivers> tag.
Add a datasource definition within the <datasources> tag (next to ExampleDS):
<datasource jndi-name="java:/[NAME]" pool-name="OracleDS" enabled="true">
<connection-url>jdbc:oracle:thin:@[HOST_NAME]:1521:[SID]</connection-url>
<driver>oracle[has to match the driver name]</driver>
<pool>
<min-pool-size>1</min-pool-size>
<max-pool-size>5</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>[USER]</user-name>
<password>[PWD]</password>
</security>
</datasource>
No comments:
Post a Comment