Especially as JDBC says: "Calling the method close on a Connection object that is already closed is a no-op."
I think this came up before though, so I suspect there's a good reason. Hen On Nov 19, 2007 4:28 PM, <[EMAIL PROTECTED]> wrote: > To Whom It May Concern: > > 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. > > 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. > > Any design thoughts are greatly appreciated. > > Thanks, > > Jeff > > /** > * Returns me to my pool. > */ > public synchronized void close() throws SQLException { > boolean isClosed = false; > try { > isClosed = 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); > } > } > } > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]