• Post Reply Bookmark Topic Watch Topic
  • New Topic

Stale Connection  RSS feed

Mandy Yan
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an application running on WebSphere 4.0 with oracle database on Windows 2000 Server. After the application has not been accessed for 1 night, the stale connection error occurs.

The error is as follows:
Mapping the following SQLException, with ErrorCode 17,002 and SQLState <null>, to a StaleConnectionException: java.sql.SQLException: Io exception: Connection reset by peer: socket write error
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:335)
at oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:503)
at oracle.jdbc.driver.OracleConnection.privateCreateStatement(OracleConnection.java:683)
at oracle.jdbc.driver.OracleConnection.createStatement(OracleConnection.java:560)
at com.ibm.ejs.cm.pool.ConnectO.createStatement(ConnectO.java:2057)
at com.ibm.ejs.cm.proxy.OracleConnectionProxy.createStatement(OracleConnectionProxy.java:131)
at insurance.bean.UserBean.login(UserBean.java:125)
at insurance.bean.UserBean.login(UserBean.java:352)
at insurance.MemberLogin.service(MemberLogin.java:68)
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.servlet.engine.webapp.SingleThreadModelServlet.service(SingleThreadModelServlet.java:73)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:827)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:167)
at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:297)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:110)
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:665)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:117)
at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:124)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:218)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)
at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:122)
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:323)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:252)
at com.ibm.ws.util.CachedThread.run(ThreadPool.java:137)
Can anyone kindly help me see what the problem is?
Thank you very much!
[ July 31, 2002: Message edited by: Mandy Yan ]
Kartik Shah
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what documentation says...
This exception (com.ibm.websphere.ce.cm.StaleConnectionException) indicates that the connection currently being held is no longer valid. This
can occur for numerous reasons, including:
The application fails to get a connectionbecause of a problem such as the database not being started. l
A connection is no longer usable because of a database failure. When an application tries to use a connection it previously obtained, the
connection is no longer valid. In this case, all connections currently in use by the application may prompt this exception.
The application using the connection has already called close() and then tries to use the connection again. l
The connection has been orphaned, andthe application tries to use the orphaned connection. l
The application tries to use a JDBC resource, such as Statement, obtained on a now-stale connection. l
When application code catches StaleConnectionException, it should take explicit steps to handle the exception. StaleConnectionException extends
SQLException, so it can be thrown from any method that is declared to throw SQLException. The most common occasion for a
StaleConnectionException to be thrown is the first time a connection is used, just after it has been retrieved. Because connections are pooled, a
database failure is not detected until the operation immediately following its retrieval from the pool, which is the first time communication with the
database is attempted. It is only when a failure is detected thatthe connection is marked stale. StaleConnectionException occurs less often if each
method that accesses the database gets a new connection from the pool. Typically, this occurs because all connections currently allocatedto an
application are marked stale; the more connections the application has, the more connections can be stale.
Generally,when a StaleConnectionException is caught, the transaction in which the connection was involvedneeds to be rolled back and a new
transaction begun with a new connection.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!