Received: from iremia.univ-reunion.fr (iremia.univ-reunion.fr [194.199.73.10]) by hub.org (8.9.3/8.9.3) with ESMTP id OAA76082 for ; Tue, 18 Apr 2000 14:36:50 -0400 (EDT) (envelope-from Guillaume.Rousse@univ-reunion.fr) Received: from agathe (agathe.univ.run [10.10.2.24]) by iremia.univ-reunion.fr (8.9.1a/jtpda-5.3.1/jlo(98)) with SMTP id WAA18035 ; Tue, 18 Apr 2000 22:36:09 +0400 (GMT+4) From: Guillaume Rousse Organization: Université de la Réunion To: Joseph Shraibman Subject: Re: where to close statement ? Date: Tue, 18 Apr 2000 22:40:00 +0400 X-Mailer: KMail [version 1.0.28] Content-Type: text/plain References: <1B3D5E532D18D311861A00600865478C70C4BD@exchange1.nt.maidstone.gov.uk> <38FCA940.C3D36528@selectacast.net> In-Reply-To: <38FCA940.C3D36528@selectacast.net> Cc: pgsql-interfaces@postgresql.org MIME-Version: 1.0 Message-Id: <00041822430000.02798@agathe> Content-Transfer-Encoding: 8bit X-Archive-Number: 200004/130 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 Réunion Sleep doesn't exists. Just lack of cafeine.