I agree with Paul. Believe it or not, under extreme load I've seen
problems with the Oracle driver (classes12.zip) unless you closed
everything you could - as soon as you could - in the reverse order.
Always good practice.
David
--
Paul Austin wrote:
> Jim,
>
> The reason that you should close all the resources in reverse order is to
> insure that all resources are cleaned up. There are bugs in some drivers
> that do not perform correct clean up if you fail to close the result set and
> statement first. You should also catch any exceptions from the first two
> calls. You can use the following pattern which will ignore the null pointer
> exceptions as this is the worst case and will be handled by the catch clause
> I have included, under normal conditions this will be slightly faster (not
> much).
>
> Paul
>
> finally {
> try {
> resultSet.close();
> } catch (Exception e) {
> }
> try {
> statement.close();
> } catch (Exception e) {
> }
> try {
> connection.close();
> } catch (Exception e) {
> }
> }
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Jim Robinson
> Sent: 09 July 2001 20:43
> To: [EMAIL PROTECTED]
> Subject: [JBoss-user] Closing connections, etc
>
>
>
> Hi, in most examples of using JDBC connections a
> pattern like the following pattern is used to clean up
> resources
>
> finally
> {
> if(resultSet != null) resultSet.close();
> if(statement != null) statement.close();
> if(connection != null) connection.close();
> }
>
> Shouldn't closing the connection also close the
> statement and result set, making the first 2 lines
> redundant? What is the proper pattern?
>
> Thanks,
>
> Jim
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
>
--
-----------------------------------------------------------------------
David Ward [EMAIL PROTECTED]
Senior Software Engineer http://www.dotech.com
Distributed Object Technologies, Inc. 716-381-8320 (phone)
500 Linden Oaks, Rochester, NY 14625 716-381-0598 (fax)
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user