Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-interfaces by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group