tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: ConnectionPool question
Date Sat, 07 Nov 2009 02:07:48 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Josh,

On 11/5/2009 8:51 PM, Josh Gooding wrote:
> So my ConnectionPool class is here
> http://www.realissuesforrealpeople.com/ConnectionPool.java

The overloaded recycleConnection methods are a bit strange...

Also, this class is written as a ServletContextListener but it doesn't
ever actually react to ServletContext events. The methods are static...
you don't need to do anything except call them directly: no need for the
class to be any kind of listener or anything.

> and my DatabaseTransaction class is here
> http://www.realissuesforrealpeople.com/DatabaseTransaction.java

I think you're doing more than necessary.

		finally
		{
			if (rs != null)
			ConnectionPool.recycleConnection(rs);
			if (pstmntCommand != null)
			ConnectionPool.recycleConnection(pstmntCommand);
			if (!conn.isClosed())
				conn.close();
		}

If you have code like this, you don't need a separate method to recycle
each object: just call close on it directly.

Also, all your recycleConnection methods (though they don't all take
Connection objects) close everything: ResultSet, Statement, and
Connection. Then, the 'finally' block above re-closes everything over
again (twice!).

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkr01nMACgkQ9CaO5/Lv0PDZmgCgtY2+TdYs4UFFxyWTTNMbpApF
9a0AoIEmkVGifK0KXh0IzoB4mEFv//m7
=ErkB
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message