But I need to re-trigger the operation (such as an INSERT statement), and also 
to remove the dead connection from the pool or reconnect it.


--- On Sat, 12/6/08, Ken Bowen <[EMAIL PROTECTED]> wrote:

> From: Ken Bowen <[EMAIL PROTECTED]>
> Subject: Re: configure JNDI to avoid error "Last packet sent to the server 
> was xxxxx ms ago"
> To: "Tomcat Users List" <users@tomcat.apache.org>
> Date: Saturday, December 6, 2008, 4:39 PM
> Can't you deal with the connection being closed in your
> finally block  
> by using this code:
> 
> if (connection != null && !connection.isClosed())
> connection.close();
> 
> 
> On Dec 6, 2008, at 6:50 PM, [EMAIL PROTECTED]
> wrote:
> 
> > The second message -- connection has already been
> closed -- most  
> > likely arises from my code structure, which is:
> >
> > Connection connection = null;
> > PreparedStatement prepStmt = null;
> > try
> > {
> >   Connection connection = getConnection();
> >   PreparedStatement prepStmt =
> connection.prepareStatement(...);
> >   ...
> > }
> > finally
> > {
> >   if (prepStmt != null) prepStmt.close();
> >   if (connection != null) connection.close();
> > }
> >
> > The call to getConnection() in the try block gets a
> connection from  
> > the pool.  But the server has closed this connection. 
> Therefore the  
> > call to prepareStatement throws a SQLException which
> is the last  
> > packet exception.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to