Instead of configuring the multiple datasource configuration in seperate -ds.xml files we can configure it in a single datasource configuration file, it can simply be done by adding the additional datasource types in the exsiting -ds.xml file.
Check the sample simple configuration, this configuration will create the local-tx-datasource datasource for mysql+oracle DB
<?xml version="1.0" encoding="UTF-8"?> <datasources> <!-- Defining local-tx-datasource --> <local-tx-datasource> <jndi-name>common-mysqlds</jndi-name> <use-java-context>true</use-java-context> <connection-url>jdbc:mysql://localhost:3306/testDB</connection-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <prefill>true</prefill> <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name> <check-valid-connection-sql>SELECT @@VERSION</check-valid-connection-sql> <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name> <metadata> <type-mapping>mySQL</type-mapping> </metadata> </local-tx-datasource> <local-tx-datasource> <jndi-name>common-oracleds</jndi-name> <connection-url>jdbc:oracle:thin:@localhost:1521</connection-url> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class> <user-name>scott</user-name> <password>tiger</password> <prefill>true</prefill> <min-pool-size>5</min-pool-size> <max-pool-size>6</max-pool-size> </local-tx-datasource> </datasources>
Advantages of this pattern
- Single configuration file
Disadvantages of this pattern
- It could lead to http://www.jboss.org/community/wiki/ManagedConnectionisNull
Comments