How to reconnect lost connections with EclipseLink?

末鹿安然 提交于 2019-12-01 16:43:58

问题


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.

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" />

And the transactiontype is RESOURCE_LOCAL if it's important to know.


回答1:


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.

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



来源:https://stackoverflow.com/questions/23525903/how-to-reconnect-lost-connections-with-eclipselink

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!