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 [2/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...
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/cpdsadapter/DriverAdapterCPDS.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/cpdsadapter/DriverAdapterCPDS.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/cpdsadapter/DriverAdapterCPDS.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/cpdsadapter/DriverAdapterCPDS.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.
@@ -19,10 +19,13 @@ package org.apache.commons.dbcp.cpdsadap
import java.util.Hashtable;
import java.util.Properties;
+import java.util.logging.Logger;
import java.io.PrintWriter;
import java.io.Serializable;
import java.sql.DriverManager;
import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+
import javax.sql.PooledConnection;
import javax.sql.ConnectionPoolDataSource;
import javax.naming.Name;
@@ -40,42 +43,42 @@ import org.apache.commons.pool.impl.Gene
/**
* <p>
* An adapter for jdbc drivers that do not include an implementation
- * of {@link javax.sql.ConnectionPoolDataSource}, but still include a
- * {@link java.sql.DriverManager} implementation.
- * <code>ConnectionPoolDataSource</code>s are not used within general
+ * of {@link javax.sql.ConnectionPoolDataSource}, but still include a
+ * {@link java.sql.DriverManager} implementation.
+ * <code>ConnectionPoolDataSource</code>s are not used within general
* applications. They are used by <code>DataSource</code> implementations
- * that pool <code>Connection</code>s, such as
+ * that pool <code>Connection</code>s, such as
* {@link org.apache.commons.dbcp.datasources.SharedPoolDataSource}. A J2EE
* container will normally provide some method of initializing the
* <code>ConnectionPoolDataSource</code> whose attributes are presented
* as bean getters/setters and then deploying it via JNDI. It is then
* available as a source of physical connections to the database, when
- * the pooling <code>DataSource</code> needs to create a new
+ * the pooling <code>DataSource</code> needs to create a new
* physical connection.
* </p>
*
* <p>
* Although normally used within a JNDI environment, the DriverAdapterCPDS
* can be instantiated and initialized as any bean and then attached
- * directly to a pooling <code>DataSource</code>.
- * <code>Jdbc2PoolDataSource</code> can use the
+ * directly to a pooling <code>DataSource</code>.
+ * <code>Jdbc2PoolDataSource</code> can use the
* <code>ConnectionPoolDataSource</code> with or without the use of JNDI.
* </p>
*
* <p>
* The DriverAdapterCPDS also provides <code>PreparedStatement</code> pooling
- * which is not generally available in jbdc2
- * <code>ConnectionPoolDataSource</code> implementation, but is
+ * which is not generally available in jbdc2
+ * <code>ConnectionPoolDataSource</code> implementation, but is
* addressed within the jdbc3 specification. The <code>PreparedStatement</code>
* pool in DriverAdapterCPDS has been in the dbcp package for some time, but
* it has not undergone extensive testing in the configuration used here.
- * It should be considered experimental and can be toggled with the
+ * It should be considered experimental and can be toggled with the
* poolPreparedStatements attribute.
* </p>
*
* <p>
- * The <a href="package-summary.html">package documentation</a> contains an
- * example using catalina and JNDI. The <a
+ * The <a href="package-summary.html">package documentation</a> contains an
+ * example using catalina and JNDI. The <a
* href="../datasources/package-summary.html">datasources package documentation</a>
* shows how to use <code>DriverAdapterCPDS</code> as a source for
* <code>Jdbc2PoolDataSource</code> without the use of JNDI.
@@ -85,14 +88,14 @@ import org.apache.commons.pool.impl.Gene
* @version $Revision$ $Date$
*/
public class DriverAdapterCPDS
- implements ConnectionPoolDataSource, Referenceable, Serializable,
+ implements ConnectionPoolDataSource, Referenceable, Serializable,
ObjectFactory {
-
+
private static final long serialVersionUID = -4820523787212147844L;
- private static final String GET_CONNECTION_CALLED
- = "A PooledConnection was already requested from this source, "
+ private static final String GET_CONNECTION_CALLED
+ = "A PooledConnection was already requested from this source, "
+ "further initialization is not allowed.";
/** Description */
@@ -122,7 +125,7 @@ public class DriverAdapterCPDS
/** Whether or not getConnection has been called */
private volatile boolean getConnectionCalled = false;
-
+
/** Connection properties passed to JDBC Driver */
private Properties connectionProperties = null;
@@ -131,11 +134,11 @@ public class DriverAdapterCPDS
DriverManager.getDrivers();
}
- /**
- * Controls access to the underlying connection
+ /**
+ * Controls access to the underlying connection
*/
- private boolean accessToUnderlyingConnectionAllowed = false;
-
+ private boolean accessToUnderlyingConnectionAllowed = false;
+
/**
* Default no-arg constructor for Serialization
*/
@@ -149,22 +152,22 @@ public class DriverAdapterCPDS
public PooledConnection getPooledConnection() throws SQLException {
return getPooledConnection(getUser(), getPassword());
}
-
+
/**
* Attempt to establish a database connection.
* @param username name to be used for the connection
* @param pass password to be used fur the connection
*/
- public PooledConnection getPooledConnection(String username,
+ public PooledConnection getPooledConnection(String username,
String pass)
throws SQLException {
getConnectionCalled = true;
/*
- public GenericKeyedObjectPool(KeyedPoolableObjectFactory factory,
- int maxActive, byte whenExhaustedAction, long maxWait,
- int maxIdle, boolean testOnBorrow, boolean testOnReturn,
- long timeBetweenEvictionRunsMillis,
- int numTestsPerEvictionRun, long minEvictableIdleTimeMillis,
+ public GenericKeyedObjectPool(KeyedPoolableObjectFactory factory,
+ int maxActive, byte whenExhaustedAction, long maxWait,
+ int maxIdle, boolean testOnBorrow, boolean testOnReturn,
+ long timeBetweenEvictionRunsMillis,
+ int numTestsPerEvictionRun, long minEvictableIdleTimeMillis,
boolean testWhileIdle) {
*/
KeyedObjectPool stmtPool = null;
@@ -199,11 +202,11 @@ public class DriverAdapterCPDS
connectionProperties.put("user", username);
connectionProperties.put("password", pass);
pci = new PooledConnectionImpl(
- DriverManager.getConnection(getUrl(), connectionProperties),
+ DriverManager.getConnection(getUrl(), connectionProperties),
stmtPool);
} else {
pci = new PooledConnectionImpl(
- DriverManager.getConnection(getUrl(), username, pass),
+ DriverManager.getConnection(getUrl(), username, pass),
stmtPool);
}
pci.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());
@@ -214,11 +217,11 @@ public class DriverAdapterCPDS
PooledConnectionImpl pci = null;
if (connectionProperties != null) {
pci = new PooledConnectionImpl(
- DriverManager.getConnection(getUrl(), connectionProperties),
+ DriverManager.getConnection(getUrl(), connectionProperties),
stmtPool);
} else {
pci = new PooledConnectionImpl(
- DriverManager.getConnection(getUrl(), username, pass),
+ DriverManager.getConnection(getUrl(), username, pass),
stmtPool);
}
pci.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());
@@ -227,7 +230,7 @@ public class DriverAdapterCPDS
}
// ----------------------------------------------------------------------
- // Referenceable implementation
+ // Referenceable implementation
/**
* <CODE>Referenceable</CODE> implementation.
@@ -235,28 +238,28 @@ public class DriverAdapterCPDS
public Reference getReference() throws NamingException {
// this class implements its own factory
String factory = getClass().getName();
-
+
Reference ref = new Reference(getClass().getName(), factory, null);
ref.add(new StringRefAddr("description", getDescription()));
ref.add(new StringRefAddr("driver", getDriver()));
- ref.add(new StringRefAddr("loginTimeout",
+ ref.add(new StringRefAddr("loginTimeout",
String.valueOf(getLoginTimeout())));
ref.add(new StringRefAddr("password", getPassword()));
ref.add(new StringRefAddr("user", getUser()));
ref.add(new StringRefAddr("url", getUrl()));
- ref.add(new StringRefAddr("poolPreparedStatements",
+ ref.add(new StringRefAddr("poolPreparedStatements",
String.valueOf(isPoolPreparedStatements())));
- ref.add(new StringRefAddr("maxActive",
+ ref.add(new StringRefAddr("maxActive",
String.valueOf(getMaxActive())));
- ref.add(new StringRefAddr("maxIdle",
+ ref.add(new StringRefAddr("maxIdle",
String.valueOf(getMaxIdle())));
- ref.add(new StringRefAddr("timeBetweenEvictionRunsMillis",
+ ref.add(new StringRefAddr("timeBetweenEvictionRunsMillis",
String.valueOf(getTimeBetweenEvictionRunsMillis())));
- ref.add(new StringRefAddr("numTestsPerEvictionRun",
+ ref.add(new StringRefAddr("numTestsPerEvictionRun",
String.valueOf(getNumTestsPerEvictionRun())));
- ref.add(new StringRefAddr("minEvictableIdleTimeMillis",
+ ref.add(new StringRefAddr("minEvictableIdleTimeMillis",
String.valueOf(getMinEvictableIdleTimeMillis())));
ref.add(new StringRefAddr("maxPreparedStatements",
String.valueOf(getMaxPreparedStatements())));
@@ -266,15 +269,15 @@ public class DriverAdapterCPDS
// ----------------------------------------------------------------------
- // ObjectFactory implementation
+ // ObjectFactory implementation
/**
* implements ObjectFactory to create an instance of this class
- */
- public Object getObjectInstance(Object refObj, Name name,
- Context context, Hashtable env)
+ */
+ public Object getObjectInstance(Object refObj, Name name,
+ Context context, Hashtable env)
throws Exception {
- // The spec says to return null if we can't create an instance
+ // The spec says to return null if we can't create an instance
// of the reference
DriverAdapterCPDS cpds = null;
if (refObj instanceof Reference) {
@@ -358,29 +361,29 @@ public class DriverAdapterCPDS
// ----------------------------------------------------------------------
// Properties
-
+
/**
* Get the connection properties passed to the JDBC driver.
- *
+ *
* @return the JDBC connection properties used when creating connections.
* @since 1.3
*/
public Properties getConnectionProperties() {
return connectionProperties;
}
-
+
/**
* <p>Set the connection properties passed to the JDBC driver.</p>
- *
+ *
* <p>If <code>props</code> contains "user" and/or "password"
* properties, the corresponding instance properties are set. If these
* properties are not present, they are filled in using
* {@link #getUser()}, {@link #getPassword()} when {@link #getPooledConnection()}
- * is called, or using the actual parameters to the method call when
+ * is called, or using the actual parameters to the method call when
* {@link #getPooledConnection(String, String)} is called. Calls to
* {@link #setUser(String)} or {@link #setPassword(String)} overwrite the values
* of these properties if <code>connectionProperties</code> is not null.</p>
- *
+ *
* @param props Connection properties to use when creating new connections.
* @since 1.3
* @throws IllegalStateException if {@link #getPooledConnection()} has been called
@@ -395,7 +398,7 @@ public class DriverAdapterCPDS
setPassword(connectionProperties.getProperty("password"));
}
}
-
+
/**
* Get the value of description. This property is here for use by
* the code which will deploy this datasource. It is not used
@@ -407,7 +410,7 @@ public class DriverAdapterCPDS
public String getDescription() {
return description;
}
-
+
/**
* Set the value of description. This property is here for use by
* the code which will deploy this datasource. It is not used
@@ -426,7 +429,7 @@ public class DriverAdapterCPDS
public String getPassword() {
return password;
}
-
+
/**
* Set the value of password for the default user.
* @param v Value to assign to password.
@@ -447,7 +450,7 @@ public class DriverAdapterCPDS
public String getUrl() {
return url;
}
-
+
/**
* Set the value of url used to locate the database for this datasource.
* @param v Value to assign to url.
@@ -465,7 +468,7 @@ public class DriverAdapterCPDS
public String getUser() {
return user;
}
-
+
/**
* Set the value of default user (login or username).
* @param v Value to assign to user.
@@ -486,9 +489,9 @@ public class DriverAdapterCPDS
public String getDriver() {
return driver;
}
-
+
/**
- * Set the driver classname. Setting the driver classname cause the
+ * Set the driver classname. Setting the driver classname cause the
* driver to be registered with the DriverManager.
* @param v Value to assign to driver.
* @throws IllegalStateException if {@link #getPooledConnection()} has been called
@@ -499,42 +502,42 @@ public class DriverAdapterCPDS
// make sure driver is registered
Class.forName(v);
}
-
+
/**
- * Gets the maximum time in seconds that this data source can wait
+ * Gets the maximum time in seconds that this data source can wait
* while attempting to connect to a database. NOT USED.
*/
public int getLoginTimeout() {
return loginTimeout;
}
-
+
/**
* Get the log writer for this data source. NOT USED.
*/
public PrintWriter getLogWriter() {
return logWriter;
}
-
+
/**
- * Sets the maximum time in seconds that this data source will wait
+ * Sets the maximum time in seconds that this data source will wait
* while attempting to connect to a database. NOT USED.
*/
public void setLoginTimeout(int seconds) {
loginTimeout = seconds;
- }
-
+ }
+
/**
* Set the log writer for this data source. NOT USED.
*/
public void setLogWriter(java.io.PrintWriter out) {
logWriter = out;
- }
+ }
// ------------------------------------------------------------------
// PreparedStatement pool properties
-
+
/**
* Flag to toggle the pooling of <code>PreparedStatement</code>s
* @return value of poolPreparedStatements.
@@ -542,7 +545,7 @@ public class DriverAdapterCPDS
public boolean isPoolPreparedStatements() {
return poolPreparedStatements;
}
-
+
/**
* Flag to toggle the pooling of <code>PreparedStatement</code>s
* @param v true to pool statements.
@@ -584,7 +587,7 @@ public class DriverAdapterCPDS
/**
* The maximum number of statements that can remain idle in the
* pool, without extra ones being released, or negative for no limit.
- *
+ *
* @param maxIdle The maximum number of statements that can remain idle
* @throws IllegalStateException if {@link #getPooledConnection()} has been called
*/
@@ -638,7 +641,7 @@ public class DriverAdapterCPDS
* When a negative value is supplied, <tt>ceil({*link #numIdle})/abs({*link #getNumTestsPerEvictionRun})</tt>
* tests will be run. I.e., when the value is <i>-n</i>, roughly one <i>n</i>th of the
* idle objects will be tested per run.
- *
+ *
* @param numTestsPerEvictionRun number of statements to examine per run
* @see #getNumTestsPerEvictionRun()
* @see #setTimeBetweenEvictionRunsMillis(int)
@@ -676,10 +679,10 @@ public class DriverAdapterCPDS
assertInitializationAllowed();
_minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
}
-
+
/**
* Returns the value of the accessToUnderlyingConnectionAllowed property.
- *
+ *
* @return true if access to the underlying is allowed, false otherwise.
*/
public synchronized boolean isAccessToUnderlyingConnectionAllowed() {
@@ -690,16 +693,16 @@ public class DriverAdapterCPDS
* 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 synchronized void setAccessToUnderlyingConnectionAllowed(boolean allow) {
this.accessToUnderlyingConnectionAllowed = allow;
}
-
+
/**
* Returns the maximun number of prepared statements.
- *
+ *
* @return maxPrepartedStatements value
* @since 1.2.2
*/
@@ -710,13 +713,20 @@ public class DriverAdapterCPDS
/**
* Sets the maximum number of prepared statements.
- * @param maxPreparedStatements the new maximum number of prepared
+ * @param maxPreparedStatements the new maximum number of prepared
* statements
- *
+ *
* @since 1.2.2
*/
public void setMaxPreparedStatements(int maxPreparedStatements)
{
_maxPreparedStatements = maxPreparedStatements;
}
+
+ /* JDBC_4_1_ANT_KEY_BEGIN */
+ @Override
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ throw new SQLFeatureNotSupportedException();
+ }
+ /* JDBC_4_1_ANT_KEY_END */
}
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/datasources/InstanceKeyDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/datasources/InstanceKeyDataSource.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/datasources/InstanceKeyDataSource.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/datasources/InstanceKeyDataSource.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.
@@ -21,8 +21,10 @@ import java.io.Serializable;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
import java.util.NoSuchElementException;
import java.util.Properties;
+import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
@@ -38,7 +40,7 @@ import org.apache.commons.dbcp.SQLNested
import org.apache.commons.pool.impl.GenericObjectPool;
/**
- * <p>The base class for <code>SharedPoolDataSource</code> and
+ * <p>The base class for <code>SharedPoolDataSource</code> and
* <code>PerUserPoolDataSource</code>. Many of the configuration properties
* are shared and defined here. This class is declared public in order
* to allow particular usage with commons-beanutils; do not make direct
@@ -49,7 +51,7 @@ import org.apache.commons.pool.impl.Gene
* A J2EE container will normally provide some method of initializing the
* <code>DataSource</code> whose attributes are presented
* as bean getters/setters and then deploying it via JNDI. It is then
- * available to an application as a source of pooled logical connections to
+ * available to an application as a source of pooled logical connections to
* the database. The pool needs a source of physical connections. This
* source is in the form of a <code>ConnectionPoolDataSource</code> that
* can be specified via the {@link #setDataSourceName(String)} used to
@@ -58,25 +60,25 @@ import org.apache.commons.pool.impl.Gene
*
* <p>
* Although normally used within a JNDI environment, A DataSource
- * can be instantiated and initialized as any bean. In this case the
+ * can be instantiated and initialized as any bean. In this case the
* <code>ConnectionPoolDataSource</code> will likely be instantiated in
* a similar manner. This class allows the physical source of connections
- * to be attached directly to this pool using the
+ * to be attached directly to this pool using the
* {@link #setConnectionPoolDataSource(ConnectionPoolDataSource)} method.
* </p>
*
* <p>
- * The dbcp package contains an adapter,
+ * The dbcp package contains an adapter,
* {@link org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS},
* that can be used to allow the use of <code>DataSource</code>'s based on this
- * class with jdbc driver implementations that do not supply a
+ * class with jdbc driver implementations that do not supply a
* <code>ConnectionPoolDataSource</code>, but still
* provide a {@link java.sql.Driver} implementation.
* </p>
*
* <p>
- * The <a href="package-summary.html">package documentation</a> contains an
- * example using Apache Tomcat and JNDI and it also contains a non-JNDI example.
+ * The <a href="package-summary.html">package documentation</a> contains an
+ * example using Apache Tomcat and JNDI and it also contains a non-JNDI example.
* </p>
*
* @author John D. McNally
@@ -85,49 +87,49 @@ import org.apache.commons.pool.impl.Gene
public abstract class InstanceKeyDataSource
implements DataSource, Referenceable, Serializable {
private static final long serialVersionUID = -4243533936955098795L;
- private static final String GET_CONNECTION_CALLED
- = "A Connection was already requested from this source, "
+ private static final String GET_CONNECTION_CALLED
+ = "A Connection was already requested from this source, "
+ "further initialization is not allowed.";
private static final String BAD_TRANSACTION_ISOLATION
= "The requested TransactionIsolation level is invalid.";
/**
- * Internal constant to indicate the level is not set.
+ * Internal constant to indicate the level is not set.
*/
protected static final int UNKNOWN_TRANSACTIONISOLATION = -1;
-
+
/** Guards property setters - once true, setters throw IllegalStateException */
private volatile boolean getConnectionCalled = false;
/** Underlying source of PooledConnections */
private ConnectionPoolDataSource dataSource = null;
-
+
/** DataSource Name used to find the ConnectionPoolDataSource */
private String dataSourceName = null;
-
+
// Default connection properties
private boolean defaultAutoCommit = false;
private int defaultTransactionIsolation = UNKNOWN_TRANSACTIONISOLATION;
private boolean defaultReadOnly = false;
-
+
/** Description */
private String description = null;
-
+
/** Environment that may be used to set up a jndi initial context. */
Properties jndiEnvironment = null;
-
+
/** Login TimeOut in seconds */
private int loginTimeout = 0;
-
+
/** Log stream */
private PrintWriter logWriter = null;
-
+
// Pool properties
private boolean _testOnBorrow = GenericObjectPool.DEFAULT_TEST_ON_BORROW;
private boolean _testOnReturn = GenericObjectPool.DEFAULT_TEST_ON_RETURN;
private int _timeBetweenEvictionRunsMillis = (int)
Math.min(Integer.MAX_VALUE,
GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
- private int _numTestsPerEvictionRun =
+ private int _numTestsPerEvictionRun =
GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN;
private int _minEvictableIdleTimeMillis = (int)
Math.min(Integer.MAX_VALUE,
@@ -135,7 +137,7 @@ public abstract class InstanceKeyDataSou
private boolean _testWhileIdle = GenericObjectPool.DEFAULT_TEST_WHILE_IDLE;
private String validationQuery = null;
private boolean rollbackAfterValidation = false;
-
+
/** true iff one of the setters for testOnBorrow, testOnReturn, testWhileIdle has been called. */
private boolean testPositionSet = false;
@@ -164,7 +166,7 @@ public abstract class InstanceKeyDataSou
* Close the connection pool being maintained by this datasource.
*/
public abstract void close() throws Exception;
-
+
protected abstract PooledConnectionManager getConnectionManager(UserPassKey upkey);
/* JDBC_4_ANT_KEY_BEGIN */
@@ -177,6 +179,13 @@ public abstract class InstanceKeyDataSou
}
/* 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 */
+
// -------------------------------------------------------------------
// Properties
@@ -189,7 +198,7 @@ public abstract class InstanceKeyDataSou
public ConnectionPoolDataSource getConnectionPoolDataSource() {
return dataSource;
}
-
+
/**
* Set the backend ConnectionPoolDataSource. This property should not be
* set if using jndi to access the datasource.
@@ -202,7 +211,7 @@ public abstract class InstanceKeyDataSou
throw new IllegalStateException(
"Cannot set the DataSource, if JNDI is used.");
}
- if (dataSource != null)
+ if (dataSource != null)
{
throw new IllegalStateException(
"The CPDS has already been set. It cannot be altered.");
@@ -213,7 +222,7 @@ public abstract class InstanceKeyDataSou
/**
* Get the name of the ConnectionPoolDataSource which backs this pool.
- * This name is used to look up the datasource from a jndi service
+ * This name is used to look up the datasource from a jndi service
* provider.
*
* @return value of dataSourceName.
@@ -221,10 +230,10 @@ public abstract class InstanceKeyDataSou
public String getDataSourceName() {
return dataSourceName;
}
-
+
/**
* Set the name of the ConnectionPoolDataSource which backs this pool.
- * This name is used to look up the datasource from a jndi service
+ * This name is used to look up the datasource from a jndi service
* provider.
*
* @param v Value to assign to dataSourceName.
@@ -236,18 +245,18 @@ public abstract class InstanceKeyDataSou
"Cannot set the JNDI name for the DataSource, if already " +
"set using setConnectionPoolDataSource.");
}
- if (dataSourceName != null)
+ if (dataSourceName != null)
{
throw new IllegalStateException(
- "The DataSourceName has already been set. " +
+ "The DataSourceName has already been set. " +
"It cannot be altered.");
}
this.dataSourceName = v;
instanceKey = InstanceKeyObjectFactory.registerNewInstance(this);
}
- /**
- * Get the value of defaultAutoCommit, which defines the state of
+ /**
+ * Get the value of defaultAutoCommit, which defines the state of
* connections handed out from this pool. The value can be changed
* on the Connection using Connection.setAutoCommit(boolean).
* The default is true.
@@ -257,9 +266,9 @@ public abstract class InstanceKeyDataSou
public boolean isDefaultAutoCommit() {
return defaultAutoCommit;
}
-
+
/**
- * Set the value of defaultAutoCommit, which defines the state of
+ * Set the value of defaultAutoCommit, which defines the state of
* connections handed out from this pool. The value can be changed
* on the Connection using Connection.setAutoCommit(boolean).
* The default is true.
@@ -272,7 +281,7 @@ public abstract class InstanceKeyDataSou
}
/**
- * Get the value of defaultReadOnly, which defines the state of
+ * Get the value of defaultReadOnly, which defines the state of
* connections handed out from this pool. The value can be changed
* on the Connection using Connection.setReadOnly(boolean).
* The default is false.
@@ -282,9 +291,9 @@ public abstract class InstanceKeyDataSou
public boolean isDefaultReadOnly() {
return defaultReadOnly;
}
-
+
/**
- * Set the value of defaultReadOnly, which defines the state of
+ * Set the value of defaultReadOnly, which defines the state of
* connections handed out from this pool. The value can be changed
* on the Connection using Connection.setReadOnly(boolean).
* The default is false.
@@ -301,7 +310,7 @@ public abstract class InstanceKeyDataSou
* connections handed out from this pool. The value can be changed
* on the Connection using Connection.setTransactionIsolation(int).
* If this method returns -1, the default is JDBC driver dependent.
- *
+ *
* @return value of defaultTransactionIsolation.
*/
public int getDefaultTransactionIsolation() {
@@ -313,7 +322,7 @@ public abstract class InstanceKeyDataSou
* connections handed out from this pool. The value can be changed
* on the Connection using Connection.setTransactionIsolation(int).
* The default is JDBC driver dependent.
- *
+ *
* @param v Value to assign to defaultTransactionIsolation
*/
public void setDefaultTransactionIsolation(int v) {
@@ -330,7 +339,7 @@ public abstract class InstanceKeyDataSou
}
this.defaultTransactionIsolation = v;
}
-
+
/**
* Get the description. This property is defined by jdbc as for use with
* GUI (or other) tools that might deploy the datasource. It serves no
@@ -341,18 +350,18 @@ public abstract class InstanceKeyDataSou
public String getDescription() {
return description;
}
-
+
/**
* Set the description. This property is defined by jdbc as for use with
* GUI (or other) tools that might deploy the datasource. It serves no
* internal purpose.
- *
+ *
* @param v Value to assign to description.
*/
public void setDescription(String v) {
this.description = v;
}
-
+
/**
* Get the value of jndiEnvironment which is used when instantiating
* a jndi InitialContext. This InitialContext is used to locate the
@@ -367,12 +376,12 @@ public abstract class InstanceKeyDataSou
}
return value;
}
-
+
/**
* Sets the value of the given JNDI environment property to be used when
* instantiating a JNDI InitialContext. This InitialContext is used to
* locate the backend ConnectionPoolDataSource.
- *
+ *
* @param key the JNDI environment property to set.
* @param value the value assigned to specified JNDI environment property.
*/
@@ -382,7 +391,7 @@ public abstract class InstanceKeyDataSou
}
jndiEnvironment.setProperty(key, value);
}
-
+
/**
* Get the value of loginTimeout.
* @return value of loginTimeout.
@@ -390,7 +399,7 @@ public abstract class InstanceKeyDataSou
public int getLoginTimeout() {
return loginTimeout;
}
-
+
/**
* Set the value of loginTimeout.
* @param v Value to assign to loginTimeout.
@@ -398,7 +407,7 @@ public abstract class InstanceKeyDataSou
public void setLoginTimeout(int v) {
this.loginTimeout = v;
}
-
+
/**
* Get the value of logWriter.
* @return value of logWriter.
@@ -406,10 +415,10 @@ public abstract class InstanceKeyDataSou
public PrintWriter getLogWriter() {
if (logWriter == null) {
logWriter = new PrintWriter(System.out);
- }
+ }
return logWriter;
}
-
+
/**
* Set the value of logWriter.
* @param v Value to assign to logWriter.
@@ -417,14 +426,14 @@ public abstract class InstanceKeyDataSou
public void setLogWriter(PrintWriter v) {
this.logWriter = v;
}
-
+
/**
* @see #getTestOnBorrow
*/
public final boolean isTestOnBorrow() {
return getTestOnBorrow();
}
-
+
/**
* When <tt>true</tt>, objects will be
* {*link PoolableObjectFactory#validateObject validated}
@@ -463,7 +472,7 @@ public abstract class InstanceKeyDataSou
public final boolean isTestOnReturn() {
return getTestOnReturn();
}
-
+
/**
* When <tt>true</tt>, objects will be
* {*link PoolableObjectFactory#validateObject validated}
@@ -512,7 +521,7 @@ public abstract class InstanceKeyDataSou
*
* @see #getTimeBetweenEvictionRunsMillis
*/
- public void
+ public void
setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) {
assertInitializationAllowed();
_timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
@@ -578,7 +587,7 @@ public abstract class InstanceKeyDataSou
public final boolean isTestWhileIdle() {
return getTestWhileIdle();
}
-
+
/**
* When <tt>true</tt>, objects will be
* {*link PoolableObjectFactory#validateObject validated}
@@ -636,10 +645,10 @@ public abstract class InstanceKeyDataSou
}
/**
- * Whether a rollback will be issued after executing the SQL query
+ * Whether a rollback will be issued after executing the SQL query
* that will be used to validate connections from this pool
* before returning them to the caller.
- *
+ *
* @return true if a rollback will be issued after executing the
* validation query
* @since 1.2.2
@@ -649,12 +658,12 @@ public abstract class InstanceKeyDataSou
}
/**
- * Whether a rollback will be issued after executing the SQL query
+ * Whether a rollback will be issued after executing the SQL query
* that will be used to validate connections from this pool
* before returning them to the caller. Default behavior is NOT
* to issue a rollback. The setting will only have an effect
* if a validation query is set
- *
+ *
* @param rollbackAfterValidation new property value
* @since 1.2.2
*/
@@ -667,7 +676,7 @@ public abstract class InstanceKeyDataSou
// Instrumentation Methods
// ----------------------------------------------------------------------
- // DataSource implementation
+ // DataSource implementation
/**
* Attempt to establish a database connection.
@@ -685,13 +694,13 @@ public abstract class InstanceKeyDataSou
* did not match the password used to create the pooled connection. If the connection attempt succeeds, this
* means that the database password has been changed. In this case, the <code>PooledConnectionAndInfo</code>
* instance retrieved with the old password is destroyed and the <code>getPooledConnectionAndInfo</code> is
- * repeatedly invoked until a <code>PooledConnectionAndInfo</code> instance with the new password is returned.
- *
+ * repeatedly invoked until a <code>PooledConnectionAndInfo</code> instance with the new password is returned.
+ *
*/
public Connection getConnection(String username, String password)
- throws SQLException {
+ throws SQLException {
if (instanceKey == null) {
- throw new SQLException("Must set the ConnectionPoolDataSource "
+ throw new SQLException("Must set the ConnectionPoolDataSource "
+ "through setDataSourceName or setConnectionPoolDataSource"
+ " before calling getConnection.");
}
@@ -705,15 +714,15 @@ public abstract class InstanceKeyDataSou
} catch (RuntimeException e) {
closeDueToException(info);
throw e;
- } catch (SQLException e) {
+ } catch (SQLException e) {
closeDueToException(info);
throw e;
} catch (Exception e) {
closeDueToException(info);
throw new SQLNestedException("Cannot borrow connection from pool", e);
}
-
- if (!(null == password ? null == info.getPassword()
+
+ if (!(null == password ? null == info.getPassword()
: password.equals(info.getPassword()))) { // Password on PooledConnectionAndInfo does not match
try { // See if password has changed by attempting connection
testCPDS(username, password);
@@ -735,7 +744,7 @@ public abstract class InstanceKeyDataSou
manager.invalidate(info.getPooledConnection()); // Destroy and remove from pool
manager.setPassword(upkey.getPassword()); // Reset the password on the factory if using CPDSConnectionFactory
info = null;
- for (int i = 0; i < 10; i++) { // Bound the number of retries - only needed if bad instances return
+ for (int i = 0; i < 10; i++) { // Bound the number of retries - only needed if bad instances return
try {
info = getPooledConnectionAndInfo(username, password);
} catch (NoSuchElementException e) {
@@ -744,7 +753,7 @@ public abstract class InstanceKeyDataSou
} catch (RuntimeException e) {
closeDueToException(info);
throw e;
- } catch (SQLException e) {
+ } catch (SQLException e) {
closeDueToException(info);
throw e;
} catch (Exception e) {
@@ -759,21 +768,21 @@ public abstract class InstanceKeyDataSou
}
info = null;
}
- }
+ }
if (info == null) {
throw new SQLException("Cannot borrow connection from pool - password change failure.");
}
}
Connection con = info.getPooledConnection().getConnection();
- try {
+ try {
setupDefaults(con, username);
con.clearWarnings();
return con;
- } catch (SQLException ex) {
+ } catch (SQLException ex) {
try {
con.close();
- } catch (Exception exc) {
+ } catch (Exception exc) {
getLogWriter().println(
"ignoring exception during close: " + exc);
}
@@ -781,14 +790,14 @@ public abstract class InstanceKeyDataSou
}
}
- protected abstract PooledConnectionAndInfo
+ protected abstract PooledConnectionAndInfo
getPooledConnectionAndInfo(String username, String password)
throws SQLException;
- protected abstract void setupDefaults(Connection con, String username)
+ protected abstract void setupDefaults(Connection con, String username)
throws SQLException;
-
+
private void closeDueToException(PooledConnectionAndInfo info) {
if (info != null) {
try {
@@ -798,20 +807,20 @@ public abstract class InstanceKeyDataSou
// of handling another exception. But record it because
// it potentially leaks connections from the pool.
getLogWriter().println("[ERROR] Could not return connection to "
- + "pool during exception handling. " + e.getMessage());
+ + "pool during exception handling. " + e.getMessage());
}
}
}
- protected ConnectionPoolDataSource
+ protected ConnectionPoolDataSource
testCPDS(String username, String password)
throws javax.naming.NamingException, SQLException {
// The source of physical db connections
ConnectionPoolDataSource cpds = this.dataSource;
- if (cpds == null) {
+ if (cpds == null) {
Context ctx = null;
if (jndiEnvironment == null) {
- ctx = new InitialContext();
+ ctx = new InitialContext();
} else {
ctx = new InitialContext(jndiEnvironment);
}
@@ -825,7 +834,7 @@ public abstract class InstanceKeyDataSou
+ " doesn't implement javax.sql.ConnectionPoolDataSource");
}
}
-
+
// try to get a connection with the supplied username/password
PooledConnection conn = null;
try {
@@ -861,10 +870,10 @@ public abstract class InstanceKeyDataSou
whenExhausted = GenericObjectPool.WHEN_EXHAUSTED_FAIL;
}
return whenExhausted;
- }
+ }
// ----------------------------------------------------------------------
- // Referenceable implementation
+ // Referenceable implementation
/**
* Retrieves the Reference of this object.
@@ -879,10 +888,10 @@ public abstract class InstanceKeyDataSou
*/
// TODO: Remove the implementation of this method at next major
// version release.
-
+
public Reference getReference() throws NamingException {
final String className = getClass().getName();
- final String factoryName = className + "Factory"; // XXX: not robust
+ final String factoryName = className + "Factory"; // XXX: not robust
Reference ref = new Reference(className, factoryName, null);
ref.add(new StringRefAddr("instanceKey", instanceKey));
return ref;
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterCallableStatement.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterCallableStatement.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterCallableStatement.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterCallableStatement.java Tue Jan 29 13:11:04 2013
@@ -456,4 +456,18 @@ public class TesterCallableStatement ext
public void setNClob(String parameterName, Reader reader) throws SQLException {
}
/* JDBC_4_ANT_KEY_END */
+
+ /* JDBC_4_1_ANT_KEY_BEGIN */
+ @Override
+ public <T> T getObject(int parameterIndex, Class<T> type)
+ throws SQLException {
+ return null;
+ }
+
+ @Override
+ public <T> T getObject(String parameterName, Class<T> type)
+ throws SQLException {
+ return null;
+ }
+ /* JDBC_4_1_ANT_KEY_END */
}
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterConnection.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterConnection.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterConnection.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.
@@ -35,10 +35,11 @@ import java.sql.SQLXML;
import java.sql.Struct;
import java.util.Properties;
/* JDBC_4_ANT_KEY_END */
+import java.util.concurrent.Executor;
/**
* A dummy {@link Connection}, for testing purposes.
- *
+ *
* @author Rodney Waldhoff
* @author Dirk Verbeeck
* @version $Revision$ $Date$
@@ -60,7 +61,7 @@ public class TesterConnection implements
this.username = username;
this.password = password;
}
-
+
public String getUsername() {
return this.username;
}
@@ -209,17 +210,17 @@ public class TesterConnection implements
}
checkFailure();
}
-
+
protected void checkFailure() throws SQLException {
if (failure != null) {
throw (SQLException) new SQLException("TesterConnection failure").initCause(failure);
}
}
-
+
public void setFailure(Exception failure) {
this.failure = failure;
}
-
+
public int getHoldability() throws SQLException {
throw new SQLException("Not implemented.");
}
@@ -334,4 +335,32 @@ public class TesterConnection implements
throw new SQLException("Not implemented.");
}
/* JDBC_4_ANT_KEY_END */
+
+ /* JDBC_4_1_ANT_KEY_BEGIN */
+ @Override
+ public void setSchema(String schema) throws SQLException {
+ throw new SQLException("Not implemented.");
+ }
+
+ @Override
+ public String getSchema() throws SQLException {
+ throw new SQLException("Not implemented.");
+ }
+
+ @Override
+ public void abort(Executor executor) throws SQLException {
+ throw new SQLException("Not implemented.");
+ }
+
+ @Override
+ public void setNetworkTimeout(Executor executor, int milliseconds)
+ throws SQLException {
+ throw new SQLException("Not implemented.");
+ }
+
+ @Override
+ public int getNetworkTimeout() throws SQLException {
+ throw new SQLException("Not implemented.");
+ }
+ /* JDBC_4_1_ANT_KEY_END */
}
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterDatabaseMetaData.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterDatabaseMetaData.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterDatabaseMetaData.java Tue Jan 29 13:11:04 2013
@@ -69,15 +69,15 @@ public class TesterDatabaseMetaData impl
public String getCatalogSeparator() throws SQLException {
return null;
}
-
+
public String getCatalogTerm() throws SQLException {
return null;
}
-
+
public ResultSet getCatalogs() throws SQLException {
return null;
}
-
+
public ResultSet getColumnPrivileges(String catalog, String schema,
String table, String columnNamePattern) throws SQLException {
return null;
@@ -748,7 +748,7 @@ public class TesterDatabaseMetaData impl
public ResultSet getClientInfoProperties() throws SQLException {
return null;
}
-
+
public ResultSet getFunctionColumns(String catalog, String schemaPattern,
String functionNamePattern, String columnNamePattern)
throws SQLException {
@@ -759,6 +759,19 @@ public class TesterDatabaseMetaData impl
String functionNamePattern) throws SQLException {
return null;
}
-
/* 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 {
+ return null;
+ }
+
+ @Override
+ public boolean generatedKeyAlwaysReturned() throws SQLException {
+ return false;
+ }
+ /* JDBC_4_1_ANT_KEY_END */
}
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterDriver.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterDriver.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterDriver.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterDriver.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.
@@ -22,11 +22,13 @@ import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties;
+import java.util.logging.Logger;
/**
* Mock object implementing the <code>java.sql.Driver</code> interface.
- * Returns <code>TestConnection</code>'s from getConnection methods.
+ * Returns <code>TestConnection</code>'s from getConnection methods.
* Valid username, password combinations are:
*
* <table>
@@ -36,7 +38,7 @@ import java.util.Properties;
* <tr><td>u2</td><td>p2</td></tr>
* <tr><td>username</td><td>password</td></tr>
* </table>
- *
+ *
* @author Rodney Waldhoff
* @author Dirk Verbeeck
* @version $Revision$ $Date$
@@ -54,8 +56,8 @@ public class TesterDriver implements Dri
validUserPasswords.put("username", "password");
}
- /**
- * TesterDriver specific method to add users to the list of valid users
+ /**
+ * TesterDriver specific method to add users to the list of valid users
*/
public static void addUser(String username, String password) {
synchronized (validUserPasswords) {
@@ -67,7 +69,7 @@ public class TesterDriver implements Dri
return CONNECT_STRING.startsWith(url);
}
- private void assertValidUserPassword(String user, String password)
+ private void assertValidUserPassword(String user, String password)
throws SQLException {
synchronized (validUserPasswords) {
String realPassword = validUserPasswords.getProperty(user);
@@ -84,11 +86,11 @@ public class TesterDriver implements Dri
public Connection connect(String url, Properties info) throws SQLException {
//return (acceptsURL(url) ? new TesterConnection() : null);
Connection conn = null;
- if (acceptsURL(url))
+ if (acceptsURL(url))
{
String username = "test";
String password = "test";
- if (info != null)
+ if (info != null)
{
username = info.getProperty("user");
password = info.getProperty("password");
@@ -96,7 +98,7 @@ public class TesterDriver implements Dri
}
conn = new TesterConnection(username, password);
}
-
+
return conn;
}
@@ -116,6 +118,13 @@ public class TesterDriver implements Dri
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 */
+
protected static final String CONNECT_STRING = "jdbc:apache:commons:testdriver";
// version numbers
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterResultSet.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterResultSet.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterResultSet.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterResultSet.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.
@@ -38,7 +38,7 @@ import java.sql.SQLXML;
/**
* A dummy {@link ResultSet}, for testing purposes.
- *
+ *
* @author Rodney Waldhoff
* @author Dirk Verbeeck
* @version $Revision$ $Date$
@@ -59,13 +59,13 @@ public class TesterResultSet implements
_type = type;
_concurrency = concurrency;
}
-
+
protected int _type = ResultSet.TYPE_FORWARD_ONLY;
protected int _concurrency = ResultSet.CONCUR_READ_ONLY;
protected Object[][] _data = null;
protected int _currentRow = -1;
-
+
protected Statement _statement = null;
protected int _rowsLeft = 2;
protected boolean _open = true;
@@ -89,12 +89,12 @@ public class TesterResultSet implements
if (!_open) {
return;
}
-
+
// Not all result sets are generated from statements eg DatabaseMetaData
if (_statement != null) {
((TesterStatement)_statement)._resultSet = null;
}
-
+
_open = false;
}
@@ -969,4 +969,17 @@ public class TesterResultSet implements
throw new SQLException("Not implemented.");
}
/* JDBC_4_ANT_KEY_END */
+
+ /* JDBC_4_1_ANT_KEY_BEGIN */
+ @Override
+ public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
+ throw new SQLException("Not implemented.");
+ }
+
+ @Override
+ public <T> T getObject(String columnLabel, Class<T> type)
+ throws SQLException {
+ throw new SQLException("Not implemented.");
+ }
+ /* JDBC_4_1_ANT_KEY_END */
}
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterStatement.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterStatement.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterStatement.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TesterStatement.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.
@@ -25,7 +25,7 @@ import java.sql.Statement;
/**
* A dummy {@link Statement}, for testing purposes.
- *
+ *
* @author Rodney Waldhoff
* @author Dirk Verbeeck
* @version $Revision$ $Date$
@@ -40,7 +40,7 @@ public class TesterStatement implements
_resultSetType = resultSetType;
_resultSetConcurrency = resultSetConcurrency;
}
-
+
protected Connection _connection = null;
protected boolean _open = true;
protected int _rowsUpdated = 1;
@@ -60,20 +60,20 @@ public class TesterStatement implements
checkOpen();
if("null".equals(sql)) {
return null;
- }
+ }
if("invalid".equals(sql)) {
throw new SQLException("invalid query");
}
if ("broken".equals(sql)) {
throw new SQLException("broken connection");
- }
+ }
if("select username".equals(sql)) {
String username = ((TesterConnection) _connection).getUsername();
Object[][] data = {{username}};
return new TesterResultSet(this, data);
} else {
// Simulate timeout if queryTimout is set to less than 5 seconds
- if (_queryTimeout > 0 && _queryTimeout < 5) {
+ if (_queryTimeout > 0 && _queryTimeout < 5) {
throw new SQLException("query timeout");
}
return new TesterResultSet(this);
@@ -162,7 +162,7 @@ public class TesterStatement implements
public ResultSet getResultSet() throws SQLException {
checkOpen();
if (_resultSet == null) {
- _resultSet = new TesterResultSet(this);
+ _resultSet = new TesterResultSet(this);
}
return _resultSet;
}
@@ -296,4 +296,15 @@ public class TesterStatement implements
throw new SQLException("Not implemented.");
}
/* JDBC_4_ANT_KEY_END */
+
+ /* JDBC_4_1_ANT_KEY_BEGIN */
+ @Override
+ public void closeOnCompletion() throws SQLException {
+ }
+
+ @Override
+ public boolean isCloseOnCompletion() throws SQLException {
+ return false;
+ }
+ /* JDBC_4_1_ANT_KEY_END */
}
Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/datasources/ConnectionPoolDataSourceProxy.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/datasources/ConnectionPoolDataSourceProxy.java?rev=1439882&r1=1439881&r2=1439882&view=diff
==============================================================================
--- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/datasources/ConnectionPoolDataSourceProxy.java (original)
+++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/datasources/ConnectionPoolDataSourceProxy.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.
@@ -19,31 +19,34 @@ package org.apache.commons.dbcp.datasour
import java.io.PrintWriter;
import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.logging.Logger;
+
import javax.sql.ConnectionPoolDataSource;
import javax.sql.PooledConnection;
/**
- * ConnectionPoolDataSource implementation that proxies another
+ * ConnectionPoolDataSource implementation that proxies another
* ConnectionPoolDataSource.
- *
+ *
* @version $Revision$ $Date$
*/
public class ConnectionPoolDataSourceProxy implements ConnectionPoolDataSource {
protected ConnectionPoolDataSource delegate = null;
-
+
public ConnectionPoolDataSourceProxy(ConnectionPoolDataSource cpds) {
this.delegate = cpds;
}
-
+
public ConnectionPoolDataSource getDelegate() {
return delegate;
}
-
+
public int getLoginTimeout() throws SQLException {
return delegate.getLoginTimeout();
}
-
+
public PrintWriter getLogWriter() throws SQLException {
return delegate.getLogWriter();
}
@@ -64,20 +67,26 @@ public class ConnectionPoolDataSourcePro
}
public void setLoginTimeout(int seconds) throws SQLException {
- delegate.setLoginTimeout(seconds);
+ delegate.setLoginTimeout(seconds);
}
public void setLogWriter(PrintWriter out) throws SQLException {
- delegate.setLogWriter(out);
+ delegate.setLogWriter(out);
}
-
+
/**
* Create a TesterPooledConnection with notifyOnClose turned on
*/
protected PooledConnection wrapPooledConnection(PooledConnection pc) {
PooledConnectionProxy tpc = new PooledConnectionProxy(pc);
tpc.setNotifyOnClose(true);
- return tpc;
+ return tpc;
}
+ /* JDBC_4_1_ANT_KEY_BEGIN */
+ @Override
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ throw new SQLFeatureNotSupportedException();
+ }
+ /* JDBC_4_1_ANT_KEY_END */
}