Re: where to close statement ?

From: Guillaume Rousse <Guillaume(dot)Rousse(at)univ-reunion(dot)fr>
To: Joseph Shraibman <jks(at)p1(dot)selectacast(dot)net>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: where to close statement ?
Date: 2000-04-18 18:40:00
Message-ID: 00041822430000.02798@agathe
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Le mar, 18 avr 2000, vous avez crit :
> 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.
so we have either :
finally {
try {
if (conn!=null) conn.close();
} catch (SQLException ignore) {}
}
or eventually :
inally {
try {
conn.close();
} catch (Exception ignore) {}
}
The second also deals with NullPointerException
--
Guillaume Rousse
Iremia - Universit de la Runion

Sleep doesn't exists. Just lack of cafeine.

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Joseph Shraibman 2000-04-18 18:41:39 Re: JDBC: Missing Classes?
Previous Message Joseph Shraibman 2000-04-18 18:28:16 Re: where to close statement ?