JPA (EclipseLink) connection timeouts

岁酱吖の 提交于 2020-01-05 07:27:54

问题


I am using JPA 2.0 with EclipseLink, Glassfish, and NetBeans. I am experiencing issues with connection timeouts after extended periods of inactivity. I've looked pretty hard for ways to either:

(1) Check for JPA's connection and then re-establish its connection if disconnected

(2) Keep the JPA's connection active as much as possible

However, I can't really find a solution for either. The closest thing I can find is this post: How To modify Eclipselink JPA 2.0 connection retry behavior .

If there is someway to directly work with the JPA's connection, it'd be nice but it's buried within the library.


回答1:


What you state you are looking for is usually provided by the datasource, in this case it would be configurable in Glassfish as described here: https://blogs.oracle.com/JagadishPrasath/entry/connection_validation_in_glassfish_jdbc

If you want to do this without a datasource, for instance by passing a URL to the provider and have it handle connections, it will be EclipseLink specific. EclipseLink does have options that can be configured when it attempts to reconnect and retry queries, such as the public void setPingSQL(String pingSQL) public void setQueryRetryAttemptCount(int queryRetryAttemptCount) public void setDelayBetweenConnectionAttempts(int delayBetweenConnectionAttempts) methods that can be set on the DatabaseLogin or DatabasePlatform classes through a customizer.



来源:https://stackoverflow.com/questions/12220860/jpa-eclipselink-connection-timeouts

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