超难问题!也是最常见的问题!著名的异常:java.net.SocketException: Connection reset by peer: socket write error,难道不能避免吗?

websa 2003-03-14 09:36:11
我的web应用程序后台数据库是java,
连接池配置:
<driver>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver> <url>jdbc:microsoft:sqlserver://dataserver:1433;databasename=yeshu;selectMethod=cursor</url>
<username>saa</username>
<password>r7ebPAYdBUU=</password>
<minimumSize>5</minimumSize>
<initializeSize>10</initializeSize>
<maximumSize>20</maximumSize>
<idleTimeout>180000</idleTimeout>
<waitTimeout>180000</waitTimeout>
当抛出
java.net.SocketException: Connection reset by peer: socket write error
异常以后,就会出现再也连接不上的问题
连接池是自己写的,这个错误有时候好几天也不发生,有时候一天好几次
连接池的日志:
/*****Before getConnection() (Thu Mar 13 14:55:39 CST 2003) *****/
Established connection number 10
Free connection number 10
Used connection number 0
Dying connection number 0
Initial number 5
Prefer number 10
Max number 20
Block or not true
Reuse or not true

ConnectionPoolManager:<=get: 9 of 10 (max 20, prefer 10) are free
TransactionControl:error when getConnection(), [Microsoft][SQLServer JDBC Driver]System Exception: Connection reset by peer: socket write error
TransactionControlPool:release TransactionControl with id(14)
TransactionControlPool:Creating new TransactionControl. ID: 15

/*****Before getConnection() (Thu Mar 13 14:55:55 CST 2003) *****/
Established connection number 10
Free connection number 9
Used connection number 0
Dying connection number 0
Initial number 5
Prefer number 10
Max number 20
Block or not true
Reuse or not true


/*****End getConnection() (Thu Mar 13 14:55:55 CST 2003) *****/
Established connection number 10
Free connection number 8
Used connection number 1
Dying connection number 0
Initial number 5
Prefer number 10
Max number 20
Block or not true
Reuse or not true

ConnectionPoolManager:<=get: 8 of 10 (max 20, prefer 10) are free
java.sql.SQLException: [Microsoft][SQLServer JDBC Driver]System Exception: Connection reset by peer: socket write error
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.submitRequest(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSExecuteRequest.submitRequest(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.rollbackTransaction(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.rollback(Unknown Source)
at com.gtong.application.architect.TransactionControl.rollback(TransactionControl.java:200)
at com.gtong.application.architect.Context.rollback(Context.java:580)
at jsp.EventDispatch_jsp_0._jspService(EventDispatch_jsp_0.java:260)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:139)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.servlet.dynacache.CacheHook.handleFragment(CacheHook.java:305)
at com.ibm.servlet.dynacache.CacheHook.handleServlet(CacheHook.java:159)
at com.ibm.servlet.dynacache.CacheManager.handleServlet(CacheManager.java:234)
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:284)
at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:415)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:544)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:827)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:159)
at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:286)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:106)
at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:472)
at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:1012)
at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:913)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:499)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:278)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:105)
at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:67)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:123)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)
at com.ibm.servlet.engine.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:106)
at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:125)
at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:315)
at com.ibm.servlet.engine.http11.HttpConnection.handleRequest(HttpConnection.java:60)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:313)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:242)
at com.ibm.ws.util.CachedThread.run(ThreadPool.java:122)
TransactionControl:rollback(): SQLException during rollback.[Microsoft][SQLServer JDBC Driver]System Exception: Connection reset by peer: socket write error
TransactionControlPool:release TransactionControl with id(15)

/*****Before releaseConnection() (Thu Mar 13 14:55:56 CST 2003) *****/
Established connection number 10
Free connection number 8
Used connection number 1
Dying connection number 0
Initial number 5
Prefer number 10
Max number 20
Block or not true
Reuse or not true

可见,连接某个时间从池里自动减少了一个,这个连接可能是sql server直接kill掉的(可能是idle time到了也可能是客户端浏览器操作回退等所致。。。),连接池不知道,所以再拿连接的时候就会出错,因为再次拿的时候,连接已经不在了,但是池里标注的却是可用的???//?
有没有办法解决阿
...全文
73 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
kenli 2003-06-24
  • 打赏
  • 举报
回复
这么自私啊,贴出来大家看看么。
dongdongshu 2003-06-02
  • 打赏
  • 举报
回复
呵呵,看来你是收到MAIL了~~
你在北京么?
请吃饭算了吧?
teva 2003-04-14
  • 打赏
  • 举报
回复
不建议使用自己的连接池实现

62,616

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧