jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marti...@apache.org
Subject svn commit: r815272 - in /jackrabbit/sandbox/JCR-1456/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java test/java/org/apache/jackrabbit/core/util/db/ConnectionFactoryTest.java
Date Tue, 15 Sep 2009 11:12:28 GMT
Author: martijnh
Date: Tue Sep 15 11:12:27 2009
New Revision: 815272

URL: http://svn.apache.org/viewvc?rev=815272&view=rev
Log:
JCR-1456 Database connection pooling

Small improvement.

Modified:
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/util/db/ConnectionFactoryTest.java

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java?rev=815272&r1=815271&r2=815272&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java
(original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionFactory.java
Tue Sep 15 11:12:27 2009
@@ -43,7 +43,7 @@
  */
 public class ConnectionFactory {
 
-    private static Logger log = LoggerFactory.getLogger(ConnectionFactory.class);
+    private static final Logger log = LoggerFactory.getLogger(ConnectionFactory.class);
 
     /**
      * The lock to protect the registries. 
@@ -303,6 +303,8 @@
             return "select 1";
         } else if (url.contains("oracle")) {
             return "select 'validationQuery' from dual";
+        } else if (url.contains("h2")) {
+            return "select 1";
         }
         log.warn("Failed to guess validation query for URL " + url);
         return null;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/util/db/ConnectionFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/util/db/ConnectionFactoryTest.java?rev=815272&r1=815271&r2=815272&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/util/db/ConnectionFactoryTest.java
(original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/util/db/ConnectionFactoryTest.java
Tue Sep 15 11:12:27 2009
@@ -46,6 +46,8 @@
 
     private static final String ORACLE_URL = "jdbc:oracle:thin:@localhost:1521:xe";
 
+    private static final String H2_URL = "jdbc:h2:tcp://localhost/dbName";
+
      @Override
      public void setUp() {
          System.setProperty("derby.stream.error.file", "target/derby-connectionfactorytest.log");
@@ -80,6 +82,11 @@
         assertEquals("select 'validationQuery' from dual", ((BasicDataSource) ds1).getValidationQuery());
     }
 
+    public void testGuessValidationQuery_H2() throws Exception {
+        DataSource ds1 = ConnectionFactory.getDataSource(DRIVER, H2_URL, "user", "password");
+        assertEquals("select 1", ((BasicDataSource) ds1).getValidationQuery());
+    }
+
     public void testRegisterDataSources_defaultValues() throws Exception {
         BasicDataSource ds = registerAndGet(DERBY_URL, "overwrite");
         assertEquals(10, ds.getMaxActive());
@@ -139,7 +146,7 @@
         DataSourceConfig dsc = new DataSourceConfig();
         Properties props = new Properties();
         props.put(DataSourceConfig.LOGICAL_NAME, name);
-        props.put(DataSourceConfig.DRIVER, "org.apache.derby.jdbc.EmbeddedDriver");
+        props.put(DataSourceConfig.DRIVER, DRIVER);
         props.put(DataSourceConfig.URL, url);
         props.put(DataSourceConfig.DB_TYPE, "dbType");
         props.put(DataSourceConfig.MAX_POOL_SIZE, "10");



Mime
View raw message