数据库
首页 > 数据库> > 数据库重新启动后,Jboss无法重新连接到Mysql

数据库重新启动后,Jboss无法重新连接到Mysql

作者:互联网

您好,我们使用JBOSS AS 7.1.1 Final.
简单的JPA Hibernate体系结构与Mysql.

xa-datasource看起来像:

<xa-datasource jndi-name="java:jboss/datasources/db" pool-name="db" enabled="true" use-java-context="true">
<xa-datasource-property name="ServerName">
localhost
</xa-datasource-property>
<xa-datasource-property name="DatabaseName">
db
</xa-datasource-property>
<xa-datasource-property name="User">
root
</xa-datasource-property>
<xa-datasource-property name="Password">
xxxxx
</xa-datasource-property>
<xa-datasource-property name="AutoReconnectForPools">
true
</xa-datasource-property>
<xa-datasource-property name="FailOverReadOnly">
false
</xa-datasource-property>
<xa-datasource-property name="MaxReconnects">
100
</xa-datasource-property>
<xa-datasource-property name="ReconnectAtTxEnd">
true
</xa-datasource-property>
<driver>com.mysql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<check-valid-connection-sql>select 1</check-valid-connection-sql>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
</validation>
</xa-datasource>

MySQL重新启动后,JBOSS应该更新连接(重新连接),但是不会发生.请指教

解决方法:

这个对我有用.尝试添加以下内容:

<validation>
    <check-valid-connection-sql>select 1</check-valid-connection-sql>
    <background-validation>true</background-validation>
    <background-validation-millis>15000</background-validation-millis>
</validation>

标签:jboss7-x,jca,mysql
来源: https://codeday.me/bug/20191031/1973999.html