当前位置: 代码迷 >> J2EE >> Hibernate 运用 proxool 连接池 隔一段时间自动断开连接,郁闷死了,请求大家帮忙
  详细解决方案

Hibernate 运用 proxool 连接池 隔一段时间自动断开连接,郁闷死了,请求大家帮忙

热度:708   发布时间:2016-04-22 03:13:46.0
Hibernate 使用 proxool 连接池 隔一段时间自动断开连接,郁闷死了,请求大家帮忙
数据持久层:Hibernate 3.1
连接池:proxool 0.8.3

症状描述: 正常操作没有问题,如果过上一段时间不操作,比较机器闲置半小时(TOMCAT容器正常工作)左右,当你再次操作的时候,报500错误,说connection.close()方法已经被执行。错误详情如下:

Java code
ERROR[http-8080-Processor23](StandardWrapperValve.java:253)-Servlet.service() for servlet action threw exceptioncom.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:981)    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)    at com.mysql.jdbc.ConnectionImpl.getMutex.......


--------------------
下面是几个主要的配置文件,贴出来:
hibernate.cfg.xml
Java code
<?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="dialect">        org.hibernate.dialect.MySQLDialect    </property>    <property name="show_sql">true</property>    <!-- proxool connection pool config -->    <property name="proxool.pool_alias">dbpool</property>    <property name="proxool.xml">proxool_conf.xml</property>    <property name="connection.provider_class">org.hibernate.connection.ProxoolConnectionProvider</property>    <mapping resource="com/erp/puaite/main/TbAdmin.hbm.xml" />    <mapping resource="com/erp/puaite/main/TbProduct.hbm.xml" />    <mapping resource="com/erp/puaite/main/TbSuppliers.hbm.xml" />    <mapping        resource="com/erp/puaite/main/TbMonthlyBuylistSummaryDetil.hbm.xml" />    <mapping        resource="com/erp/puaite/main/TbMonthlyBuylistSummary.hbm.xml" />    <mapping        resource="com/erp/puaite/main/TbNewaddPlannedBuylistDetil.hbm.xml" />    <mapping        resource="com/erp/puaite/main/TbNewaddPlannedBuylist.hbm.xml" />    <mapping        resource="com/erp/puaite/main/TbProducingPlannedBuylistDetil.hbm.xml" />    <mapping        resource="com/erp/puaite/main/TbProducingPlannedBuylist.hbm.xml" />    <mapping resource="com/erp/puaite/main/TbReceiveGoods.hbm.xml" />    <mapping resource="com/erp/puaite/main/TbSendmoneyList.hbm.xml" />    <mapping        resource="com/erp/puaite/main/TbStockMonthlyReportDetil.hbm.xml" />    <mapping        resource="com/erp/puaite/main/TbStockMonthlyReport.hbm.xml" />    <mapping        resource="com/erp/puaite/main/TbSupplierGivingPrice.hbm.xml" /></session-factory></hibernate-configuration>


proxool_conf.xml
Java code
<?xml version="1.0" encoding="UTF-8"?><something-else-entirely>    <proxool>        <alias>dbpool</alias>        <driver-url>jdbc:mysql://localhost:3306/db_puaite?useUnicode=true&amp;characterEncoding=utf-8</driver-url>        <driver-class>org.gjt.mm.mysql.Driver</driver-class>        <driver-properties>            <property name="user" value="root" />            <property name="password" value="186899" />        </driver-properties>        <house-keeping-sleep-time>90000</house-keeping-sleep-time>        <maximum-active-time>60000</maximum-active-time>        <maximum-new-connections>100</maximum-new-connections>        <prototype-count>5</prototype-count>                <maximum-connection-count>50</maximum-connection-count>        <minimum-connection-count>10</minimum-connection-count>    </proxool></something-else-entirely>
  相关解决方案