在休眠中没有从连接池中删除连接?

时间:2014-08-28 11:53:47

标签: java hibernate c3p0 toad

我正在使用c3p0连接池在我的hibernate项目中进行池化。这是我的hibernate.cfg.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 <hibernate-configuration>
 <session-factory>
 <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
 <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
 <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/minkme_active</property>
 <property name="hibernate.connection.username">java</property>
 <property name="hibernate.connection.password">java123</property>

    <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>        
    <property name="hibernate.c3p0.acquire_increment">1</property>
    <property name="hibernate.c3p0.idle_test_period">5</property>
    <property name="hibernate.c3p0.min_size">5</property>
    <property name="hibernate.c3p0.max_size">20</property>
    <property name="hibernate.c3p0.max_statements">50</property>
    <property name="hibernate.c3p0.timeout">30</property>
    <property name="hibernate.c3p0.acquireRetryAttempts">1</property>
    <property name="hibernate.c3p0.acquireRetryDelay">250</property>

    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.use_sql_comments">true</property>

    <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
    <property name="hibernate.current_session_context_class">thread</property>


<mapping resource="Save.hbm.xml"/>
<mapping resource="ad.hbm.xml"/>
<mapping resource="msgs.hbm.xml"/>

 </session-factory>
</hibernate-configuration>

以下是我的MYSQL TOAD快照:http://postimg.org/image/i45d3wri1/

这里我设置了idle_test_period 5秒,因此每5秒后会话ID会发生变化,但我也提到了30秒的timeout所以每30秒后应该从数据库中删除连接但这并不是很好的。

0 个答案:

没有答案