MySQL的Jboss数据源配置-MysqlXADataSource元素 [英] Jboss Datasource configuration for MySQL - MysqlXADataSource element
问题描述
我一直在研究几个在Jboss 7中为MySQL配置数据源的示例.我为该元素看到的所有参考看起来都像这样:
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>
我知道<driver-class>
是什么,但是<xa-datasource-class>
的确切含义是什么?
I know what the <driver-class>
is but what exactly is the <xa-datasource-class>
what is its purpose?
当我在Tomcat上配置数据源之前,不需要为任何数据库指定xa数据源.为什么这里不一样?
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?
谢谢
推荐答案
根据jdbc 4.0规范(12.2):XA数据源产生了能够在全局/分布式事务中使用的XA连接.如果您需要一个事务来跨越多个数据库或一个JMS调用,则可能需要这样的连接.您可以在此处找到有关此概念的清晰说明: http://www. theserverside.com/discussions/thread.tss?thread_id=21385#95346
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
如果您没有这种分布式事务方案,则无需指定xa数据源,简单的数据源配置就足够了.因此,如果您使用简单的数据源,则在声明驱动程序时无需指定xa-datasource-class.
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>
这篇关于MySQL的Jboss数据源配置-MysqlXADataSource元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!