问题描述
如果mySQL Server在睡眠时间" 500秒后终止了会话,则我有一个问题,那就是下一个请求不会成功.如果mySQL Server无法关闭睡眠连接,则可能在700秒后发生相同的问题.
I have the problem if the mySQL Server kills the session after 500 sec "sleeping-time", that the next request isn't successful. The same problem occurs after maybe 700 sec if the mySQL Server doesn't closes the sleeping connection.
我该怎么办?遵循我的persistence.xml的属性
What can I do?Following the properties of my persistence.xml
<property name="eclipselink.query-results-cache" value="false" />
<property name="eclipselink.cache.size.default" value="0" />
<property name="eclipselink.cache.type.default" value="None" />
<property name="eclipselink.cache.alwaysRefresh.default" value="true" />
<property name="eclipselink.jdbc.read-connections.max" value="10" />
<property name="eclipselink.jdbc.cache-statements" value="true" />
<property name="eclipselink.jdbc.read-connections.shared" value="true" />
重要的是,事务类型为RESOURCE_LOCAL.
And the transactiontype is RESOURCE_LOCAL if it's important to know.
推荐答案
您如何配置连接池?如果它是服务器数据源,则应在服务器中设置诸如连接测试之类的属性.请参见 http://docs.oracle.com/cd /E21764_01/web.1111/e13737/ds_tuning.htm#i1199711 作为示例设置.
How have you configured your connection pool? If it a server datasource, the properties such as connection testing should be set in the server. See http://docs.oracle.com/cd/E21764_01/web.1111/e13737/ds_tuning.htm#i1199711 for example settings.
如果它是EclipseLink池,则默认情况下它应在检测到连接失败时自动尝试重试查询.控制行为的属性只能通过特定数据库的DatabasePlaform类中的api访问,并且可以通过定制器进行设置,如下所述:如何修改Eclipselink JPA 2.0连接重试行为
If it is an EclipseLink pool, it should automatically attempt to retry queries when it detects a connection failure by default. The properties controlling the behavior are only accessible through api in the DatabasePlaform class for your specific database, and can be set through a customizer as described here:How To modify Eclipselink JPA 2.0 connection retry behavior
这篇关于如何使用EclipseLink重新连接丢失的连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!