Return-Path: X-Original-To: apmail-jackrabbit-commits-archive@www.apache.org Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BF3B1DC5F for ; Fri, 30 Nov 2012 10:17:30 +0000 (UTC) Received: (qmail 26316 invoked by uid 500); 30 Nov 2012 10:17:30 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 26226 invoked by uid 500); 30 Nov 2012 10:17:30 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 26210 invoked by uid 99); 30 Nov 2012 10:17:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Nov 2012 10:17:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Nov 2012 10:17:27 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5D4BD2388A40; Fri, 30 Nov 2012 10:17:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1415576 - in /jackrabbit/branches/2.4: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java Date: Fri, 30 Nov 2012 10:17:06 -0000 To: commits@jackrabbit.apache.org From: schans@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121130101706.5D4BD2388A40@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: schans Date: Fri Nov 30 10:17:05 2012 New Revision: 1415576 URL: http://svn.apache.org/viewvc?rev=1415576&view=rev Log: JCR-3445: Make sure setValidationQueryTimeout is not called on non complient jdbc drivers (eg postgresql) Modified: jackrabbit/branches/2.4/ (props changed) jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java Propchange: jackrabbit/branches/2.4/ ------------------------------------------------------------------------------ Merged /jackrabbit/trunk:r1415574 Modified: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java?rev=1415576&r1=1415575&r2=1415576&view=diff ============================================================================== --- jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java (original) +++ jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java Fri Nov 30 10:17:05 2012 @@ -17,6 +17,7 @@ package org.apache.jackrabbit.core.util.db; import java.sql.Connection; +import java.sql.Driver; import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; @@ -316,17 +317,23 @@ public final class ConnectionFactory { created.add(ds); if (driverClass != null) { + Driver instance = null; try { // Workaround for Apache Derby: // The JDBC specification recommends the Class.forName // method without the .newInstance() method call, // but it is required after a Derby 'shutdown' - driverClass.newInstance(); + instance = (Driver) driverClass.newInstance(); } catch (Throwable e) { // Ignore exceptions as there's no requirement for // a JDBC driver class to have a public default constructor } - + if (instance != null) { + if (instance.jdbcCompliant()) { + // JCR-3445 At the moment the PostgreSQL isn't compliant because it doesn't implement this method... + ds.setValidationQueryTimeout(3); + } + } ds.setDriverClassName(driverClass.getName()); } @@ -344,12 +351,6 @@ public final class ConnectionFactory { ds.setAccessToUnderlyingConnectionAllowed(true); ds.setPoolPreparedStatements(true); ds.setMaxOpenPreparedStatements(-1); // unlimited - try { - // JCR-3445 At the moment the PostgreSQL driver doesn't implement this method... - ds.setValidationQueryTimeout(3); - } catch (Exception e) { - log.info("Unable to set the validation query timeout on the datasource: " + e.getMessage()); - } return ds; }