MySQL 的 Jboss 数据源配置 - MysqlXADataSource 元素
我一直在研究在 Jboss 7 中为 MySQL 配置数据源的几个示例。我看到的该元素的所有引用如下所示:
<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>
我知道
它的用途是什么?
当我之前在Tomcat上配置数据源时,我不需要为任何数据库指定xa-datasource。为什么这里不一样?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 jdbc 4.0 规范 (12.2):XA 数据源生成能够在全局/分布式事务中使用的 XA 连接。如果您需要一项事务跨越多个数据库或一次 JMS 调用,您可能需要这样一种连接。您可以在这里找到该概念的清晰解释:http://www. theserverside.com/discussions/thread.tss?thread_id=21385#95346
如果你没有这样的分布式事务场景则不需要指定xa-datasource,简单的数据源配置就足够了。因此,如果您使用简单的数据源,则在声明驱动程序时无需指定 xa-datasource-class。
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.