Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 16314 invoked from network); 19 Nov 2007 22:08:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Nov 2007 22:08:58 -0000 Received: (qmail 93184 invoked by uid 500); 19 Nov 2007 22:08:44 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 93115 invoked by uid 500); 19 Nov 2007 22:08:44 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Delivered-To: moderator for dev@commons.apache.org Received: (qmail 34245 invoked by uid 99); 19 Nov 2007 21:28:46 -0000 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C82AF3.1461F2BE" Subject: "Already closed." exception in org.apache.commons.dbcp.PoolableConnection Date: Mon, 19 Nov 2007 16:28:08 -0500 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: "Already closed." exception in org.apache.commons.dbcp.PoolableConnection Thread-Index: Acgq8xQN+nrjzxUESAW6sf/FBlMupA== From: To: X-OriginalArrivalTime: 19 Nov 2007 21:28:08.0807 (UTC) FILETIME=[146B8770:01C82AF3] X-Virus-Checked: Checked by ClamAV on apache.org ------_=_NextPart_001_01C82AF3.1461F2BE Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable To Whom It May Concern: =20 Why is it necessary to throw a new SQLException("Already closed") when the purpose of the close() method is to close the connection. Seems to me this Exception is not necessary. =20 In my code (Tomcat/DBCP/iBATIS) apparently iBATIS is trying to close an already closed connection( without checking ) and this causes the close() method to throw the exception. =20 Any design thoughts are greatly appreciated. =20 Thanks, =20 Jeff =20 /** * Returns me to my pool. */ public synchronized void close() throws SQLException { boolean isClosed =3D false; try { isClosed =3D isClosed(); } catch (SQLException e) { try { _pool.invalidateObject(this); // XXX should be guarded to happen at most once } catch (Exception ie) { // DO NOTHING the original exception will be rethrown } throw new SQLNestedException("Cannot close connection (isClosed check failed)", e); } if (isClosed) { try { _pool.invalidateObject(this); // XXX should be guarded to happen at most once } catch (Exception ie) { // DO NOTHING, "Already closed" exception thrown below } throw new SQLException("Already closed."); } else { try { _pool.returnObject(this); // XXX should be guarded to happen at most once } catch(SQLException e) { throw e; } catch(RuntimeException e) { throw e; } catch(Exception e) { throw new SQLNestedException("Cannot close connection (return to pool failed)", e); } } } =20 ------_=_NextPart_001_01C82AF3.1461F2BE--