Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 0FEBB634C34 for ; Fri, 19 Jun 2009 07:37:20 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 49125-09 for ; Fri, 19 Jun 2009 07:37:18 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from kerberos.fcon.no (165.84-49-232.nextgentel.com [84.49.232.165]) by mail.postgresql.org (Postfix) with ESMTP id 05DC6632F4A for ; Fri, 19 Jun 2009 07:37:18 -0300 (ADT) Received: from fcon.no (localhost [127.0.0.1]) by kerberos.fcon.no (Postfix) with ESMTP id D15B3370A6 for ; Fri, 19 Jun 2009 12:37:15 +0200 (CEST) Received: from 134.32.140.234 (SquirrelMail authenticated user tfinneid) by fcon.no with HTTP; Fri, 19 Jun 2009 12:37:15 +0200 (CEST) Message-ID: <54338.134.32.140.234.1245407835.squirrel@fcon.no> Date: Fri, 19 Jun 2009 12:37:15 +0200 (CEST) Subject: Connection exceptions From: "Thomas Finneid" To: pgsql-jdbc@postgresql.org User-Agent: SquirrelMail/1.4.9a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.1 tagged_above=0 required=5 tests=RDNS_DYNAMIC=0.1 X-Spam-Level: X-Archive-Number: 200906/71 X-Sequence-Number: 19735 Hi Anybody got any best practices for how do I deal with connection problems in JDBC? I am working on a storage tier where the DAOs can encounter faulty database connections, either closed or other-wise non functional connections. The database connection is pooled with Commons DBCP, and my initial thought was to reinitialise or restart the pool, if there were any problems. But then I realised that the pool can test connections before giving it to the application, so now moving into muddy waters because I dont know much about these details. My original code is something like: while (retry > 0) { Connection con = ds.getConnection if (con==null) { dsFactory.restartDS(); retry--: continue; } try { dao.execute(); } catch (SQLExceptions e) { con.close(); } Not knowing the details of how the DBCP or the DataSource works in these situations, make this code prone to problems. I will continue to investigate, but any feedback about what to look at is appreciated. regards thomas