You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2013/01/29 14:11:05 UTC
svn commit: r1439882 [1/2] - in
/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH: ./
src/java/org/apache/commons/dbcp/
src/java/org/apache/commons/dbcp/cpdsadapter/
src/java/org/apache/commons/dbcp/datasources/
src/test/org/apache/commons/dbcp/ src/test...
Author: markt
Date: Tue Jan 29 13:11:04 2013
New Revision: 1439882
URL: http://svn.apache.org/viewvc?rev=1439882&view=rev
Log:
First pass at getting DBCP to compile with Java 7 to keep Gump happy. Whether or not we create a DBCP_1.5 branch and actually release this is a different question. The aim is to continue to be able to release 1.4 from this branch with Java 6.
I need to check this in before I start testing the 1.4 build otherwise my changes will be modified/lost as I test the build.
Modified:
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/build.xml
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/BasicDataSource.java
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingCallableStatement.java
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingConnection.java
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingDatabaseMetaData.java
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingResultSet.java
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingStatement.java
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/PoolingDataSource.java
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/PoolingDriver.java
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/cpdsadapter/DriverAdapterCPDS.java
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/datasources/InstanceKeyDataSource.java
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterCallableStatement.java
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterConnection.java
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterDatabaseMetaData.java
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterDriver.java
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterResultSet.java
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterStatement.java
commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/datasources/ConnectionPoolDataSourceProxy.java
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/build.xml
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/build.xml?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/build.xml (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/build.xml Tue Jan 29 13:11:04 2013
@@ -73,6 +73,7 @@
<available property="jndi.present" classname="javax.naming.Context"/>
<available property="jdbc4.present" classname="java.sql.Wrapper"/>
+ <available property="jdbc41.present" classname="javax.sql.rowset.RowSetFactory"/>
</target>
<target name="check_jar">
@@ -128,7 +129,7 @@
</target>
<target name="prepare-nojdbc4" depends="init" unless="jdbc4.present">
- <echo message="Commenting out the jdbc4 additional methods since JDBC 4 was not detected."/>
+ <echo message="Commenting out the JDBC 4 and JDBC 4.1 additional methods since JDBC 4 was not detected."/>
<property name="src.dir" value="${build.dir}/src"/>
<property name="src.java.dir" value="${src.dir}/java"/>
<property name="src.test.dir" value="${src.dir}/test"/>
@@ -148,15 +149,36 @@
<replace dir="${src.dir}" token="/* JDBC_4_ANT_KEY_END */" value="*/"/>
</target>
- <target name="prepare-jdbc4" depends="init" if="jdbc4.present">
- <echo message="JDBC 4 was detected."/>
+ <target name="prepare-jdbc4" depends="init" if="jdbc4.present" unless="jdbc41.present">
+ <echo message="JDBC 4 was detected. Commenting out the JDBC 4.1 additional methods."/>
<property name="src.dir" value="${basedir}/src"/>
<property name="src.java.dir" value="${src.dir}/java"/>
<property name="src.test.dir" value="${src.dir}/test"/>
<property name="javac.source" value="1.5" />
+
+ <mkdir dir="${src.dir}"/>
+ <copy todir="${src.dir}" filtering="yes">
+ <fileset dir="${basedir}/src" defaultexcludes="no">
+ <include name="**/*.java"/>
+ <include name="**/*.xml"/>
+ <include name="**/*.properties"/>
+ <include name="**/*.jocl"/>
+ <include name="**/package.html"/>
+ </fileset>
+ </copy>
+ <replace dir="${src.dir}" token="/* JDBC_4_1_ANT_KEY_BEGIN */" value="/*"/>
+ <replace dir="${src.dir}" token="/* JDBC_4_1_ANT_KEY_END */" value="*/"/>
+ </target>
+
+ <target name="prepare-jdbc41" depends="init" if="jdbc41.present">
+ <echo message="JDBC 4.1 was detected."/>
+ <property name="src.dir" value="${basedir}/src"/>
+ <property name="src.java.dir" value="${src.dir}/java"/>
+ <property name="src.test.dir" value="${src.dir}/test"/>
+ <property name="javac.source" value="1.5" />
</target>
- <target name="prepare" depends="init,prepare-nojdbc4,prepare-jdbc4"/>
+ <target name="prepare" depends="init,prepare-nojdbc4,prepare-jdbc4,prepare-jdbc41"/>
<target name="javadoc" depends="prepare" description="generates javadocs">
<mkdir dir="${javadoc.dir}"/>
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/BasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/BasicDataSource.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/BasicDataSource.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/BasicDataSource.java Tue Jan 29 13:11:04 2013
@@ -5,9 +5,9 @@
* 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.
@@ -24,10 +24,13 @@ import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Collections;
+import java.util.logging.Logger;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+
import javax.sql.DataSource;
import org.apache.commons.pool.KeyedObjectPoolFactory;
@@ -41,7 +44,7 @@ import org.apache.commons.pool.impl.Gene
* configured via JavaBeans properties. This is not the only way to
* combine the <em>commons-dbcp</em> and <em>commons-pool</em> packages,
* but provides a "one stop shopping" solution for basic requirements.</p>
- *
+ *
* <p>Users extending this class should take care to use appropriate accessors
* rather than accessing protected fields directly to ensure thread-safety.</p>
*
@@ -51,7 +54,7 @@ import org.apache.commons.pool.impl.Gene
* @version $Revision$ $Date$
*/
public class BasicDataSource implements DataSource {
-
+
static {
// Attempt to prevent deadlocks - see DBCP - 272
DriverManager.getDrivers();
@@ -66,7 +69,7 @@ public class BasicDataSource implements
/**
* Returns the default auto-commit property.
- *
+ *
* @return true if default auto-commit is enabled
*/
public boolean getDefaultAutoCommit() {
@@ -81,7 +84,7 @@ public class BasicDataSource implements
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param defaultAutoCommit default auto-commit value
*/
public void setDefaultAutoCommit(boolean defaultAutoCommit) {
@@ -97,7 +100,7 @@ public class BasicDataSource implements
/**
* Returns the default readOnly property.
- *
+ *
* @return true if connections are readOnly by default
*/
public boolean getDefaultReadOnly() {
@@ -115,7 +118,7 @@ public class BasicDataSource implements
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param defaultReadOnly default read-only value
*/
public void setDefaultReadOnly(boolean defaultReadOnly) {
@@ -131,7 +134,7 @@ public class BasicDataSource implements
/**
* Returns the default transaction isolation state of returned connections.
- *
+ *
* @return the default value for transaction isolation state
* @see Connection#getTransactionIsolation
*/
@@ -147,7 +150,7 @@ public class BasicDataSource implements
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param defaultTransactionIsolation the default transaction isolation
* state
* @see Connection#getTransactionIsolation
@@ -165,7 +168,7 @@ public class BasicDataSource implements
/**
* Returns the default catalog.
- *
+ *
* @return the default catalog
*/
public String getDefaultCatalog() {
@@ -179,7 +182,7 @@ public class BasicDataSource implements
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param defaultCatalog the default catalog
*/
public void setDefaultCatalog(String defaultCatalog) {
@@ -192,7 +195,7 @@ public class BasicDataSource implements
this.restartNeeded = true;
}
-
+
/**
* The fully qualified Java class name of the JDBC driver to be used.
*/
@@ -200,7 +203,7 @@ public class BasicDataSource implements
/**
* Returns the jdbc driver class name.
- *
+ *
* @return the jdbc driver class name
*/
public synchronized String getDriverClassName() {
@@ -214,7 +217,7 @@ public class BasicDataSource implements
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param driverClassName the class name of the jdbc driver
*/
public synchronized void setDriverClassName(String driverClassName) {
@@ -234,7 +237,7 @@ public class BasicDataSource implements
* used.
*/
protected ClassLoader driverClassLoader = null;
-
+
/**
* Returns the class loader specified for loading the JDBC driver. Returns
* <code>null</code> if no class loader has been explicitly specified.
@@ -250,7 +253,7 @@ public class BasicDataSource implements
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param driverClassLoader the class loader with which to load the JDBC
* driver
*/
@@ -259,7 +262,7 @@ public class BasicDataSource implements
this.driverClassLoader = driverClassLoader;
this.restartNeeded = true;
}
-
+
/**
* True means that borrowObject returns the most recently used ("last in")
* connection in the pool (if there are idle connections available). False
@@ -269,12 +272,12 @@ public class BasicDataSource implements
private boolean lifo = GenericObjectPool.DEFAULT_LIFO;
/**
- * Returns the LIFO property.
- *
+ * Returns the LIFO property.
+ *
* @return true if connection pool behaves as a LIFO queue.
- *
- * @see #lifo
- */
+ *
+ * @see #lifo
+ */
public synchronized boolean getLifo() {
return this.lifo;
}
@@ -282,17 +285,17 @@ public class BasicDataSource implements
/**
* Sets the LIFO property. True means the pool behaves as a LIFO queue;
* false means FIFO.
- *
+ *
* @param lifo the new value for the LIFO property
- *
- */
+ *
+ */
public synchronized void setLifo(boolean lifo) {
- this.lifo = lifo;
+ this.lifo = lifo;
if (connectionPool != null) {
connectionPool.setLifo(lifo);
}
}
-
+
/**
* The maximum number of active connections that can be allocated from
* this pool at the same time, or negative for no limit.
@@ -304,7 +307,7 @@ public class BasicDataSource implements
* allocated at the same time.
* </p>
* <p>A negative number means that there is no limit.</p>
- *
+ *
* @return the maximum number of active connections
*/
public synchronized int getMaxActive() {
@@ -314,7 +317,7 @@ public class BasicDataSource implements
/**
* Sets the maximum number of active connections that can be
* allocated at the same time. Use a negative value for no limit.
- *
+ *
* @param maxActive the new value for maxActive
* @see #getMaxActive()
*/
@@ -342,7 +345,7 @@ public class BasicDataSource implements
* pool. Excess idle connections are destroyed on return to the pool.
* </p>
* <p>A negative value indicates that there is no limit</p>
- *
+ *
* @return the maximum number of idle connections
*/
public synchronized int getMaxIdle() {
@@ -352,7 +355,7 @@ public class BasicDataSource implements
/**
* Sets the maximum number of connections that can remain idle in the
* pool. Excess idle connections are destroyed on return to the pool.
- *
+ *
* @see #getMaxIdle()
* @param maxIdle the new value for maxIdle
*/
@@ -365,7 +368,7 @@ public class BasicDataSource implements
/**
* The minimum number of active connections that can remain idle in the
- * pool, without extra ones being created when the evictor runs, or 0 to create none.
+ * pool, without extra ones being created when the evictor runs, or 0 to create none.
* The pool attempts to ensure that minIdle connections are available when the idle object evictor
* runs. The value of this property has no effect unless {@link #timeBetweenEvictionRunsMillis}
* has a positive value.
@@ -377,7 +380,7 @@ public class BasicDataSource implements
* to ensure that minIdle connections are available when the idle object evictor
* runs. The value of this property has no effect unless {@link #timeBetweenEvictionRunsMillis}
* has a positive value.
- *
+ *
* @return the minimum number of idle connections
* @see GenericObjectPool#getMinIdle()
*/
@@ -390,7 +393,7 @@ public class BasicDataSource implements
* to ensure that minIdle connections are available when the idle object evictor
* runs. The value of this property has no effect unless {@link #timeBetweenEvictionRunsMillis}
* has a positive value.
- *
+ *
* @param minIdle the new value for minIdle
* @see GenericObjectPool#setMinIdle(int)
*/
@@ -404,20 +407,20 @@ public class BasicDataSource implements
/**
* The initial number of connections that are created when the pool
* is started.
- *
+ *
* @since 1.2
*/
protected int initialSize = 0;
-
+
/**
* Returns the initial size of the connection pool.
- *
+ *
* @return the number of connections created when the pool is initialized
*/
public synchronized int getInitialSize() {
return this.initialSize;
}
-
+
/**
* <p>Sets the initial size of the connection pool.</p>
* <p>
@@ -425,7 +428,7 @@ public class BasicDataSource implements
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param initialSize the number of connections created when the pool
* is initialized
*/
@@ -447,7 +450,7 @@ public class BasicDataSource implements
* </p>
* <p>A value less than or equal to zero means the pool is set to wait
* indefinitely.</p>
- *
+ *
* @return the maxWait property value
*/
public synchronized long getMaxWait() {
@@ -459,7 +462,7 @@ public class BasicDataSource implements
* </p>
* <p>Use -1 to make the pool wait indefinitely.
* </p>
- *
+ *
* @param maxWait the new value for maxWait
* @see #getMaxWait()
*/
@@ -475,10 +478,10 @@ public class BasicDataSource implements
* both PreparedStatements and CallableStatements are pooled.
*/
protected boolean poolPreparedStatements = false;
-
+
/**
* Returns true if we are pooling statements.
- *
+ *
* @return true if prepared and callable statements are pooled
*/
public synchronized boolean isPoolPreparedStatements() {
@@ -492,7 +495,7 @@ public class BasicDataSource implements
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param poolingStatements pooling on or off
*/
public synchronized void setPoolPreparedStatements(boolean poolingStatements) {
@@ -502,10 +505,10 @@ public class BasicDataSource implements
/**
* <p>The maximum number of open statements that can be allocated from
- * the statement pool at the same time, or non-positive for no limit. Since
+ * the statement pool at the same time, or non-positive for no limit. Since
* a connection usually only uses one or two statements at a time, this is
* mostly used to help detect resource leaks.</p>
- *
+ *
* <p>Note: As of version 1.3, CallableStatements (those produced by {@link Connection#prepareCall})
* are pooled along with PreparedStatements (produced by {@link Connection#prepareStatement})
* and <code>maxOpenPreparedStatements</code> limits the total number of prepared or callable statements
@@ -515,7 +518,7 @@ public class BasicDataSource implements
/**
* Gets the value of the {@link #maxOpenPreparedStatements} property.
- *
+ *
* @return the maximum number of open statements
* @see #maxOpenPreparedStatements
*/
@@ -523,7 +526,7 @@ public class BasicDataSource implements
return this.maxOpenPreparedStatements;
}
- /**
+ /**
* <p>Sets the value of the {@link #maxOpenPreparedStatements}
* property.</p>
* <p>
@@ -531,7 +534,7 @@ public class BasicDataSource implements
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param maxOpenStatements the new maximum number of prepared statements
* @see #maxOpenPreparedStatements
*/
@@ -549,10 +552,10 @@ public class BasicDataSource implements
/**
* Returns the {@link #testOnBorrow} property.
- *
+ *
* @return true if objects are validated before being borrowed from the
* pool
- *
+ *
* @see #testOnBorrow
*/
public synchronized boolean getTestOnBorrow() {
@@ -562,9 +565,9 @@ public class BasicDataSource implements
/**
* Sets the {@link #testOnBorrow} property. This property determines
* whether or not the pool will validate objects before they are borrowed
- * from the pool. For a <code>true</code> value to have any effect, the
+ * from the pool. For a <code>true</code> value to have any effect, the
* <code>validationQuery</code> property must be set to a non-null string.
- *
+ *
* @param testOnBorrow new value for testOnBorrow property
*/
public synchronized void setTestOnBorrow(boolean testOnBorrow) {
@@ -582,7 +585,7 @@ public class BasicDataSource implements
/**
* Returns the value of the {@link #testOnReturn} property.
- *
+ *
* @return true if objects are validated before being returned to the
* pool
* @see #testOnReturn
@@ -594,9 +597,9 @@ public class BasicDataSource implements
/**
* Sets the <code>testOnReturn</code> property. This property determines
* whether or not the pool will validate objects before they are returned
- * to the pool. For a <code>true</code> value to have any effect, the
+ * to the pool. For a <code>true</code> value to have any effect, the
* <code>validationQuery</code> property must be set to a non-null string.
- *
+ *
* @param testOnReturn new value for testOnReturn property
*/
public synchronized void setTestOnReturn(boolean testOnReturn) {
@@ -613,11 +616,11 @@ public class BasicDataSource implements
*/
protected long timeBetweenEvictionRunsMillis =
GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS;
-
+
/**
* Returns the value of the {@link #timeBetweenEvictionRunsMillis}
* property.
- *
+ *
* @return the time (in milliseconds) between evictor runs
* @see #timeBetweenEvictionRunsMillis
*/
@@ -627,7 +630,7 @@ public class BasicDataSource implements
/**
* Sets the {@link #timeBetweenEvictionRunsMillis} property.
- *
+ *
* @param timeBetweenEvictionRunsMillis the new time between evictor runs
* @see #timeBetweenEvictionRunsMillis
*/
@@ -647,7 +650,7 @@ public class BasicDataSource implements
/**
* Returns the value of the {@link #numTestsPerEvictionRun} property.
- *
+ *
* @return the number of objects to examine during idle object evictor
* runs
* @see #numTestsPerEvictionRun
@@ -658,8 +661,8 @@ public class BasicDataSource implements
/**
* Sets the value of the {@link #numTestsPerEvictionRun} property.
- *
- * @param numTestsPerEvictionRun the new {@link #numTestsPerEvictionRun}
+ *
+ * @param numTestsPerEvictionRun the new {@link #numTestsPerEvictionRun}
* value
* @see #numTestsPerEvictionRun
*/
@@ -679,7 +682,7 @@ public class BasicDataSource implements
/**
* Returns the {@link #minEvictableIdleTimeMillis} property.
- *
+ *
* @return the value of the {@link #minEvictableIdleTimeMillis} property
* @see #minEvictableIdleTimeMillis
*/
@@ -689,9 +692,9 @@ public class BasicDataSource implements
/**
* Sets the {@link #minEvictableIdleTimeMillis} property.
- *
+ *
* @param minEvictableIdleTimeMillis the minimum amount of time an object
- * may sit idle in the pool
+ * may sit idle in the pool
* @see #minEvictableIdleTimeMillis
*/
public synchronized void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
@@ -700,7 +703,7 @@ public class BasicDataSource implements
connectionPool.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
}
}
-
+
/**
* The minimum amount of time a connection may sit idle in the pool before
* it is eligible for eviction by the idle object evictor, with the extra
@@ -709,7 +712,7 @@ public class BasicDataSource implements
* parameter. See {@link #getSoftMinEvictableIdleTimeMillis()}.
*/
private long softMinEvictableIdleTimeMillis = GenericObjectPool.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
-
+
/**
* Sets the minimum amount of time a connection may sit idle in the pool
* before it is eligible for eviction by the idle object evictor, with the
@@ -727,19 +730,19 @@ public class BasicDataSource implements
connectionPool.setSoftMinEvictableIdleTimeMillis(softMinEvictableIdleTimeMillis);
}
}
-
+
/**
* <p>Returns the minimum amount of time a connection may sit idle in the
* pool before it is eligible for eviction by the idle object evictor, with
* the extra condition that at least "minIdle" connections remain in the
* pool.</p>
- *
- * <p>When {@link #getMinEvictableIdleTimeMillis() miniEvictableIdleTimeMillis}
+ *
+ * <p>When {@link #getMinEvictableIdleTimeMillis() miniEvictableIdleTimeMillis}
* is set to a positive value, miniEvictableIdleTimeMillis is examined
* first by the idle connection evictor - i.e. when idle connections are
* visited by the evictor, idle time is first compared against
* {@code minEvictableIdleTimeMillis} (without considering the number of idle
- * connections in the pool) and then against
+ * connections in the pool) and then against
* {@code softMinEvictableIdleTimeMillis}, including the {@code minIdle},
* constraint.</p>
*
@@ -761,7 +764,7 @@ public class BasicDataSource implements
/**
* Returns the value of the {@link #testWhileIdle} property.
- *
+ *
* @return true if objects examined by the idle object evictor are
* validated
* @see #testWhileIdle
@@ -773,9 +776,9 @@ public class BasicDataSource implements
/**
* Sets the <code>testWhileIdle</code> property. This property determines
* whether or not the idle object evictor will validate connections. For a
- * <code>true</code> value to have any effect, the
+ * <code>true</code> value to have any effect, the
* <code>validationQuery</code> property must be set to a non-null string.
- *
+ *
* @param testWhileIdle new value for testWhileIdle property
*/
public synchronized void setTestWhileIdle(boolean testWhileIdle) {
@@ -788,7 +791,7 @@ public class BasicDataSource implements
/**
* [Read Only] The current number of active connections that have been
* allocated from this data source.
- *
+ *
* @return the current number of active connections
*/
public synchronized int getNumActive() {
@@ -803,7 +806,7 @@ public class BasicDataSource implements
/**
* [Read Only] The current number of idle connections that are waiting
* to be allocated from this data source.
- *
+ *
* @return the current number of idle connections
*/
public synchronized int getNumIdle() {
@@ -822,21 +825,21 @@ public class BasicDataSource implements
/**
* Returns the password passed to the JDBC driver to establish connections.
- *
+ *
* @return the connection password
*/
public String getPassword() {
return this.password;
}
- /**
+ /**
* <p>Sets the {@link #password}.</p>
* <p>
* Note: this method currently has no effect once the pool has been
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param password new value for the password
*/
public void setPassword(String password) {
@@ -852,7 +855,7 @@ public class BasicDataSource implements
/**
* Returns the JDBC connection {@link #url} property.
- *
+ *
* @return the {@link #url} passed to the JDBC driver to establish
* connections
*/
@@ -860,14 +863,14 @@ public class BasicDataSource implements
return this.url;
}
- /**
+ /**
* <p>Sets the {@link #url}.</p>
* <p>
* Note: this method currently has no effect once the pool has been
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param url the new value for the JDBC connection url
*/
public synchronized void setUrl(String url) {
@@ -883,7 +886,7 @@ public class BasicDataSource implements
/**
* Returns the JDBC connection {@link #username} property.
- *
+ *
* @return the {@link #username} passed to the JDBC driver to establish
* connections
*/
@@ -891,14 +894,14 @@ public class BasicDataSource implements
return this.username;
}
- /**
+ /**
* <p>Sets the {@link #username}.</p>
* <p>
* Note: this method currently has no effect once the pool has been
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param username the new value for the JDBC connection username
*/
public void setUsername(String username) {
@@ -917,7 +920,7 @@ public class BasicDataSource implements
/**
* Returns the validation query used to validate connections before
* returning them.
- *
+ *
* @return the SQL validation query
* @see #validationQuery
*/
@@ -925,14 +928,14 @@ public class BasicDataSource implements
return this.validationQuery;
}
- /**
+ /**
* <p>Sets the {@link #validationQuery}.</p>
* <p>
* Note: this method currently has no effect once the pool has been
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param validationQuery the new value for the validation query
*/
public void setValidationQuery(String validationQuery) {
@@ -943,24 +946,24 @@ public class BasicDataSource implements
}
this.restartNeeded = true;
}
-
+
/**
- * Timeout in seconds before connection validation queries fail.
- *
+ * Timeout in seconds before connection validation queries fail.
+ *
* @since 1.3
*/
protected volatile int validationQueryTimeout = -1;
-
+
/**
* Returns the validation query timeout.
- *
+ *
* @return the timeout in seconds before connection validation queries fail.
* @since 1.3
*/
public int getValidationQueryTimeout() {
return validationQueryTimeout;
}
-
+
/**
* Sets the validation query timeout, the amount of time, in seconds, that
* connection validation will wait for a response from the database when
@@ -971,7 +974,7 @@ public class BasicDataSource implements
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param timeout new validation query timeout value in seconds
* @since 1.3
*/
@@ -979,7 +982,7 @@ public class BasicDataSource implements
this.validationQueryTimeout = timeout;
restartNeeded = true;
}
-
+
/**
* These SQL statements run once after a Connection is created.
* <p>
@@ -987,7 +990,7 @@ public class BasicDataSource implements
* NLS_SORT=XCYECH in an Oracle Database only once after connection
* creation.
* </p>
- *
+ *
* @since 1.3
*/
protected volatile List connectionInitSqls;
@@ -996,12 +999,12 @@ public class BasicDataSource implements
* Returns the list of SQL statements executed when a physical connection
* is first created. Returns an empty list if there are no initialization
* statements configured.
- *
+ *
* @return initialization SQL statements
* @since 1.3
*/
public Collection getConnectionInitSqls() {
- Collection result = connectionInitSqls;
+ Collection result = connectionInitSqls;
if (result == null) {
return Collections.EMPTY_LIST;
}
@@ -1016,7 +1019,7 @@ public class BasicDataSource implements
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param connectionInitSqls Collection of SQL statements to execute
* on connection creation
*/
@@ -1044,14 +1047,14 @@ public class BasicDataSource implements
}
- /**
+ /**
* Controls access to the underlying connection.
*/
- private boolean accessToUnderlyingConnectionAllowed = false;
+ private boolean accessToUnderlyingConnectionAllowed = false;
/**
* Returns the value of the accessToUnderlyingConnectionAllowed property.
- *
+ *
* @return true if access to the underlying connection is allowed, false
* otherwise.
*/
@@ -1068,7 +1071,7 @@ public class BasicDataSource implements
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param allow Access to the underlying connection is granted when true.
*/
public synchronized void setAccessToUnderlyingConnectionAllowed(boolean allow) {
@@ -1086,12 +1089,12 @@ public class BasicDataSource implements
* this property has no effect.
*/
private volatile boolean restartNeeded = false;
-
+
/**
- * Returns whether or not a restart is needed.
- *
+ * Returns whether or not a restart is needed.
+ *
* Note: restart is not currently triggered by property changes.
- *
+ *
* @return true if a restart is needed
*/
private boolean isRestartNeeded() {
@@ -1102,7 +1105,7 @@ public class BasicDataSource implements
* The object pool that internally manages our connections.
*/
protected volatile GenericObjectPool connectionPool = null;
-
+
/**
* The connection properties that will be sent to our JDBC driver when
* establishing new connections. <strong>NOTE</strong> - The "user" and
@@ -1230,39 +1233,39 @@ public class BasicDataSource implements
private AbandonedConfig abandonedConfig;
- /**
+ /**
* <p>Flag to remove abandoned connections if they exceed the
* removeAbandonedTimout.</p>
*
* <p>The default value is false.<p>
- *
+ *
* <p>If set to true a connection is considered abandoned and eligible
* for removal if it has not been used for more than
* {@link #getRemoveAbandonedTimeout() removeAbandonedTimeout} seconds.</p>
- *
- * <p>Abandoned connections are identified and removed when
+ *
+ * <p>Abandoned connections are identified and removed when
* {@link #getConnection()} is invoked and the following conditions hold
* <ul><li>{@link #getRemoveAbandoned()} = true </li>
* <li>{@link #getNumActive()} > {@link #getMaxActive()} - 3 </li>
* <li>{@link #getNumIdle()} < 2 </li></ul></p>
*
* @see #getRemoveAbandonedTimeout()
- */
- public boolean getRemoveAbandoned() {
+ */
+ public boolean getRemoveAbandoned() {
if (abandonedConfig != null) {
return abandonedConfig.getRemoveAbandoned();
}
return false;
- }
-
+ }
+
/**
* <p>Flag to remove abandoned connections if they exceed the
* removeAbandonedTimeout.</p>
*
- * <p>If set to true a connection is considered abandoned and eligible
+ * <p>If set to true a connection is considered abandoned and eligible
* for removal if it has been idle longer than the
* {@link #getRemoveAbandoned() removeAbandonedTimeout}.</p>
- *
+ *
* <p>Setting this to true can recover db connections from poorly written
* applications which fail to close a connection.</p>
*
@@ -1276,66 +1279,66 @@ public class BasicDataSource implements
}
abandonedConfig.setRemoveAbandoned(removeAbandoned);
this.restartNeeded = true;
- }
-
- /**
+ }
+
+ /**
* <p>Timeout in seconds before an abandoned connection can be removed.</p>
- *
+ *
* <p>Creating a Statement, PreparedStatement or CallableStatement or using
* one of these to execute a query (using one of the execute methods)
* resets the lastUsed property of the parent connection.</p>
- *
+ *
* <p>Abandoned connection cleanup happens when
* <code><ul>
* <li><code>{@link #getRemoveAbandoned() removeAbandoned} == true</li>
* <li>{@link #getNumIdle() numIdle} < 2</li>
* <li>{@link #getNumActive() numActive} > {@link #getMaxActive() maxActive} - 3</li>
* </ul></code></p>
- *
+ *
* <p>The default value is 300 seconds.</p>
- */
- public int getRemoveAbandonedTimeout() {
+ */
+ public int getRemoveAbandonedTimeout() {
if (abandonedConfig != null) {
return abandonedConfig.getRemoveAbandonedTimeout();
}
return 300;
- }
+ }
/**
* <p>Sets the timeout in seconds before an abandoned connection can be
* removed.</p>
- *
- * <p>Setting this property has no effect if
+ *
+ * <p>Setting this property has no effect if
* {@link #getRemoveAbandoned() removeAbandoned} is false.</p>
*
* @param removeAbandonedTimeout new abandoned timeout in seconds
* @see #getRemoveAbandonedTimeout()
* @see #getRemoveAbandoned()
- */
+ */
public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
if (abandonedConfig == null) {
abandonedConfig = new AbandonedConfig();
}
abandonedConfig.setRemoveAbandonedTimeout(removeAbandonedTimeout);
this.restartNeeded = true;
- }
-
+ }
+
/**
* <p>Flag to log stack traces for application code which abandoned
* a Statement or Connection.
* </p>
- * <p>Defaults to false.
- * </p>
+ * <p>Defaults to false.
+ * </p>
* <p>Logging of abandoned Statements and Connections adds overhead
- * for every Connection open or new Statement because a stack
+ * for every Connection open or new Statement because a stack
* trace has to be generated. </p>
- */
- public boolean getLogAbandoned() {
+ */
+ public boolean getLogAbandoned() {
if (abandonedConfig != null) {
return abandonedConfig.getLogAbandoned();
}
return false;
- }
+ }
/**
* @param logAbandoned new logAbandoned property value
@@ -1367,7 +1370,7 @@ public class BasicDataSource implements
/**
* Remove a custom connection property.
- *
+ *
* @param name Name of the custom connection property to remove
* @see #addConnectionProperty(String, String)
*/
@@ -1416,16 +1419,16 @@ public class BasicDataSource implements
* <p>Closes and releases all idle connections that are currently stored in the connection pool
* associated with this data source.</p>
*
- * <p>Connections that are checked out to clients when this method is invoked are not affected.
+ * <p>Connections that are checked out to clients when this method is invoked are not affected.
* When client applications subsequently invoke {@link Connection#close()} to return
* these connections to the pool, the underlying JDBC connections are closed.</p>
- *
+ *
* <p>Attempts to acquire connections using {@link #getConnection()} after this method has been
* invoked result in SQLExceptions.<p>
- *
+ *
* <p>This method is idempotent - i.e., closing an already closed BasicDataSource has no effect
* and does not generate exceptions.</p>
- *
+ *
* @throws SQLException if an error occurs closing idle connections
*/
public synchronized void close() throws SQLException {
@@ -1464,7 +1467,14 @@ public class BasicDataSource implements
}
/* JDBC_4_ANT_KEY_END */
-
+ /* JDBC_4_1_ANT_KEY_BEGIN */
+ @Override
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ throw new SQLFeatureNotSupportedException();
+ }
+ /* JDBC_4_1_ANT_KEY_END */
+
+
// ------------------------------------------------------ Protected Methods
@@ -1517,7 +1527,7 @@ public class BasicDataSource implements
} catch (SQLException se) {
throw se;
} catch (RuntimeException rte) {
- throw rte;
+ throw rte;
} catch (Exception ex) {
throw new SQLException("Error creating connection factory", ex);
} finally {
@@ -1525,7 +1535,7 @@ public class BasicDataSource implements
closeConnectionPool();
}
}
-
+
// Create the pooling data source to manage connections
success = false;
try {
@@ -1540,9 +1550,9 @@ public class BasicDataSource implements
} finally {
if (!success) {
closeConnectionPool();
- }
+ }
}
-
+
// If initialSize > 0, preload the pool
try {
for (int i = 0 ; i < initialSize ; i++) {
@@ -1552,10 +1562,10 @@ public class BasicDataSource implements
closeConnectionPool();
throw new SQLNestedException("Error preloading the connection pool", e);
}
-
+
// If timeBetweenEvictionRunsMillis > 0, start the pool's evictor task
startPoolMaintenance();
-
+
return dataSource;
}
@@ -1611,7 +1621,7 @@ public class BasicDataSource implements
// respect the ContextClassLoader
driver = (Driver) driverFromCCL.newInstance();
if (!driver.acceptsURL(url)) {
- throw new SQLException("No suitable driver", "08001");
+ throw new SQLException("No suitable driver", "08001");
}
}
} catch (Throwable t) {
@@ -1652,8 +1662,8 @@ public class BasicDataSource implements
/**
* Creates a connection pool for this datasource. This method only exists
* so subclasses can replace the implementation class.
- *
- * This implementation configures all pool properties other than
+ *
+ * This implementation configures all pool properties other than
* timeBetweenEvictionRunsMillis. Setting that property is deferred to
* {@link #startPoolMaintenance()}, since setting timeBetweenEvictionRunsMillis
* to a positive value causes {@link GenericObjectPool}'s eviction timer
@@ -1680,7 +1690,7 @@ public class BasicDataSource implements
gop.setLifo(lifo);
connectionPool = gop;
}
-
+
/**
* Closes the connection pool, silently swallowing any exception that occurs.
*/
@@ -1695,9 +1705,9 @@ public class BasicDataSource implements
// Do not propagate
}
}
-
+
/**
- * Starts the connection pool maintenance task, if configured.
+ * Starts the connection pool maintenance task, if configured.
*/
protected void startPoolMaintenance() {
if (connectionPool != null && timeBetweenEvictionRunsMillis > 0) {
@@ -1709,7 +1719,7 @@ public class BasicDataSource implements
/**
* Creates the actual data source instance. This method only exists so
* that subclasses can replace the implementation class.
- *
+ *
* @throws SQLException if unable to create a datasource instance
*/
protected void createDataSourceInstance() throws SQLException {
@@ -1722,7 +1732,7 @@ public class BasicDataSource implements
/**
* Creates the PoolableConnectionFactory and attaches it to the connection pool. This method only exists
* so subclasses can replace the default implementation.
- *
+ *
* @param driverConnectionFactory JDBC connection factory
* @param statementPoolFactory statement pool factory (null if statement pooling is turned off)
* @param configuration abandoned connection tracking configuration (null if no tracking)
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingCallableStatement.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingCallableStatement.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingCallableStatement.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingCallableStatement.java Tue Jan 29 13:11:04 2013
@@ -5,9 +5,9 @@
* 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.
@@ -28,7 +28,9 @@ import java.sql.Ref;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Array;
+import java.sql.SQLFeatureNotSupportedException;
import java.util.Calendar;
+import java.util.logging.Logger;
import java.io.InputStream;
import java.io.Reader;
import java.sql.SQLException;
@@ -662,4 +664,32 @@ public class DelegatingCallableStatement
}
}
/* JDBC_4_ANT_KEY_END */
+
+ /* JDBC_4_1_ANT_KEY_BEGIN */
+ @Override
+ public <T> T getObject(int parameterIndex, Class<T> type)
+ throws SQLException {
+ checkOpen();
+ try {
+ return ((CallableStatement)_stmt).getObject(parameterIndex, type);
+ }
+ catch (SQLException e) {
+ handleException(e);
+ return null;
+ }
+ }
+
+ @Override
+ public <T> T getObject(String parameterName, Class<T> type)
+ throws SQLException {
+ checkOpen();
+ try {
+ return ((CallableStatement)_stmt).getObject(parameterName, type);
+ }
+ catch (SQLException e) {
+ handleException(e);
+ return null;
+ }
+ }
+ /* JDBC_4_1_ANT_KEY_END */
}
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingConnection.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingConnection.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingConnection.java Tue Jan 29 13:11:04 2013
@@ -5,9 +5,9 @@
* 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.
@@ -40,6 +40,7 @@ import java.sql.Struct;
import java.util.Collections;
import java.util.Properties;
/* JDBC_4_ANT_KEY_END */
+import java.util.concurrent.Executor;
/**
* A base delegating implementation of {@link Connection}.
@@ -74,7 +75,7 @@ public class DelegatingConnection extend
protected Connection _conn = null;
protected boolean _closed = false;
-
+
/**
* Create a wrapper for the Connection which traces this
* Connection in the AbandonedObjectPool.
@@ -102,12 +103,12 @@ public class DelegatingConnection extend
/**
* Returns a string representation of the metadata associated with
* the innnermost delegate connection.
- *
+ *
* @since 1.2.2
*/
public String toString() {
String s = null;
-
+
Connection c = this.getInnermostDelegateInternal();
if (c != null) {
try {
@@ -131,11 +132,11 @@ public class DelegatingConnection extend
// Ignore
}
}
-
+
if (s == null) {
s = super.toString();
}
-
+
return s;
}
@@ -146,17 +147,17 @@ public class DelegatingConnection extend
public Connection getDelegate() {
return getDelegateInternal();
}
-
+
/**
* Should be final but can't be for compatibility with previous releases.
*/
protected Connection getDelegateInternal() {
return _conn;
}
-
+
/**
* Compares innermost delegate to the given connection.
- *
+ *
* @param c connection to compare innermost delegate with
* @return true if innermost delegate equals <code>c</code>
* @since 1.2.2
@@ -171,7 +172,7 @@ public class DelegatingConnection extend
}
/**
- * This method considers two objects to be equal
+ * This method considers two objects to be equal
* if the underlying jdbc objects are equal.
*/
public boolean equals(Object obj) {
@@ -185,7 +186,7 @@ public class DelegatingConnection extend
if (delegate == null) {
return false;
}
- if (obj instanceof DelegatingConnection) {
+ if (obj instanceof DelegatingConnection) {
DelegatingConnection c = (DelegatingConnection) obj;
return c.innermostDelegateEquals(delegate);
}
@@ -232,7 +233,7 @@ public class DelegatingConnection extend
}
return c;
}
-
+
/** Sets my delegate. */
public void setDelegate(Connection c) {
_conn = c;
@@ -329,16 +330,16 @@ public class DelegatingConnection extend
public void clearWarnings() throws SQLException
{ checkOpen(); try { _conn.clearWarnings(); } catch (SQLException e) { handleException(e); } }
-
+
public void commit() throws SQLException
{ checkOpen(); try { _conn.commit(); } catch (SQLException e) { handleException(e); } }
-
+
public boolean getAutoCommit() throws SQLException
- { checkOpen(); try { return _conn.getAutoCommit(); } catch (SQLException e) { handleException(e); return false; }
+ { checkOpen(); try { return _conn.getAutoCommit(); } catch (SQLException e) { handleException(e); return false; }
}
public String getCatalog() throws SQLException
{ checkOpen(); try { return _conn.getCatalog(); } catch (SQLException e) { handleException(e); return null; } }
-
+
public DatabaseMetaData getMetaData() throws SQLException {
checkOpen();
try {
@@ -348,25 +349,25 @@ public class DelegatingConnection extend
return null;
}
}
-
+
public int getTransactionIsolation() throws SQLException
{ checkOpen(); try { return _conn.getTransactionIsolation(); } catch (SQLException e) { handleException(e); return -1; } }
-
+
public Map getTypeMap() throws SQLException
{ checkOpen(); try { return _conn.getTypeMap(); } catch (SQLException e) { handleException(e); return null; } }
-
+
public SQLWarning getWarnings() throws SQLException
{ checkOpen(); try { return _conn.getWarnings(); } catch (SQLException e) { handleException(e); return null; } }
-
+
public boolean isReadOnly() throws SQLException
{ checkOpen(); try { return _conn.isReadOnly(); } catch (SQLException e) { handleException(e); return false; } }
-
+
public String nativeSQL(String sql) throws SQLException
{ checkOpen(); try { return _conn.nativeSQL(sql); } catch (SQLException e) { handleException(e); return null; } }
-
+
public void rollback() throws SQLException
{ checkOpen(); try { _conn.rollback(); } catch (SQLException e) { handleException(e); } }
-
+
public void setAutoCommit(boolean autoCommit) throws SQLException
{ checkOpen(); try { _conn.setAutoCommit(autoCommit); } catch (SQLException e) { handleException(e); } }
@@ -400,7 +401,7 @@ public class DelegatingConnection extend
} else {
throw new SQLException
("Connection is null.");
- }
+ }
}
}
@@ -679,4 +680,37 @@ public class DelegatingConnection extend
}
}
/* JDBC_4_ANT_KEY_END */
+
+ /* JDBC_4_1_ANT_KEY_BEGIN */
+ @Override
+ public void setSchema(String schema) throws SQLException {
+ checkOpen();
+ _conn.setSchema(schema);
+ }
+
+ @Override
+ public String getSchema() throws SQLException {
+ checkOpen();
+ return _conn.getSchema();
+ }
+
+ @Override
+ public void abort(Executor executor) throws SQLException {
+ checkOpen();
+ _conn.abort(executor);
+ }
+
+ @Override
+ public void setNetworkTimeout(Executor executor, int milliseconds)
+ throws SQLException {
+ checkOpen();
+ _conn.setNetworkTimeout(executor, milliseconds);
+ }
+
+ @Override
+ public int getNetworkTimeout() throws SQLException {
+ checkOpen();
+ return _conn.getNetworkTimeout();
+ }
+ /* JDBC_4_1_ANT_KEY_END */
}
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingDatabaseMetaData.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingDatabaseMetaData.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingDatabaseMetaData.java Tue Jan 29 13:11:04 2013
@@ -5,9 +5,9 @@
* 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.
@@ -27,12 +27,12 @@ import java.sql.SQLException;
/**
* <p>A base delegating implementation of {@link DatabaseMetaData}.</p>
- *
+ *
* <p>Methods that create {@link ResultSet} objects are wrapped to
* create {@link DelegatingResultSet} objects and the remaining methods
* simply call the corresponding method on the "delegate"
* provided in the constructor.</p>
- *
+ *
* <p>NOTE: as of version 2.0, this class will no longer extend AbandonedTrace.</p>
*/
public class DelegatingDatabaseMetaData extends AbandonedTrace
@@ -40,7 +40,7 @@ public class DelegatingDatabaseMetaData
/** My delegate {@link DatabaseMetaData} */
protected DatabaseMetaData _meta;
-
+
/** The connection that created me. **/
protected DelegatingConnection _conn = null;
@@ -103,7 +103,7 @@ public class DelegatingDatabaseMetaData
}
return m;
}
-
+
protected void handleException(SQLException e) throws SQLException {
if (_conn != null) {
_conn.handleException(e);
@@ -1134,7 +1134,7 @@ public class DelegatingDatabaseMetaData
return _meta.unwrap(iface);
}
}
-
+
public RowIdLifetime getRowIdLifetime() throws SQLException {
{ try { return _meta.getRowIdLifetime(); }
catch (SQLException e) { handleException(e); throw new AssertionError(); } }
@@ -1206,4 +1206,31 @@ public class DelegatingDatabaseMetaData
/* JDBC_4_ANT_KEY_END */
+ /* JDBC_4_1_ANT_KEY_BEGIN */
+ @Override
+ public ResultSet getPseudoColumns(String catalog, String schemaPattern,
+ String tableNamePattern, String columnNamePattern)
+ throws SQLException {
+ _conn.checkOpen();
+ try {
+ return DelegatingResultSet.wrapResultSet(_conn,
+ _meta.getPseudoColumns(catalog, schemaPattern,
+ tableNamePattern, columnNamePattern));
+ } catch (SQLException e) {
+ handleException(e);
+ throw new AssertionError();
+ }
+ }
+
+ @Override
+ public boolean generatedKeyAlwaysReturned() throws SQLException {
+ _conn.checkOpen();
+ try {
+ return _meta.generatedKeyAlwaysReturned();
+ } catch (SQLException e) {
+ handleException(e);
+ throw new AssertionError();
+ }
+ }
+ /* JDBC_4_1_ANT_KEY_END */
}
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingResultSet.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingResultSet.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingResultSet.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingResultSet.java Tue Jan 29 13:11:04 2013
@@ -5,9 +5,9 @@
* 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.
@@ -82,7 +82,7 @@ public class DelegatingResultSet extends
this._stmt = stmt;
this._res = res;
}
-
+
/**
* Create a wrapper for the ResultSet which traces this
* ResultSet to the Connection which created it (via, for
@@ -96,7 +96,7 @@ public class DelegatingResultSet extends
this._conn = conn;
this._res = res;
}
-
+
public static ResultSet wrapResultSet(Statement stmt, ResultSet rset) {
if(null == rset) {
return null;
@@ -165,7 +165,7 @@ public class DelegatingResultSet extends
}
return r;
}
-
+
public Statement getStatement() throws SQLException {
return _stmt;
}
@@ -204,7 +204,7 @@ public class DelegatingResultSet extends
}
}
- public boolean next() throws SQLException
+ public boolean next() throws SQLException
{ try { return _res.next(); } catch (SQLException e) { handleException(e); return false; } }
public boolean wasNull() throws SQLException
@@ -1080,4 +1080,27 @@ public class DelegatingResultSet extends
}
}
/* JDBC_4_ANT_KEY_END */
+
+ /* JDBC_4_1_ANT_KEY_BEGIN */
+ @Override
+ public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
+ try {
+ return _res.getObject(columnIndex, type);
+ } catch (SQLException e) {
+ handleException(e);
+ return null;
+ }
+ }
+
+ @Override
+ public <T> T getObject(String columnLabel, Class<T> type)
+ throws SQLException {
+ try {
+ return _res.getObject(columnLabel, type);
+ } catch (SQLException e) {
+ handleException(e);
+ return null;
+ }
+ }
+ /* JDBC_4_1_ANT_KEY_END */
}
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingStatement.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingStatement.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingStatement.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/DelegatingStatement.java Tue Jan 29 13:11:04 2013
@@ -5,9 +5,9 @@
* 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.
@@ -20,9 +20,11 @@ package org.apache.commons.dbcp;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.List;
+import java.util.logging.Logger;
/**
* A base delegating implementation of {@link Statement}.
@@ -73,14 +75,14 @@ public class DelegatingStatement extends
}
/**
- * <p>This method considers two objects to be equal
+ * <p>This method considers two objects to be equal
* if the underlying jdbc objects are equal.</p>
- *
- * <p>If {@code obj} is a DelegatingStatement, this DelegatingStatement's
+ *
+ * <p>If {@code obj} is a DelegatingStatement, this DelegatingStatement's
* {@link #getInnermostDelegate() innermostDelegate} is compared with
* the innermost delegate of obj; otherwise obj itself is compared with the
* the Statement returned by {@link #getInnermostDelegate()}.</p>
- *
+ *
*/
public boolean equals(Object obj) {
if (obj == this) return true;
@@ -104,7 +106,7 @@ public class DelegatingStatement extends
}
return obj.hashCode();
}
-
+
/**
* If my underlying {@link Statement} is not a
* <tt>DelegatingStatement</tt>, returns it,
@@ -142,7 +144,7 @@ public class DelegatingStatement extends
protected void checkOpen() throws SQLException {
if(isClosed()) {
throw new SQLException
- (this.getClass().getName() + " with address: \"" +
+ (this.getClass().getName() + " with address: \"" +
this.toString() + "\" is closed.");
}
}
@@ -158,7 +160,7 @@ public class DelegatingStatement extends
_conn.removeTrace(this);
_conn = null;
}
-
+
// The JDBC spec requires that a statment close any open
// ResultSet's when it is closed.
// FIXME The PreparedStatement we're wrapping should handle this for us.
@@ -171,7 +173,7 @@ public class DelegatingStatement extends
}
clearTrace();
}
-
+
_stmt.close();
}
catch (SQLException e) {
@@ -485,4 +487,18 @@ public class DelegatingStatement extends
}
}
/* JDBC_4_ANT_KEY_END */
+
+ /* JDBC_4_1_ANT_KEY_BEGIN */
+ @Override
+ public void closeOnCompletion() throws SQLException {
+ checkOpen();
+ _stmt.closeOnCompletion();
+ }
+
+ @Override
+ public boolean isCloseOnCompletion() throws SQLException {
+ checkOpen();
+ return _stmt.isCloseOnCompletion();
+ }
+ /* JDBC_4_1_ANT_KEY_END */
}
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/PoolingDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/PoolingDataSource.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/PoolingDataSource.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/PoolingDataSource.java Tue Jan 29 13:11:04 2013
@@ -5,9 +5,9 @@
* 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.
@@ -23,10 +23,12 @@ import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.Map;
import java.util.NoSuchElementException;
+import java.util.logging.Logger;
import javax.sql.DataSource;
@@ -45,7 +47,7 @@ import org.apache.commons.pool.ObjectPoo
public class PoolingDataSource implements DataSource {
/** Controls access to the underlying connection */
- private boolean accessToUnderlyingConnectionAllowed = false;
+ private boolean accessToUnderlyingConnectionAllowed = false;
public PoolingDataSource() {
this(null);
@@ -67,7 +69,7 @@ public class PoolingDataSource implement
/**
* Returns the value of the accessToUnderlyingConnectionAllowed property.
- *
+ *
* @return true if access to the underlying is allowed, false otherwise.
*/
public boolean isAccessToUnderlyingConnectionAllowed() {
@@ -78,7 +80,7 @@ public class PoolingDataSource implement
* Sets the value of the accessToUnderlyingConnectionAllowed property.
* It controls if the PoolGuard allows access to the underlying connection.
* (Default: false)
- *
+ *
* @param allow Access to the underlying connection is granted when true.
*/
public void setAccessToUnderlyingConnectionAllowed(boolean allow) {
@@ -94,7 +96,14 @@ public class PoolingDataSource implement
throw new SQLException("PoolingDataSource is not a wrapper.");
}
/* JDBC_4_ANT_KEY_END */
-
+
+ /* JDBC_4_1_ANT_KEY_BEGIN */
+ @Override
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ throw new SQLFeatureNotSupportedException();
+ }
+ /* JDBC_4_1_ANT_KEY_END */
+
//--- DataSource methods -----------------------------------------
/**
@@ -106,7 +115,7 @@ public class PoolingDataSource implement
Connection conn = (Connection)(_pool.borrowObject());
if (conn != null) {
conn = new PoolGuardConnectionWrapper(conn);
- }
+ }
return conn;
} catch(SQLException e) {
throw e;
@@ -168,13 +177,13 @@ public class PoolingDataSource implement
protected ObjectPool _pool = null;
/**
- * PoolGuardConnectionWrapper is a Connection wrapper that makes sure a
+ * PoolGuardConnectionWrapper is a Connection wrapper that makes sure a
* closed connection cannot be used anymore.
*/
private class PoolGuardConnectionWrapper extends DelegatingConnection {
private Connection delegate;
-
+
PoolGuardConnectionWrapper(Connection delegate) {
super(delegate);
this.delegate = delegate;
@@ -185,7 +194,7 @@ public class PoolingDataSource implement
throw new SQLException("Connection is closed.");
}
}
-
+
public void close() throws SQLException {
if (delegate != null) {
this.delegate.close();
@@ -229,7 +238,7 @@ public class PoolingDataSource implement
return innerCon.equals(c);
}
}
-
+
public boolean getAutoCommit() throws SQLException {
checkOpen();
return delegate.getAutoCommit();
@@ -266,7 +275,7 @@ public class PoolingDataSource implement
}
return delegate.hashCode();
}
-
+
public boolean equals(Object obj) {
if (obj == null) {
return false;
@@ -279,7 +288,7 @@ public class PoolingDataSource implement
if (conn == null) {
return false;
}
- if (obj instanceof DelegatingConnection) {
+ if (obj instanceof DelegatingConnection) {
DelegatingConnection c = (DelegatingConnection) obj;
return c.innermostDelegateEquals(conn);
}
@@ -359,7 +368,7 @@ public class PoolingDataSource implement
checkOpen();
return delegate.getHoldability();
}
-
+
public void setHoldability(int holdability) throws SQLException {
checkOpen();
delegate.setHoldability(holdability);
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/PoolingDriver.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/PoolingDriver.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/PoolingDriver.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/PoolingDriver.java Tue Jan 29 13:11:04 2013
@@ -5,9 +5,9 @@
* 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.
@@ -27,6 +27,7 @@ import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
import java.sql.PreparedStatement;
import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.HashMap;
@@ -34,6 +35,7 @@ import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.Set;
+import java.util.logging.Logger;
import org.apache.commons.jocl.JOCLContentHandler;
import org.apache.commons.pool.ObjectPool;
@@ -62,14 +64,14 @@ public class PoolingDriver implements Dr
protected static final HashMap _pools = new HashMap();
/** Controls access to the underlying connection */
- private static boolean accessToUnderlyingConnectionAllowed = false;
+ private static boolean accessToUnderlyingConnectionAllowed = false;
public PoolingDriver() {
}
/**
* Returns the value of the accessToUnderlyingConnectionAllowed property.
- *
+ *
* @return true if access to the underlying is allowed, false otherwise.
*/
public static synchronized boolean isAccessToUnderlyingConnectionAllowed() {
@@ -80,7 +82,7 @@ public class PoolingDriver implements Dr
* Sets the value of the accessToUnderlyingConnectionAllowed property.
* It controls if the PoolGuard allows access to the underlying connection.
* (Default: false)
- *
+ *
* @param allow Access to the underlying connection is granted when true.
*/
public static synchronized void setAccessToUnderlyingConnectionAllowed(boolean allow) {
@@ -90,7 +92,7 @@ public class PoolingDriver implements Dr
/**
* WARNING: This method throws DbcpExceptions (RuntimeExceptions)
* and will be replaced by the protected getConnectionPool method.
- *
+ *
* @deprecated This will be removed in a future version of DBCP.
*/
public synchronized ObjectPool getPool(String name) {
@@ -101,7 +103,7 @@ public class PoolingDriver implements Dr
throw new DbcpException(e);
}
}
-
+
public synchronized ObjectPool getConnectionPool(String name) throws SQLException {
ObjectPool pool = (ObjectPool)(_pools.get(name));
if(null == pool) {
@@ -156,7 +158,7 @@ public class PoolingDriver implements Dr
}
}
}
-
+
public synchronized String[] getPoolNames(){
Set names = _pools.keySet();
return (String[]) names.toArray(new String[names.size()]);
@@ -180,7 +182,7 @@ public class PoolingDriver implements Dr
Connection conn = (Connection)(pool.borrowObject());
if (conn != null) {
conn = new PoolGuardConnectionWrapper(pool, conn);
- }
+ }
return conn;
} catch(SQLException e) {
throw e;
@@ -199,9 +201,9 @@ public class PoolingDriver implements Dr
/**
* Invalidates the given connection.
- *
+ *
* @param conn connection to invalidate
- * @throws SQLException if the connection is not a
+ * @throws SQLException if the connection is not a
* <code>PoolGuardConnectionWrapper</code> or an error occurs invalidating
* the connection
* @since 1.2.2
@@ -213,8 +215,8 @@ public class PoolingDriver implements Dr
Connection delegate = pgconn.delegate;
try {
pool.invalidateObject(delegate);
- }
- catch (Exception e) {
+ }
+ catch (Exception e) {
}
pgconn.delegate = null;
}
@@ -239,6 +241,13 @@ public class PoolingDriver implements Dr
return new DriverPropertyInfo[0];
}
+ /* JDBC_4_1_ANT_KEY_BEGIN */
+ @Override
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ throw new SQLFeatureNotSupportedException();
+ }
+ /* JDBC_4_1_ANT_KEY_END */
+
/** My URL prefix */
protected static final String URL_PREFIX = "jdbc:apache:commons:dbcp:";
protected static final int URL_PREFIX_LEN = URL_PREFIX.length();
@@ -248,14 +257,14 @@ public class PoolingDriver implements Dr
protected static final int MINOR_VERSION = 0;
/**
- * PoolGuardConnectionWrapper is a Connection wrapper that makes sure a
+ * PoolGuardConnectionWrapper is a Connection wrapper that makes sure a
* closed connection cannot be used anymore.
*/
static private class PoolGuardConnectionWrapper extends DelegatingConnection {
private final ObjectPool pool;
private Connection delegate;
-
+
PoolGuardConnectionWrapper(ObjectPool pool, Connection delegate) {
super(delegate);
this.pool = pool;
@@ -419,7 +428,7 @@ public class PoolingDriver implements Dr
checkOpen();
return delegate.getHoldability();
}
-
+
public void setHoldability(int holdability) throws SQLException {
checkOpen();
delegate.setHoldability(holdability);
Re: svn commit: r1439882 [1/2] - in /commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH:
./ src/java/org/apache/commons/dbcp/ src/java/org/apache/commons/dbcp/cpdsadapter/
src/java/org/apache/commons/dbcp/datasources/ src/test/org/apache/commons/dbcp/
src/test...
Posted by Mark Thomas <ma...@apache.org>.
On 29/01/2013 13:11, markt@apache.org wrote:
> Author: markt
> Date: Tue Jan 29 13:11:04 2013
> New Revision: 1439882
>
> URL: http://svn.apache.org/viewvc?rev=1439882&view=rev
> Log:
> First pass at getting DBCP to compile with Java 7 to keep Gump happy. Whether or not we create a DBCP_1.5 branch and actually release this is a different question. The aim is to continue to be able to release 1.4 from this branch with Java 6.
>
> I need to check this in before I start testing the 1.4 build otherwise my changes will be modified/lost as I test the build.
Sorry about the trailing whitespace changes in this commit. My IDE is
configured to remove them by default and I forgot to disable that
setting before I started these changes.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org