出现错误SQL Error: SQLState: S
Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
SocketException
MESSAGE: Software caused connection abort: socket write error
STACKTRACE:
SocketException: Software caused connection abort: socket write error
** END NESTED EXCEPTION **
Last packet sent to the server was ms ago
问题出现原因
mysql默认为小时后自动消除空闲连接而hibernate默认空连接超时时间大于这个数
解决方法
找到mysql目录下的myini文件在最底处(或任意位置)添加wait_timeout =(为自定义值)
用cp代替hibernate的连接池cpjar可从hibernate开源项目的lib下面找到将其拷贝到webinf/lib下面在hibernatecfgxml配置文件中添加以下信息
<property name=hibernatecpmin_size></property>
<property name=hibernatecptimeout></property>
<property name=hibernatecpmax_statements></property>
<property name=hibernatecpidle_test_period></property>
<property name=hibernatecpacquire_increment></property>
<property name=hibernatecpvalidate>false</property>
其中hibernatecptimeout属性指定多少秒后连接超时连接池会自动对超时连接进行重查