RE: where to close statement ?

From: Peter Mount <petermount(at)it(dot)maidstone(dot)gov(dot)uk>
To: "'Joseph Shraibman'" <jks(at)p1(dot)selectacast(dot)net>, Peter Mount <petermount(at)it(dot)maidstone(dot)gov(dot)uk>
Cc: "'Guillaume Rousse'" <Guillaume(dot)Rousse(at)univ-reunion(dot)fr>, pgsql-interfaces(at)postgresql(dot)org
Subject: RE: where to close statement ?
Date: 2000-04-19 06:47:47
Message-ID: 1B3D5E532D18D311861A00600865478C70C4C8@exchange1.nt.maidstone.gov.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

I wrap the closes within the finally() block because of this:

try {
... code ...
} catch(SQLException e) {
... handle exception here ...
} finally {
try {
if(rs!=null) rs.close();
if(st!=null) st.close();
} catch(SQLException e1) {}
}

Peter

--
Peter Mount
Enterprise Support
Maidstone Borough Council
Any views stated are my own, and not those of Maidstone Borough Council.

-----Original Message-----
From: Joseph Shraibman [mailto:jks(at)p1(dot)selectacast(dot)net]
Sent: Tuesday, April 18, 2000 7:28 PM
To: Peter Mount
Cc: 'Guillaume Rousse'; pgsql-interfaces(at)postgresql(dot)org
Subject: Re: [INTERFACES] where to close statement ?

Peter Mount wrote:

> Ah, forgot that bit. I put them under finally as it always gets run,
> although you have to wrap them in a try{} win finally if the parent
> method doesn't throw SQLException.
>
> Peter
>

The problem with that is that close() itself can throw a SQLException so
you have to wrap it twice.

Browse pgsql-interfaces by date

  From Date Subject
Next Message Peter Mount 2000-04-19 06:49:26 RE: JDBC: Missing Classes?
Previous Message Peter Mount 2000-04-19 06:45:15 RE: psql & java