MySQL+Hibernate下连接空闲8小时自动断开问题解决方案
前段时间刚完成一个家教网项目,数据库为MySQL5.0,持久层使用Hibernate 3.1,没有使用额外的连接池,那么Hibernate会默认使用它自带的一个默认连接池,也就是DriverManagerConnectionProvider。
先在本机上调试都毫无问题,于是部署到服务器上,也都没什么问题。由于这是新网站,根本还没正式对外发布和宣传,所以头两天根本没人访问。等到第二天,我再次访问网站时,问题就出现了,错误信息如下:
javax.servlet.ServletException: ption.JDBCConnectionException: could not execute query
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jsp.index_jsp._jspService(index_jsp.java:57)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.lab1000.jcom.system.filter.RequestEncodingFilter.doFilter(RequestEncodingFilter.java:30)
ption.JDBCConnectionException: could not execute query
vert(SQLStateConverter.java:74)
vert(JDBCExceptionHelper.java:43)
org.hibernate.loader.Loader.doList(Loader.java:2148)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
org.hibernate.loader.Loader.list(Loader.java:2024)
org.iteria.CriteriaLoader.list(CriteriaLoader.java:94)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
com.lab1000.jcom.ArticlesUnder(ArticleDAO.java:163)
com.lab1000.jcom.struts.ute(HomeAction.java:40)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jsp.index_jsp._jspService(index_jsp.java:57)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.lab1000.jcom.system.filter.RequestEncodingFilter.doFilter(RequestEncodingFilter.java:30)
** BEGIN NESTED EXCEPTION **
MESSAGE: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.io.EOFException
STACKTRACE:
java.io.EOFException
sql.adFully(MysqlIO.java:1963)
sql.useAndReadPacket(MysqlIO.java:2375)
sql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2874)
sql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)
sql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)
sql.SQL(Connection.java:3249)
sql.uteInternal(PreparedStatement.java:1268)
sql.uteQuery(PreparedStatement.java:1403)
at org.hibernate.ResultSet(AbstractBatcher.java:139)
at org.hibernate.ResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.iteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at com.lab1000.jcom.ArticlesUnder(ArticleDAO.java:163)
at com.lab1000.jcom.struts.ute(HomeAction.java:40)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
at
org.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:57)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.lab1000.jcom.system.filter.RequestEncodingFilter.doFilter(RequestEncodingFilter.java:30) at
org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.StandardWrapperV alve.invoke(StandardWrapperValve.java:233)
at org.StandardContextValve.invoke(StandardContextValve.java:175)
at org.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.tor.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jkmon.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jkmon.ChannelSocket.invoke(ChannelSocket.java:767)
at org.apache.jkmon.ChannelSocket.processConnection(ChannelSocket.java:697)
at org.apache.jkmon.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
at at.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
at java.lang.Thread.run(Unknown Source)
** END NESTED EXCEPTION **
Last packet sent to the server was 15 ms ago.
STACKTRACE:
** BEGIN NESTED EXCEPTION **
java.io.EOFException
STACKTRACE:
java.io.EOFException
sql.adFully(MysqlIO.java:1963)
sql.useAndReadPacket(MysqlIO.java:2375)
sql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2874)
sql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)
sql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)
sql.SQL(Connection.java:3249)
sql.uteInternal(PreparedStatement.java:1268)
sql.uteQuery(PreparedStatement.java:1403)
at org.hibernate.ResultSet(AbstractBatcher.java:139)
at org.hibernate.ResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.iteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at com.lab1000.jcom.ArticlesUnder(ArticleDAO.java:163)
下载mysql为什么下载不了at com.lab1000.jcom.struts.ute(HomeAction.java:40)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
at
org.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:57)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.lab1000.jcom.system.filter.RequestEncodingFilter.doFilter(RequestEncodingFilter.java:30) at
org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.StandardWrapperV alve.invoke(StandardWrapperValve.java:233)
at org.StandardContextValve.invoke(StandardContextValve.java:175)
at org.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.tor.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jkmon.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jkmon.ChannelSocket.invoke(ChannelSocket.java:767)
at org.apache.jkmon.ChannelSocket.processConnection(ChannelSocket.java:697)
at org.apache.jkmon.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
at at.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
at java.lang.Thread.run(Unknown Source)
** END NESTED EXCEPTION **
Last packet sent to the server was 15 ms ago.
sql.useAndReadPacket(MysqlIO.java:2586)
sql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2874)
sql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)
sql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)
sql.SQL(Connection.java:3249)
sql.uteInternal(PreparedStatement.java:1268)
sql.uteQuery(PreparedStatement.java:1403)
at org.hibernate.ResultSet(AbstractBatcher.java:139)
at org.hibernate.ResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论