Java c3p0与冬眠don';t闭合连接
我有一个项目使用了Java c3p0与冬眠don';t闭合连接,java,hibernate,c3p0,Java,Hibernate,C3p0,我有一个项目使用了hibernatejpa和persistence.xml以及EntityManager <property name="connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider"/> <!-- Important --> <property name="hibernate.c3p0.min_size" value="10"/
hibernatejpa
和persistence.xml以及EntityManager
<property name="connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider"/>
<!-- Important -->
<property name="hibernate.c3p0.min_size" value="10"/>
<property name="hibernate.c3p0.max_size" value="20"/>
<property name="hibernate.c3p0.acquire_increment" value="1"/>
<property name="hibernate.c3p0.minPoolSize" value="1"/>
<property name="hibernate.c3p0.timeout" value="1800"/>
<property name="hibernate.c3p0.max_statements" value="50"/>
<property name="hibernate.c3p0.idle_test_period" value="3000"/>
但连接件未与座椅闭合,见下文
PostgreSQL
请告诉我哪里错了
提前感谢。连接池不是关于关闭连接的。这完全是相反的情况——保持连接的活力并重用它们。保持活动空闲连接比按需重新建立连接要有效得多 作为奖励,请查看附录C,因为您的一些配置属性是多余的和/或没有任何影响。我看不到“下面”有任何内容
public class JPAFilter implements Filter {
@Override
public void destroy() {}
@Override
public void init(FilterConfig fc) throws ServletException {}
@Override
public void doFilter(ServletRequest req, ServletResponse res,FilterChain chain) throws IOException, ServletException {
try {
req.setAttribute("EntityManager", EntityManagerHelper.getEntityManager());
EntityManagerHelper.beginTransaction();
chain.doFilter(req, res);
EntityManagerHelper.commit();
} catch (RuntimeException e) {
if ( EntityManagerHelper.getEntityManager() != null && EntityManagerHelper.getEntityManager().isOpen())
EntityManagerHelper.rollback();
throw e;
} finally {
EntityManagerHelper.closeEntityManager();
}
}
public EntityManager getEntityManager(){
return EntityManagerHelper.getEntityManager();
}
}
PostgreSQL