我在 Jboss 6 上使用 XA 数据源,当其中一个连接失效时使用<check-valid-connection-sql>
and<background-validation-millis>
自动重新连接。这可行,但问题是在“重新连接”之后,每两分钟左右我就会收到这个奇怪的异常,即使我的数据库操作正在运行。
2011-10-13 12:05:22,516 WARN [com.arjuna.ats.jta] (Periodic Recovery) ARJUNA-16027 Local XARecoveryModule.xaRecovery got XA exception XAException.XAER_RMERR: javax.transaction.xa.XAException: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.DTC_XA_Interface(SQLServerXAResource.java:642) [:]
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.recover(SQLServerXAResource.java:723) [:]
at org.jboss.resource.adapter.jdbc.xa.XAManagedConnection.recover(XAManagedConnection.java:294) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.xaRecovery(XARecoveryModule.java:468) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.resourceInitiatedRecoveryForRecoveryHelpers(XARecoveryModule.java:436) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkSecondPass(XARecoveryModule.java:155) [:6.0.0.Final]
at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:789) [:6.0.0.Final]
at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:371) [:6.0.0.Final]
2011-10-13 12:05:22,516 WARN [com.arjuna.ats.jta] (Periodic Recovery) ARJUNA-16027 Local XARecoveryModule.xaRecovery got XA exception XAException.XAER_RMERR: javax.transaction.xa.XAException: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.DTC_XA_Interface(SQLServerXAResource.java:642) [:]
at com.microsoft.sqlserver.jdbc.SQLServerXAResource.recover(SQLServerXAResource.java:723) [:]
at org.jboss.resource.adapter.jdbc.xa.XAManagedConnection.recover(XAManagedConnection.java:294) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.xaRecovery(XARecoveryModule.java:468) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.resourceInitiatedRecoveryForRecoveryHelpers(XARecoveryModule.java:436) [:6.0.0.Final]
at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkSecondPass(XARecoveryModule.java:155) [:6.0.0.Final]
at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:789) [:6.0.0.Final]
at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:371) [:6.0.0.Final]
会不会是司机?(我使用的是 Microsoft 的 4 型)
这是我的数据源配置:
<xa-datasource>
<jndi-name>jdbc/MyDataSourceDS</jndi-name>
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
<xa-datasource-property name="ServerName">hostname</xa-datasource-property>
<xa-datasource-property name="DatabaseName">database</xa-datasource-property>
<xa-datasource-property name="SelectMethod">cursor</xa-datasource-property>
<xa-datasource-property name="User">user</xa-datasource-property>
<xa-datasource-property name="Password">password</xa-datasource-property>
<!--pooling parameters-->
<min-pool-size>5</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>15</idle-timeout-minutes>
<new-connection-sql>select 1</new-connection-sql>
<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
<background-validation>true</background-validation>
<background-validation-millis>10000</background-validation-millis>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>MS SQLSERVER2000</type-mapping>
</metadata>
</xa-datasource>
另外,我没有在日志中的每个查询之前看到“SELECT 1”查询?我看到我的查询正在运行。
任何帮助将不胜感激!