diff --git a/openjpa-integration/daytrader/pom.xml b/openjpa-integration/daytrader/pom.xml
index 7d888a608..14b5b6459 100644
--- a/openjpa-integration/daytrader/pom.xml
+++ b/openjpa-integration/daytrader/pom.xml
@@ -39,11 +39,11 @@
${project.basedir}${file.separator}..${file.separator}..${file.separator}openjpa-project${file.separator}checkstyle.xml${project.basedir}${file.separator}..${file.separator}..${file.separator}openjpa-project${file.separator}suppressions.xml2.2-SNAPSHOT
- 10
+ 105210000
- MaxActive=${dbcp.maxActive},MaxIdle=${dbcp.maxIdle},MinIdle=${dbcp.minIdle},MaxWait=${dbcp.maxWait}
+ MaxTotal=${dbcp.maxTotal},MaxIdle=${dbcp.maxIdle},MinIdle=${dbcp.minIdle},MaxWait=${dbcp.maxWait}
diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfiguration.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfiguration.java
index 34ee5ebf2..6808f460d 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfiguration.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfiguration.java
@@ -486,7 +486,7 @@ public interface JDBCConfiguration
* Create an instance of the {@link DriverDataSource} to use
* for creating a {@link DataSource} from a JDBC {@link Driver}.
*/
- DriverDataSource newDriverDataSourceInstance();
+ DataSource newDriverDataSourceInstance();
/**
* The plugin string for the {@link SchemaFactory} to use to provide
diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java
index 178c680a6..9fdb6dd3f 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java
@@ -36,7 +36,6 @@ import org.apache.openjpa.jdbc.kernel.UpdateManager;
import org.apache.openjpa.jdbc.meta.MappingDefaults;
import org.apache.openjpa.jdbc.meta.MappingRepository;
import org.apache.openjpa.jdbc.schema.DataSourceFactory;
-import org.apache.openjpa.jdbc.schema.DriverDataSource;
import org.apache.openjpa.jdbc.schema.SchemaFactory;
import org.apache.openjpa.jdbc.sql.DBDictionary;
import org.apache.openjpa.jdbc.sql.DBDictionaryFactory;
@@ -246,9 +245,8 @@ public class JDBCConfigurationImpl
driverDataSourcePlugin = addPlugin("jdbc.DriverDataSource", false);
aliases = new String[]{
- "auto", "org.apache.openjpa.jdbc.schema.AutoDriverDataSource",
"simple", "org.apache.openjpa.jdbc.schema.SimpleDriverDataSource",
- "dbcp", "org.apache.openjpa.jdbc.schema.DBCPDriverDataSource",
+ "dbcp", "org.apache.commons.dbcp2.BasicDataSource"
};
driverDataSourcePlugin.setAliases(aliases);
driverDataSourcePlugin.setDefault(aliases[0]);
@@ -688,9 +686,9 @@ public class JDBCConfigurationImpl
}
@Override
- public DriverDataSource newDriverDataSourceInstance() {
- return (DriverDataSource) driverDataSourcePlugin.
- instantiate(DriverDataSource.class, this);
+ public DataSource newDriverDataSourceInstance() {
+ return (DataSource) driverDataSourcePlugin.
+ instantiate(DataSource.class, this);
}
@Override
diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/AutoDriverDataSource.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/AutoDriverDataSource.java
deleted file mode 100644
index 90b828fbd..000000000
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/AutoDriverDataSource.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.openjpa.jdbc.schema;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Properties;
-
-/**
- * Automatic Commons DBCP pooling or Simple non-pooling driver data source.
- * If the commons-dbcp packages are on the class path, then they will be used,
- * else it will fall back to non-DBCP mode.
- */
-public class AutoDriverDataSource
- extends DBCPDriverDataSource {
-
- @Override
- public Connection getConnection(Properties props) throws SQLException {
- // if we're using managed transactions, or user specified a DBCP driver
- // or DBCP is not on the classpath, then use SimpleDriver
- if (conf == null || conf.isTransactionModeManaged() || conf.isConnectionFactoryModeManaged() ||
- !isDBCPLoaded(getClassLoader())) {
- return getSimpleConnection(props);
- } else {
- // use DBCPDriverDataSource
- return getDBCPConnection(props);
- }
- }
-}
diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
deleted file mode 100644
index c2d28e442..000000000
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.openjpa.jdbc.schema;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Properties;
-
-import javax.sql.DataSource;
-
-import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
-import org.apache.openjpa.lib.conf.Configurable;
-import org.apache.openjpa.lib.conf.Configuration;
-import org.apache.openjpa.lib.conf.Configurations;
-import org.apache.openjpa.lib.util.Closeable;
-
-/**
- * Commons DBCP basic pooling driver data source.
- * The commons-dbcp packages must be on the class path for this plugin to work,
- * as it WILL NOT fall back to non-DBCP mode if they are missing. For automatic
- * usage of Commons DBCP when available, use AutoDriverDataSource instead.
- */
-public class DBCPDriverDataSource
-extends SimpleDriverDataSource implements Configurable, Closeable {
-
- private static String DBCPPACKAGENAME = "org.apache.commons.dbcp2";
- private static String DBCPBASICDATASOURCENAME = "org.apache.commons.dbcp2.BasicDataSource";
- private static Class> _dbcpClass;
- private static Boolean _dbcpAvail;
- private static RuntimeException _dbcpEx;
-
- protected JDBCConfiguration conf;
- private DataSource _ds;
-
- @Override
- public Connection getConnection(Properties props) throws SQLException {
- return getDBCPConnection(props);
- }
-
- @Override
- public void close() throws SQLException {
- try {
- if (_ds != null) {
- if (isDBCPLoaded(getClassLoader())) {
- ((org.apache.commons.dbcp2.BasicDataSource)_dbcpClass.cast(_ds)).close();
- }
- }
- } catch (Exception e) {
- // no-op
- } catch (Throwable t) {
- // no-op
- } finally {
- _ds = null;
- }
- }
-
- protected Connection getDBCPConnection(Properties props) throws SQLException {
- Connection con = getDBCPDataSource(props).getConnection();
- if (con == null) {
- throw new SQLException(_eloc.get("dbcp-ds-null",
- DBCPBASICDATASOURCENAME, getConnectionDriverName(), getConnectionURL()).getMessage());
- }
- return con;
- }
-
- protected DataSource getDBCPDataSource(Properties props) {
- if (isDBCPLoaded(getClassLoader())) {
- if (_ds == null) {
- try {
- Properties dbcpProps = updateDBCPProperties(props);
- _ds = (DataSource) Configurations.newInstance(DBCPBASICDATASOURCENAME, conf,
- dbcpProps, getClassLoader());
- } catch (Exception e) {
- _dbcpEx = new RuntimeException(_eloc.get("driver-null", DBCPBASICDATASOURCENAME).getMessage(), e);
- }
- return _ds;
- } else {
- return _ds;
- }
- } else {
- // user choose DBCP, so fail if it isn't on the classpath
- if (_dbcpEx == null)
- _dbcpEx = new RuntimeException(_eloc.get("driver-null", DBCPBASICDATASOURCENAME).getMessage());
- throw _dbcpEx;
- }
- }
-
- /**
- * This method should not throw an exception, as it is called by
- * AutoDriverDataSource to determine if user already specified
- * to use Commons DBCP.
- * @return true if ConnectionDriverName contains org.apache.commons.dbcp2,
- * otherwise false
- */
- protected boolean isDBCPDataSource() {
- return (getConnectionDriverName() != null &&
- getConnectionDriverName().toLowerCase(Locale.ENGLISH).indexOf(DBCPPACKAGENAME) >= 0);
- }
-
- /**
- * This method should not throw an exception, as it is called by
- * AutoDriverDataSource to determine if it should use DBCP or not
- * based on if org.apache.commons.dbcp2.BasicDataSource can be loaded.
- * @return true if Commons DBCP was found on the classpath, otherwise false
- */
- static protected boolean isDBCPLoaded(ClassLoader cl) {
- if (Boolean.TRUE.equals(_dbcpAvail) && (_dbcpClass != null)) {
- return true;
- } else if (Boolean.FALSE.equals(_dbcpAvail)) {
- return false;
- } else {
- // first time checking, so try to load it
- try {
- _dbcpClass = Class.forName(DBCPBASICDATASOURCENAME, true, cl);
- _dbcpAvail = Boolean.TRUE;
- return true;
- } catch (Exception e) {
- _dbcpAvail = Boolean.FALSE;
- // save exception details for later instead of throwing here
- _dbcpEx = new RuntimeException(_eloc.get("driver-null", DBCPBASICDATASOURCENAME).getMessage(), e);
- }
- return _dbcpAvail.booleanValue();
- }
- }
-
- /**
- * Normalize properties for Commons DBCP. This should be done for every call from DataSourceFactory,
- * as we do not have a pre-configured Driver to reuse.
- * @param props
- * @return updated properties
- */
- private Properties updateDBCPProperties(Properties props) {
- Properties dbcpProps = mergeConnectionProperties(props);
-
- // only perform the following check for the first connection attempt (_driverClassName == null),
- // as multiple connections could be requested (like from SchemaTool) and isDBCPDriver() will be true
- if (isDBCPDataSource()) {
- String propDriver = hasProperty(dbcpProps, "driverClassName");
- if (propDriver == null || propDriver.trim().isEmpty()) {
- // if user specified DBCP for the connectionDriverName, then make sure they supplied a DriverClassName
- throw new RuntimeException(_eloc.get("connection-property-invalid", "DriverClassName",
- propDriver).getMessage());
- }
- propDriver = hasProperty(dbcpProps, "url");
- if (propDriver == null || propDriver.trim().isEmpty()) {
- // if user specified DBCP for the connectionDriverName, then make sure they supplied a Url
- throw new RuntimeException(_eloc.get("connection-property-invalid", "URL",
- propDriver).getMessage());
- }
- } else {
- // set Commons DBCP expected DriverClassName to the original connection driver name
- dbcpProps.setProperty(hasKey(dbcpProps, "driverClassName", "driverClassName"), getConnectionDriverName());
- // set Commons DBCP expected URL property
- dbcpProps.setProperty(hasKey(dbcpProps, "url", "url"), getConnectionURL());
- }
-
- // Commons DBCP requires non-Null username/password values in the connection properties
- if (hasKey(dbcpProps, "username") == null) {
- if (getConnectionUserName() != null)
- dbcpProps.setProperty("username", getConnectionUserName());
- else
- dbcpProps.setProperty("username", "");
- }
- // Commons DBCP requires non-Null username/password values in the connection properties
- if (hasKey(dbcpProps, "password") == null) {
- if (getConnectionPassword() != null)
- dbcpProps.setProperty("password", getConnectionPassword());
- else
- dbcpProps.setProperty("password", "");
- }
-
- // set some default properties for DBCP
- if (hasKey(dbcpProps, "maxIdle") == null) {
- dbcpProps.setProperty("maxIdle", "1");
- }
- if (hasKey(dbcpProps, "minIdle") == null) {
- dbcpProps.setProperty("minIdle", "0");
- }
- if (hasKey(dbcpProps, "maxActive") == null) {
- dbcpProps.setProperty("maxActive", "10");
- }
-
- return dbcpProps;
- }
-
- /**
- * Merge the passed in properties with a copy of the existing _connectionProperties
- * @param props
- * @return Merged properties
- */
- private Properties mergeConnectionProperties(final Properties props) {
- Properties mergedProps = new Properties();
- mergedProps.putAll(getConnectionProperties());
-
- // need to map "user" to "username" for Commons DBCP
- String uid = removeProperty(mergedProps, "user");
- if (uid != null) {
- mergedProps.setProperty("username", uid);
- }
-
- // now, merge in any passed in properties
- if (props != null && !props.isEmpty()) {
- for (Iterator