From user-return-19688-apmail-commons-user-archive=commons.apache.org@commons.apache.org Tue Aug 07 08:34:01 2007 Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 21922 invoked from network); 7 Aug 2007 08:34:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Aug 2007 08:34:00 -0000 Received: (qmail 34309 invoked by uid 500); 7 Aug 2007 08:33:54 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 34253 invoked by uid 500); 7 Aug 2007 08:33:54 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 34244 invoked by uid 99); 7 Aug 2007 08:33:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Aug 2007 01:33:54 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [194.180.18.131] (HELO lucy.ppimedia.de) (194.180.18.131) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Aug 2007 08:33:41 +0000 Received: by lucy.ppimedia.de (Postfix, from userid 501) id B112E4640E0; Tue, 7 Aug 2007 10:33:27 +0200 (CEST) Received: from max.ppinet.de (max.ppinet.de [172.31.43.64]) by lucy.ppimedia.de (Postfix) with ESMTP id 7F67E4640DC for ; Tue, 7 Aug 2007 10:33:27 +0200 (CEST) Received: by max.ppinet.de with Internet Mail Service (5.5.2653.19) id ; Tue, 7 Aug 2007 10:33:28 +0200 Message-ID: <6D48B8403D926449BDE8440EC7EEC46D038329F2@max.ppinet.de> From: Oliver.Matz@ppimedia.de To: user@commons.apache.org Subject: dbcp: InstanceKeyDataSourcegetConnection, exception during setup Defaults() Date: Tue, 7 Aug 2007 10:33:22 +0200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on lucy.ppimedia.de X-Spam-Level: X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-2.6 required=5.0 tests=ALL_TRUSTED,NO_REAL_NAME autolearn=unavailable version=3.0.0 Hello, my webapp uses Sybase jConnect2 5.5, commons-dbcp 1.2.1, spring framework 2.0.1. My webapp runs fine, but after a few days the following occurs in InstanceKeyDataSource.getConnection: com.sybase.jdbc2.jdbc.SybConnectionDeadException: JZ0C0 (stacktrace see below). Probably this is because of sybase timeouts and acceptable behaviour. However, I have the impression that the connection is not properly released. When this has happend a few times, the pool seems to get exhausted: I get "org.apache.commons.dbcp.SQLNestedException: Could not retrieve connection info from pool", see stacktrace below. After a restart, everthing is fine. I have analyzed the problem and I think there is a bug in the last lines of org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(Stri ng username, String password) It says: ------- Connection con = info.getPooledConnection().getConnection(); setupDefaults(con, username); con.clearWarnings(); return con; ------- I my case, the exception happens in the second line of this snippet, so no code gets the chance close con and release the resources. I propose to change it to: ------- Connection con = info.getPooledConnection().getConnection(); try { setupDefaults(con, username); con.clearWarnings(); return con; } catch (Exception exc) { try { con.close(); } catch (Exception exc) { getLogWriter().println("ignoring exception during close: " + exc); // uncertain here. } throw exc; } ------- What do you think? Best regards and thank you for your effort, Olli The two exceptions follow. ----------------------------- java.sql.SQLException: JZ006: Caught IOException: com.sybase.jdbc2.jdbc.SybConnectionDeadException: JZ0C0: Connection is already closed. at com.sybase.jdbc2.jdbc.ErrorMessage.raiseErrorCheckDead(ErrorMessage.java:709 ) at com.sybase.jdbc2.tds.Tds.handleIOE(Tds.java:3071) at com.sybase.jdbc2.tds.Tds.cancel(Tds.java:1412) at com.sybase.jdbc2.tds.Tds.cancel(Tds.java:1341) at com.sybase.jdbc2.jdbc.SybStatement.doCancel(SybStatement.java:564) at com.sybase.jdbc2.jdbc.SybStatement.updateLoop(SybStatement.java:1645) at com.sybase.jdbc2.jdbc.SybStatement.executeUpdate(SybStatement.java:1598) at com.sybase.jdbc2.jdbc.SybPreparedStatement.executeUpdate(SybPreparedStatemen t.java:89) at com.sybase.jdbc2.tds.Tds.setOption(Tds.java:1111) at com.sybase.jdbc2.jdbc.SybConnection.setAutoCommit(SybConnection.java:634) at org.apache.commons.dbcp.cpdsadapter.ConnectionImpl.setAutoCommit(ConnectionI mpl.java:325) at org.apache.commons.dbcp.datasources.SharedPoolDataSource.setupDefaults(Share dPoolDataSource.java:212) at org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(Inst anceKeyDataSource.java:654) at org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(Inst anceKeyDataSource.java:615) at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSour ceUtils.java:112) at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSource Utils.java:77) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:513) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:581) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:610) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:614) at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java: 656) at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java: 668) at org.springframework.jdbc.core.JdbcTemplate.queryForInt(JdbcTemplate.java:694 ) -------------------------------- Servlet.service() for servlet jobaccess threw exception : org.apache.commons.dbcp.SQLNestedException: Could not retrieve connection info from pool at org.apache.commons.dbcp.datasources.SharedPoolDataSource.getPooledConnection AndInfo(SharedPoolDataSource.java:169) at org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(Inst anceKeyDataSource.java:631) at org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(Inst anceKeyDataSource.java:615) at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSour ceUtils.java:112) at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSource Utils.java:77) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:513) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:581) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:610) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:614) -- Oliver Matz Development ppi Media GmbH Deliusstrasse 10 24114 Kiel, Germany Geschäftsführer: Norbert Ohl, Martin Ruhle Amtsgericht Hamburg, HRB 84308 phone +49 (0) 431-53 53 -422 fax +49 (0) 431-53 53 -222 www.ppimedia.de Explore your printnet! --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org