hibernate 4会话连接保持打开状态
我在java应用程序中使用hibernate和mysql数据库 我从Hibernate3迁移到Hibernate4 但在新的hibernate中,繁忙线程的数量增加了,并且它使用了所有的连接 因此,我的应用程序停止工作,无法再提供连接。 我的hibernate.cfg配置如下:hibernate 4会话连接保持打开状态,hibernate,c3p0,Hibernate,C3p0,我在java应用程序中使用hibernate和mysql数据库 我从Hibernate3迁移到Hibernate4 但在新的hibernate中,繁忙线程的数量增加了,并且它使用了所有的连接 因此,我的应用程序停止工作,无法再提供连接。 我的hibernate.cfg配置如下: <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <!-- Ena
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<property name="hibernate.current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="hibernate.cache.use_second_level_cache">true</property>
<!--<property name="hibernate.cache.provider_class">
net.sf.ehcache.hibernate.EhCacheProvider
</property>-->
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory</property>
<property name="hibernate.cache.use_query_cache">true</property>
<!--<property name="hibernate.generate_statistics">true</property>-->
<!--C3P0 configure-->
<property name="hibernate.connection.provider_class">
org.hibernate.connection.C3P0ConnectionProvider
</property>
<property name="hibernate.c3p0.acquire_increment">3</property>
<property name="hibernate.c3p0.idle_test_period">144</property>
<property name="hibernate.c3p0.timeout">60</property>
<property name="hibernate.c3p0.max_size">30</property>
<property name="hibernate.c3p0.min_size">3</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.preferredTestQuery">select 1;</property>
<property name="hibernate.c3p0.validate">true</property>
<property name="hibernate.c3p0.testConnectionOnCheckout">true</property>
我将超时设置为一个小值,并增加最大值
并将use_second_level_cache设置为false
但没有任何改善
有什么问题
非常感谢所以这听起来很像是应用程序中的连接泄漏。使用c3p0配置参数unreturnedConnectionTimeout和DebuggeUnreturnedConnectionStackTraces对其进行调试 看 在hibernate.cfg中,它们是hibernate.c3p0.unreturnedConnectionTimeout和hibernate.c3p0.debugUnreturnedConnectionStackTraces