MySQL服务器连接wait_timeout是28800秒,我的hibernate应用程序保持超时(整个应用程序的生命周期大约是1小时)。
The last packet successfully received from the server was 4,396,266 milliseconds ago. The last packet sent successfully to the server was 4,405,476 milliseconds ago.
hibernate使用以下c3p0属性,我不明白为什么它超时,即使整个应用程序运行大约1小时,并且空闲时间应该远低于此。鉴于hibernate的连接的超时值为5000秒,加上它每300秒检查一次空闲,为什么会这样呢?
<property name="hibernate.c3p0.min_size">0</property>
<property name="hibernate.c3p0.max_size">200</property>
<property name="hibernate.c3p0.idle_test_period">300</property>
<property name="hibernate.c3p0.timeout">5000</property>
更新:详细错误消息:
Caused by: java.sql.BatchUpdateException: Communications link failure The last packet successfully received from the server was 5,980,742 milliseconds ago. The last packet sent successfully to the server was 5,9\ 87,659 milliseconds ago. at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2024) at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1449) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70) at org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:56) at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2421) ... 15 more Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet successfully received from the server was 5,980,742 milliseconds ago. The last packet sent successfully to the server was 5,9\ 87,659 milliseconds ago. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:407) at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116) at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3358) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1970) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2150) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415) at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1976) ... 20 more Caused by: java.net.SocketException: Broken pipe at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92) at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123) at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3339)