changeset 8763:8179cca1796a

Upgrade to DBCP 2.1.1 DBCP 2 needs at least Java 7. We are no longer compatible with Java 6.
author Tom Gottfried <tom@intevation.de>
date Fri, 14 Aug 2015 18:24:04 +0200
parents 86da84a95fac
children d5917ff74d8a
files artifacts/pom-oracle.xml artifacts/pom.xml backend/pom-oracle.xml backend/pom.xml backend/src/main/java/org/dive4elements/river/backend/utils/DBCPConnectionProvider.java
diffstat 5 files changed, 22 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/pom-oracle.xml	Thu Aug 13 18:37:13 2015 +0200
+++ b/artifacts/pom-oracle.xml	Fri Aug 14 18:24:04 2015 +0200
@@ -21,8 +21,8 @@
           <artifactId>maven-compiler-plugin</artifactId>
           <version>2.0.2</version>
           <configuration>
-              <source>1.6</source>
-              <target>1.6</target>
+              <source>1.7</source>
+              <target>1.7</target>
           </configuration>
       </plugin>
       <plugin>
--- a/artifacts/pom.xml	Thu Aug 13 18:37:13 2015 +0200
+++ b/artifacts/pom.xml	Fri Aug 14 18:24:04 2015 +0200
@@ -21,8 +21,8 @@
           <artifactId>maven-compiler-plugin</artifactId>
           <version>2.0.2</version>
           <configuration>
-              <source>1.6</source>
-              <target>1.6</target>
+              <source>1.7</source>
+              <target>1.7</target>
           </configuration>
       </plugin>
       <plugin>
--- a/backend/pom-oracle.xml	Thu Aug 13 18:37:13 2015 +0200
+++ b/backend/pom-oracle.xml	Fri Aug 14 18:24:04 2015 +0200
@@ -21,8 +21,8 @@
         <artifactId>maven-compiler-plugin</artifactId>
         <version>2.0.2</version>
         <configuration>
-          <source>1.6</source>
-          <target>1.6</target>
+          <source>1.7</source>
+          <target>1.7</target>
         </configuration>
       </plugin>
       <plugin>
@@ -101,9 +101,9 @@
       <version>1.2.14</version>
     </dependency>
     <dependency>
-      <groupId>commons-dbcp</groupId>
-      <artifactId>commons-dbcp</artifactId>
-      <version>1.4</version>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-dbcp2</artifactId>
+      <version>2.1.1</version>
     </dependency>
     <dependency>
         <groupId>org.hibernatespatial</groupId>
--- a/backend/pom.xml	Thu Aug 13 18:37:13 2015 +0200
+++ b/backend/pom.xml	Fri Aug 14 18:24:04 2015 +0200
@@ -21,8 +21,8 @@
         <artifactId>maven-compiler-plugin</artifactId>
         <version>2.0.2</version>
         <configuration>
-          <source>1.6</source>
-          <target>1.6</target>
+          <source>1.7</source>
+          <target>1.7</target>
         </configuration>
       </plugin>
       <plugin>
@@ -101,9 +101,9 @@
       <version>1.2.14</version>
     </dependency>
     <dependency>
-      <groupId>commons-dbcp</groupId>
-      <artifactId>commons-dbcp</artifactId>
-      <version>1.4</version>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-dbcp2</artifactId>
+      <version>2.1.1</version>
     </dependency>
     <dependency>
       <groupId>postgresql</groupId>
--- a/backend/src/main/java/org/dive4elements/river/backend/utils/DBCPConnectionProvider.java	Thu Aug 13 18:37:13 2015 +0200
+++ b/backend/src/main/java/org/dive4elements/river/backend/utils/DBCPConnectionProvider.java	Fri Aug 14 18:24:04 2015 +0200
@@ -29,11 +29,10 @@
 import java.util.Iterator;
 import java.util.Properties;
 import java.util.Map;
-import java.util.Collections;
-import java.util.StringTokenizer;
+import java.util.Arrays;
 
-import org.apache.commons.dbcp.BasicDataSource;
-import org.apache.commons.dbcp.BasicDataSourceFactory;
+import org.apache.commons.dbcp2.BasicDataSource;
+import org.apache.commons.dbcp2.BasicDataSourceFactory;
 
 import org.apache.log4j.Logger;
 
@@ -208,8 +207,8 @@
             // by the BasicDataSourceFactory if you set it as a dbcpProperty
             String connectionInitSqls = props.getProperty("connectionInitSqls");
             if (connectionInitSqls != null) {
-                StringTokenizer tokenizer = new StringTokenizer(connectionInitSqls, ";");
-                ds.setConnectionInitSqls(Collections.list(tokenizer));
+                String[] statements = connectionInitSqls.split(";");
+                ds.setConnectionInitSqls(Arrays.asList(statements));
             }
 
             String validationQuery = props.getProperty("validationQuery");
@@ -220,7 +219,7 @@
             String maxWait = props.getProperty("maxWait");
             if (maxWait != null) {
                 try {
-                    ds.setMaxWait(Integer.parseInt(maxWait));
+                    ds.setMaxWaitMillis(Integer.parseInt(maxWait));
                 }
                 catch (NumberFormatException nfe) {
                     log.error(
@@ -256,8 +255,8 @@
         log.trace("Connection pool parameters:");
         log.trace("_ active connections: " + ds.getNumActive());
         log.trace("_ idle connections: " + ds.getNumIdle());
-        log.trace("_ max active: " + ds.getMaxActive());
-        if (ds.getNumActive() == ds.getMaxActive()) {
+        log.trace("_ max active: " + ds.getMaxTotal());
+        if (ds.getNumActive() == ds.getMaxTotal()) {
             log.warn("Maximum number of database connections in pool in use!");
         }
         Connection conn = ds.getConnection();

http://dive4elements.wald.intevation.org