如何修改Eclipselink JPA 2.0连接重试行为 [英] How To modify Eclipselink JPA 2.0 connection retry behavior
问题描述
如何修改Eclipselink JPA 2.0连接重试行为。
当它检测到连接失败时,Eclipselink会自动尝试重新连接到数据库,这会导致swing ui在没有任何响应的情况下冻结,直到它连接到数据库。
有任何解决方案来修改这个行为
Ie是可能的,当连接失败时抛出异常,而不重试
请帮助这个问题
我面临巨大的问题。 p>
我去了eclipselink源代码和google,但我找不到任何解决方案。
使用SessionCustomizer可以禁用连接重新连接。
import org.eclipse.persistence.internal.sessions.factories.SessionCustomizer;
import org.eclipse.persistence.sessions.Session;
import org.eclipse.persistence.sessions.DatabaseLogin;
public class EmployeeSessionCustomizer implements SessionCustomizer {
public void customize(Sesssion session){
DatabaseLogin login =(DatabaseLogin)session.getDatasourceLogin();
login.setConnectionHealthValidationOnError(false);
}
}
此定制器可以通过持久性单元属性
< property name =eclipselink.session.customizervalue =acme.EmployeeSessionCustomizer/&
How To modify Eclipselink JPA 2.0 connection retry behavior . Eclipselink automatically tries to reconnect it self to database whenever it detects a connection failure this causes swing ui to freeze without any responses until it connects to database . Are there any solution to modify this behavior Ie is it possible to throw exception when connection fails without retrying Please help on this issue I am facing with huge problem.
I went throe eclipselink source code and google but I could not find any solution.
Using a SessionCustomizer you can disable the connection reconnection.
package acme;
import org.eclipse.persistence.internal.sessions.factories.SessionCustomizer;
import org.eclipse.persistence.sessions.Session;
import org.eclipse.persistence.sessions.DatabaseLogin;
public class EmployeeSessionCustomizer implements SessionCustomizer {
public void customize(Sesssion session) {
DatabaseLogin login = (DatabaseLogin)session.getDatasourceLogin();
login.setConnectionHealthValidationOnError(false);
}
}
This customizer can be set through a persistence unit property
<property name="eclipselink.session.customizer" value="acme.EmployeeSessionCustomizer"/>
这篇关于如何修改Eclipselink JPA 2.0连接重试行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!