tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: How to close open connections after application stop?
Date Mon, 23 Feb 2009 02:50:44 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Martin,

On 2/22/2009 10:26 AM, Martin Gainty wrote:
>     catch (SQLException sqlEx) 
>     {
>     try
>     {
>       resultset.close();
>       statement.close();
>       connection.close();
>      } 

It's kind of silly to call close() on all these resources in the
exception handles when you're just going to:

> finally
>     {
>    try
>    {
>       resultset.close();
>       statement.close();
>       connection.close();
>      } 
>     catch(java.sql.SQLException excp)
>    {
>     log.debug("Exception on resultset/statement/connection close message="=excp.getMessage());
>     }
>    } //end finally..

...close them all in the finally block. Also, each close() method should
be surrounded by try/catch blocks and appropriate log messages. Finally,
logging exception stack traces is always helpful.

- -chris

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

iEYEARECAAYFAkmiDwQACgkQ9CaO5/Lv0PBHmQCfcUww2dA6wQqlY/1PWpxUGA2b
XpsAn2Bg/V3AVSBWMDcFcax8A6DkUo50
=urPv
-----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