You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by sc...@apache.org on 2012/11/30 11:17:06 UTC
svn commit: r1415576 - in /jackrabbit/branches/2.4: ./
jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java
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;
}