java.net.SocketException:Software caused connection abort: socket write error

阅读更多

使用mysql  和hibernate 3.2开发的一个小型网站,上传到服务器上,第一天还能够正常访问,第二天一早就出现了异常,异常如下:
2010-04-14 11:27:13:WARNhttp-8080-4org.hibernate.util.JDBCExceptionReporter-SQL Error: 0, SQLState: 08S01
2010-04-14 11:27:13:ERRORhttp-8080-4org.hibernate.util.JDBCExceptionReporter-Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: Software caused connection abort: socket write error

STACKTRACE:

java.net.SocketException: Software caused connection abort: socket write error
 at java.net.SocketOutputStream.socketWrite0(Native Method)
 at java.net.SocketOutputStream.socketWrite(Unknown Source)
 at java.net.SocketOutputStream.write(Unknown Source)
 at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
 at java.io.BufferedOutputStream.flush(Unknown Source)
 at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2739)
 at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2650)
 at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1581)
 at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1695)
 at com.mysql.jdbc.Connection.execSQL(Connection.java:3004)
 at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1128)
 at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1222)
 at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
 at org.hibernate.loader.Loader.getResultSet(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.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
 at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
 at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
 at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
 at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
 at com.cngoto.cjdy.car2.dao.Cjdy2cardetailDao.getListHot(Cjdy2cardetailDao.java:42)
 at org.apache.jsp.cjdy2tab_jsp._jspService(cjdy2tab_jsp.java:170)
 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
 at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535)
 at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472)
 at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
 at org.apache.jsp.index_jsp._jspService(index_jsp.java:82)
 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
 at java.lang.Thread.run(Unknown Source)


** END NESTED EXCEPTION **

 

Last packet sent to the server was 0 ms ago.
原因分析:Mysql服务器默认的“wait_timeout”是8小时,也就是说一个connection空闲超过8个小时,Mysql将自动断开该 connection。这样就出现了上面这个问题。java.net.SocketException: Software caused connection abort: socket write error。网上的解决方法有几种,我选用第一种:在mysql安装目录下找到my.ini文件中添加超时限制:在该文件最后添加一行:wait_timeout=2880000。这样把之前的超时限制把8小时(28800)扩大为800小时。这样重启了mysql后再在其中输入命令:show global variables like "wait_timeout";查看超时是否已修改为:2880000。重启tomcat(如果已启动),OK。

 

你可能感兴趣的:(Java,.net,Socket,Hibernate,MySQL)