一个让人头痛的问题
在项目中我使用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.action.UserManagerAction.sendShop(UserManagerAction.java:686)
at com.fxun.commons.plant.action.UserManagerAction.execute(UserManagerAction.java:64)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.easou.framework.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
Caused by: java.sql.SQLException: Already closed.
at org.apache.tomcat.dbcp.dbcp.PoolableConnection.close(PoolableConnection.java:114)
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:191)
at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.closeConnection(LocalDataSourceConnectionProvider.java:94)
at org.hibernate.jdbc.ConnectionManager.closeConnection(ConnectionManager.java:343)
... 36 more
2011-10-10 09:48:53,275 - [INFO] [UserOperateManagerImpl] - =====ID浜х敓瑙勫垯 ===============缁撴潫===========
2011-10-10 09:48:53,276 - [ERROR] [UserManagerAction] - error.sendShop
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: Could not execute JDBC batch update; uncategorized SQLException for SQL [update T_GOOD_SEQUENCE set SEQUENCE=? where CATEGORY_ID=? and TYPE_ID=?]; SQL state [08S01]; error code [0]; 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.; nested exception is 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 org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:96)
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:257)
at org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException
(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
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)
希望高手帮忙解释下
[解决办法]
maxWait="500"
0.5秒钟太短,一般设置为5秒钟