尽管hibernate.cfg.xml文件具有足够的内容,但c3p0不会关闭空闲连接这一事实对我没有什么麻烦。这是上面提到的文件的一部分:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.url">jdbc:postgresql://***.***.***.***/dev</property>
<property name="connection.username">*******</property>
<property name="connection.password">*******</property>
<!--<property name="connection.pool_size">1</property>-->
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.current_session_context_class">org.hibernate.context.internal.ThreadLocalSessionContext</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="use_sql_comments">true</property>
<property name="hibernate.generate_statistics">false</property>
<!-- pooling -->
<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.c3p0.max_size">100</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.idle_test_period">180</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.jdbc.use_get_generated_keys">true</property>
<property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>
例如,当我在应用程序前端中使用“搜索”按钮时,将发送请求,并且在数据库仪表板上,我可以看到一个空闲的COMMIT事务。在hibernate.c3p0.idle_test_period和hibernate.c3p0.timeout中给定的时间之后,我认为此事务应消失,但不幸的是它不会...