org.hibernate.exception.JDBCConnectionException: could not execute query
The last packet successfully received from the server was63717 milliseconds ago.The last packet sent successfully to the server was 63717 milliseconds ago, which is longer than the server configured value of'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property'autoReconnect=true' to avoid this problem.
部署了程序后当天访问都正常,隔天后会报上边的错,百度后大家都说是长时间未对数据库操作,数据库自己关闭,我用修改电脑时间24小时验证;
有两种方法可以解决:1、修改数据库;2、修改程序
修改数据库的我没验证,如果大家感兴趣可以百度验证下;下边贴出修改程序的方法
Hibernate.hbm.xml和proxoolConfig.xml 配置文件
Hibernate.hbm.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 name="default">
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="show_sql">true</property>
<!-- proxool connection pools-->
<property name="hibernate.proxool.pool_alias">mysqlProxool</property>
<property name="hibernate.proxool.xml">proxoolConfig.xml</property>
<property name="connection.provider_class">
org.hibernate.connection.ProxoolConnectionProvider
</property>
<mapping resource="org/shsmis/hibernate/vo/Manager.hbm.xml" />
</session-factory>
</hibernate-configuration>
proxoolConfig.xml文件配置
<?xml version="1.0" encoding="UTF-8"?>
<proxool>
<alias>mysqlProxool</alias>
<driver-url>jdbc:mysql://localhost:3306/DB</driver-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver-properties>
<property name="user" value="root"></property>
<property name="password" value="root"></property>
</driver-properties>
<!-- proxool自动侦察各个连接状态的时间间隔(毫秒),侦察到空闲的连接就马上回收,超时的销毁-->
<house-keeping-sleep-time>90000</house-keeping-sleep-time>
<!-- 指因未有空闲连接可以分配而在队列中等候的最大请求数,超过这个请求数的用户连接就不会被接受-->
<maximum-new-connections>20</maximum-new-connections>
<!-- 最少保持的空闲连接数-->
<prototype-count>5</prototype-count>
<!-- 允许最大连接数,超过了这个连接,再有请求时,就排在队列中等候,最大的等待请求数由maximum-new-connections决定-->
<maximum-connection-count>100</maximum-connection-count>
<!-- 最小连接数-->
<minimum-connection-count>10</minimum-connection-count>
</proxool>
也有哥们儿配置web.xml的;不过我验证不配置web.xml也没啥大碍;所以就把这里的配置干掉了