日期:2014-05-17  浏览次数:20795 次

一个让人头痛的问题
在项目中我使用Spring JDNI进行数据连接.开始在服务器上没什么问题.可是有时会报错误:错误日志如下
The last packet successfully received from the server was56275 milliseconds ago.The last packet sent successfully to the server was 56275 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.
2011-10-10 09:48:53,269 - [ERROR] [AbstractFlushingEventListener] - Could not synchronize database state with session
org.hibernate.exception.JDBCConnectionException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:72)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions
Caused by: java.sql.BatchUpdateException: The last packet successfully received from the server was56275 milliseconds ago.The last packet sent successfully to the server was 56275 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.
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1693)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1108)
at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
... 36 more
2011-10-10 09:48:53,273 - [ERROR] [JDBCExceptionReporter] - Already closed.
2011-10-10 09:48:53,274 - [ERROR] [JDBCExceptionReporter] - Already closed.
2011-10-10 09:48:53,274 - [ERROR] [SessionFactoryUtils] - Could not close Hibernate Session
org.hibernate.exception.GenericJDBCException: Cannot close connection
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.jdbc.ConnectionManager.closeConnection(ConnectionManager.java:347)
at org.hibernate.jdbc.ConnectionManager.cleanup(ConnectionManager.java:277)
at org.hibernate.jdbc.ConnectionManager.close(ConnectionManager.java:218)
at org.hibernate.impl.SessionImpl.close(SessionImpl.java:317)
at com.fxun.commons.plant.bl.impl.UserOperateManagerImpl.generateGoodsID(UserOperateManagerImpl.java:93)
at com.fxun.commons.plant