MySQL+Hibernate连接空闲超过8小时后自动断开解决方案

来源:互联网 发布:cs绘画软件 编辑:程序博客网 时间:2024/04/29 20:27

采用C3P0管理Hibernate的JDBC连接池

第一步,工程内导入C3P0包

第二步,修改Hibernate配置文件

添加以下代码


<!-- 配置c3p0连接池(解决MySQL空闲8小时自动断开问题)-->  <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property><property name="hibernate.c3p0.acquireIncrement">2</property><property name="hibernate.c3p0.checkoutTimeout">3000</property>  <property name="hibernate.c3p0.idleConnectionTestPeriod">2000</property><property name="hibernate.c3p0.maxIdleTime">4000</property><property name="hibernate.c3p0.maxPoolSize">60</property><property name="hibernate.c3p0.minPoolSize">1</property><property name="hibernate.c3p0.maxStatements">0</property><property name="hibernate.c3p0.validate">true</property><property name="hibernate.c3p0.testConnectionOnCheckout">true</property>


0 0
原创粉丝点击