You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Steve Wells <we...@gmail.com> on 2006/04/03 03:34:40 UTC

Idle connection errors

Hi,

If we try and run a query after the connection have been idle for some time,
many hours (sorry I don't exactly yet know how long) we get:

Caused by: java.sql.SQLException: Invalid state, the Connection object is
closed.
 at net.sourceforge.jtds.jdbc.ConnectionJDBC2.checkOpen(ConnectionJDBC2.java
:1305)
 at net.sourceforge.jtds.jdbc.ConnectionJDBC2.prepareCall (
ConnectionJDBC2.java:1941)
 at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.prepareCall(
DelegatingConnection.java:212)
 at
org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareCall
(PoolingDataSource.java :268)
 at org.objectstyle.cayenne.access.trans.ProcedureTranslator.createStatement
(ProcedureTranslator.java:160)
 at
org.objectstyle.cayenne.dba.sqlserver.SQLServerProcedureAction.performAction
(SQLServerProcedureAction.java :105)
 at org.objectstyle.cayenne.access.DataNodeQueryAction.runQuery(
DataNodeQueryAction.java:95)
 at org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java
:321)
 ... 54 more

using SQL Server, jtds 1.2, Cayenne M10.  Any thoughts please?

Re: Idle connection errors

Posted by Steve Wells <we...@gmail.com>.
Thanks Andrus,

I added testOnBorrow and validationQuery to my Tomcat server.xml, global
resource:

<GlobalNamingResources>
   <Resource
      name="jdbc/GlobalDataSource"
      type="javax.sql.DataSource"
      driverClassName="net.sourceforge.jtds.jdbc.Driver"
      *testOnBorrow="true"
      validationQuery="SELECT 1"*
   .....

I also added "*autoReconnect=true" *to the JDBC url, though I think in this
case the driver ignores it.

It seems ok so far, but I'll need more time to prove it.

Steve

On 03/04/06, Andrus Adamchik <an...@objectstyle.org> wrote:
>
> Some drivers support auto-reconnect parameter:
>
> http://objectstyle.org/confluence/display/CAY/Reconnect
>
> jTDS doesn't seem to support that. From the stack trace, you are
> using a DBCP connection pool. IIRC DBCP allows transparent reconnect
> with any driver. You'd have to check DBCP docs on that.
>
> Andrus
>
>
> On Apr 3, 2006, at 5:34 AM, Steve Wells wrote:
> > Hi,
> >
> > If we try and run a query after the connection have been idle for
> > some time,
> > many hours (sorry I don't exactly yet know how long) we get:
> >
> > Caused by: java.sql.SQLException: Invalid state, the Connection
> > object is
> > closed.
> >  at net.sourceforge.jtds.jdbc.ConnectionJDBC2.checkOpen
> > (ConnectionJDBC2.java
> > :1305)
> >  at net.sourceforge.jtds.jdbc.ConnectionJDBC2.prepareCall (
> > ConnectionJDBC2.java:1941)
> >  at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.prepareCall(
> > DelegatingConnection.java:212)
> >  at
> > org.apache.tomcat.dbcp.dbcp.PoolingDataSource
> > $PoolGuardConnectionWrapper.prepareCall
> > (PoolingDataSource.java :268)
> >  at
> > org.objectstyle.cayenne.access.trans.ProcedureTranslator.createStateme
> > nt
> > (ProcedureTranslator.java:160)
> >  at
> > org.objectstyle.cayenne.dba.sqlserver.SQLServerProcedureAction.perform
> > Action
> > (SQLServerProcedureAction.java :105)
> >  at org.objectstyle.cayenne.access.DataNodeQueryAction.runQuery(
> > DataNodeQueryAction.java:95)
> >  at org.objectstyle.cayenne.access.DataNode.performQueries
> > (DataNode.java
> > :321)
> >  ... 54 more
> >
> > using SQL Server, jtds 1.2, Cayenne M10.  Any thoughts please?
>
>

Re: Idle connection errors

Posted by Andrus Adamchik <an...@objectstyle.org>.
Some drivers support auto-reconnect parameter:

http://objectstyle.org/confluence/display/CAY/Reconnect

jTDS doesn't seem to support that. From the stack trace, you are  
using a DBCP connection pool. IIRC DBCP allows transparent reconnect  
with any driver. You'd have to check DBCP docs on that.

Andrus


On Apr 3, 2006, at 5:34 AM, Steve Wells wrote:
> Hi,
>
> If we try and run a query after the connection have been idle for  
> some time,
> many hours (sorry I don't exactly yet know how long) we get:
>
> Caused by: java.sql.SQLException: Invalid state, the Connection  
> object is
> closed.
>  at net.sourceforge.jtds.jdbc.ConnectionJDBC2.checkOpen 
> (ConnectionJDBC2.java
> :1305)
>  at net.sourceforge.jtds.jdbc.ConnectionJDBC2.prepareCall (
> ConnectionJDBC2.java:1941)
>  at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.prepareCall(
> DelegatingConnection.java:212)
>  at
> org.apache.tomcat.dbcp.dbcp.PoolingDataSource 
> $PoolGuardConnectionWrapper.prepareCall
> (PoolingDataSource.java :268)
>  at  
> org.objectstyle.cayenne.access.trans.ProcedureTranslator.createStateme 
> nt
> (ProcedureTranslator.java:160)
>  at
> org.objectstyle.cayenne.dba.sqlserver.SQLServerProcedureAction.perform 
> Action
> (SQLServerProcedureAction.java :105)
>  at org.objectstyle.cayenne.access.DataNodeQueryAction.runQuery(
> DataNodeQueryAction.java:95)
>  at org.objectstyle.cayenne.access.DataNode.performQueries 
> (DataNode.java
> :321)
>  ... 54 more
>
> using SQL Server, jtds 1.2, Cayenne M10.  Any thoughts please?