Barry I changed the code to this:

public static void closeResources(ResultSet rs) throws
AardvarkResourceException {
        Statement s = null;
        Connection c = null;

        try {
            s = rs.getStatement();
            if (s != null) {
                c = s.getConnection();
            }
            rs.close();
        }
        catch (SQLException e) {
            throw new AardvarkResourceException("Error closing resources
associated with ResultSet", e);
        }
        finally
        {
            if(null != rs) try { rs.close(); }
                catch (SQLException sqle)
                { sqle.printStackTrace(); }

            if(null != s) try { s.close(); } catch (SQLException sqle)
                { sqle.printStackTrace(); }

            if(null != c)
                try { c.close(); } catch (SQLException sqle)
                { sqle.printStackTrace(); }
        }
    }

No luck using the DataSoruceConnectionFactory though. I am using 6.0.18.

On Fri, Oct 30, 2009 at 4:28 PM, Propes, Barry L <barry.l.pro...@citi.com>wrote:

> Where does it close the connection? Looks like it gets it, but the close
> part is commented out. The rs gets closed, but the connection gets recycled.
> Theoretically.
>
> Seems like you put a finally block down there to try catching/closing the
> wayward connection.
>
>
> -----Original Message-----
> From: Josh Gooding [mailto:josh.good...@gmail.com]
> Sent: Friday, October 30, 2009 1:43 PM
> To: Tomcat Users List
> Subject: Re: ConnectionPool question
>
> I also found this tid bit lying around.  It get's a connection, but doesn't
> close the statement.
>
>    public static void closeResources(ResultSet rs) throws
> AardvarkResourceException {
>        try {
>            Statement s = rs.getStatement();
>            if (s != null) { // ResultSets produced by metadata queries do
> not have associated statements
>                Connection c = s.getConnection();
>                //s.close();
>                //c.close();
>                ConnectionPool.recycleConnection(c);
>            }
>            rs.close();
>        } catch (SQLException e) {
>            throw new AardvarkResourceException("Error closing resources
> associated with ResultSet", e);
>        }
>    }
>
> It still doesn't close the statement, but closes the connection leaving the
> statement hanging.... I'll fix and make sure to use it.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>

Reply via email to