cannot enlist more than one non-XA resource

2017-01-14 19:45:48来源:CSDN作者:kyq_1024yahoocn人点击


(1) 关闭事务,使用jdbc执行建表语句


(2)(3) 又使用了hibernate在不同sessionFacory之间切换执行sql。

错误代码:cannot enlist more than one non-XA resource, tried enlisting an XAResourceHolderState with uniqueName=dataSourceSCDP XAResource=a JDBC LrcXAResource in state NO_TX with XID null, already enlisted: an XAResourceHolderState with uniqueName=dataSource.1 XAResource=a JDBC LrcXAResource in state STARTED (started) with XID a Bitronix XID [3139322E3136382E35362E31000000000A6647B900000039 : 3139322E3136382E35362E31000000000A6647FE0000003A]


数据源的Driver使用 com.mysql.jdbc.jdbc2.optional.MysqlXADataSource.


<bean id="dataSource" class="" init-method="init"      destroy-method="close">    <property name="className" value="${jdbc.driver}"/>    <property name="uniqueName" value="dataSource"/>    <!--the minimal amount of connections that can be in the pool.-->    <property name="minPoolSize" value="${jdbc.minPoolSize}"/>    <!--the maximum amount of connections that can be in the pool.-->    <property name="maxPoolSize" value="${jdbc.maxPoolSize}"/>    <!--the amount of seconds and idle connection can stay in the pool before getting closed.-->    <property name="maxIdleTime" value="300"/>    <!--the amount of connections to be created at once when the pool needs to grow.-->    <property name="acquireIncrement" value="2"/>    <!--the amount of time between failed connection acquirements.-->    <property name="acquisitionInterval" value="1"/>    <!--the amount of time in seconds a call to get a connection from the pool will wait when the pool is empty.-->    <property name="acquisitionTimeout" value="2"/>    <!--false only if the database can run many transactions on the same connection.-->    <property name="deferConnectionRelease" value="true"/>    <!--true if the transaction manager should allow mixing XA and non-XA transactions.-->    <property name="allowLocalTransactions" value="true"/>    <property name="applyTransactionTimeout" value="true"/>    <!--Set whether connections in the ACCESSIBLE state can be shared within the context of a transaction.-->    <property name="shareTransactionConnections" value="true"/>    <property name="driverProperties">        <props>            <prop key="url">${jdbc.url}</prop>            <prop key="user">${jdbc.username}</prop>            <prop key="password">${jdbc.password}</prop>        </props>    </property>    <property name="testQuery" value="SELECT 1"/></bean>