I have been looking at several examples for configuring a datasource for MySQL in Jboss 7. All references i have seen for the element looks like this:
<driver name="com.mysql" module="com.mysql">
<driver-class>com.mysql.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
I know what the <driver-class>
is but what exactly is the <xa-datasource-class>
what is its purpose?
When i configured a datasource on Tomcat before i did not need to specify the xa-datasource for any database. Why is it different here?
Thanks
According to jdbc 4.0 specification (12.2): XA datasources produces XA connections capable to be used in global/distributed transactions. You might need such a connection if you need a transaction to span more than one database or a JMS calls. You can find a clear explanation of the concept here: http://www.theserverside.com/discussions/thread.tss?thread_id=21385#95346
If you don't have such a distributed transactions scenario you don't need to specify a xa-datasource, a simple datasource configuration is enough. So, if you use a simple datasource there is no need to specify a xa-datasource-class when you declare your driver.
<datasources>
<datasource jndi-name="java:/myDatasource" pool-name="MyDS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>
jdbc:mysql://localhost:3306/mydb
</connection-url>
<driver>
mysql
</driver>
<transaction-isolation>
TRANSACTION_READ_COMMITTED
</transaction-isolation>
<pool>
<min-pool-size>
5
</min-pool-size>
<max-pool-size>
10
</max-pool-size>
<prefill>
true
</prefill>
<use-strict-min>
false
</use-strict-min>
<flush-strategy>
FailingConnectionOnly
</flush-strategy>
</pool>
<security>
<user-name>
username
</user-name>
<password>
password
</password>
</security>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql"/>
</drivers>
</datasources>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With