jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sch...@apache.org
Subject svn commit: r1415574 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java
Date Fri, 30 Nov 2012 10:15:37 GMT
Author: schans
Date: Fri Nov 30 10:15:36 2012
New Revision: 1415574

URL: http://svn.apache.org/viewvc?rev=1415574&view=rev
Log:
JCR-3445: Make sure setValidationQueryTimeout is not called on non complient jdbc drivers
(eg postgresql)

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java?rev=1415574&r1=1415573&r2=1415574&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java
Fri Nov 30 10:15:36 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;
     }
 



Mime
View raw message