You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/06/12 14:14:24 UTC
[4/4] commons-dbcp git commit: Line length 120.
Line length 120.
Project: http://git-wip-us.apache.org/repos/asf/commons-dbcp/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbcp/commit/d5a24430
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbcp/tree/d5a24430
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbcp/diff/d5a24430
Branch: refs/heads/master
Commit: d5a24430061654ac5319ba1392415e7f3958a475
Parents: c43bd77
Author: Gary Gregory <ga...@gmail.com>
Authored: Tue Jun 12 08:14:16 2018 -0600
Committer: Gary Gregory <ga...@gmail.com>
Committed: Tue Jun 12 08:14:16 2018 -0600
----------------------------------------------------------------------
.../apache/commons/dbcp2/AbandonedTrace.java | 10 +-
.../apache/commons/dbcp2/BasicDataSource.java | 53 +-
.../commons/dbcp2/BasicDataSourceFactory.java | 236 ++-
.../apache/commons/dbcp2/ConnectionFactory.java | 6 +-
.../commons/dbcp2/DelegatingConnection.java | 319 ++--
.../dbcp2/DelegatingDatabaseMetaData.java | 1199 +++++++++----
.../commons/dbcp2/DelegatingResultSet.java | 1580 +++++++++++++-----
.../commons/dbcp2/DelegatingStatement.java | 46 +-
.../dbcp2/DriverManagerConnectionFactory.java | 32 +-
.../dbcp2/LifetimeExceededException.java | 5 +-
.../dbcp2/PoolableCallableStatement.java | 26 +-
.../dbcp2/PoolableConnectionFactory.java | 20 +-
.../commons/dbcp2/PoolableConnectionMXBean.java | 17 +-
.../dbcp2/PoolablePreparedStatement.java | 39 +-
.../apache/commons/dbcp2/PoolingDataSource.java | 27 +-
.../org/apache/commons/dbcp2/PoolingDriver.java | 60 +-
.../commons/dbcp2/SwallowedExceptionLogger.java | 21 +-
.../org/apache/commons/dbcp2/package-info.java | 207 +--
18 files changed, 2530 insertions(+), 1373 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/d5a24430/src/main/java/org/apache/commons/dbcp2/AbandonedTrace.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbcp2/AbandonedTrace.java b/src/main/java/org/apache/commons/dbcp2/AbandonedTrace.java
index 77b5441..659fe76 100644
--- a/src/main/java/org/apache/commons/dbcp2/AbandonedTrace.java
+++ b/src/main/java/org/apache/commons/dbcp2/AbandonedTrace.java
@@ -50,7 +50,8 @@ public class AbandonedTrace implements TrackedUse {
/**
* Constructs a new AbandonedTrace with a parent object.
*
- * @param parent AbandonedTrace parent object.
+ * @param parent
+ * AbandonedTrace parent object.
*/
public AbandonedTrace(final AbandonedTrace parent) {
init(parent);
@@ -59,7 +60,8 @@ public class AbandonedTrace implements TrackedUse {
/**
* Initializes abandoned tracing for this object.
*
- * @param parent AbandonedTrace parent object.
+ * @param parent
+ * AbandonedTrace parent object.
*/
private void init(final AbandonedTrace parent) {
if (parent != null) {
@@ -111,7 +113,7 @@ public class AbandonedTrace implements TrackedUse {
* Clears the list of objects being traced by this object.
*/
protected void clearTrace() {
- synchronized(this.traceList) {
+ synchronized (this.traceList) {
this.traceList.clear();
}
}
@@ -149,7 +151,7 @@ public class AbandonedTrace implements TrackedUse {
* AbandonedTrace object to remove.
*/
protected void removeTrace(final AbandonedTrace trace) {
- synchronized(this.traceList) {
+ synchronized (this.traceList) {
final Iterator<WeakReference<AbandonedTrace>> iter = traceList.iterator();
while (iter.hasNext()) {
final AbandonedTrace traceInList = iter.next().get();
http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/d5a24430/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java b/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
index 861238f..d940e7e 100644
--- a/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
+++ b/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
@@ -129,7 +129,6 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
this.defaultAutoCommit = defaultAutoCommit;
}
-
/**
* The default read-only state of connections created by this pool.
*/
@@ -165,8 +164,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
/**
* The default TransactionIsolation state of connections created by this pool.
*/
- private volatile int defaultTransactionIsolation =
- PoolableConnectionFactory.UNKNOWN_TRANSACTIONISOLATION;
+ private volatile int defaultTransactionIsolation = PoolableConnectionFactory.UNKNOWN_TRANSACTIONISOLATION;
/**
* Returns the default transaction isolation state of returned connections.
@@ -197,7 +195,6 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
this.defaultTransactionIsolation = defaultTransactionIsolation;
}
-
private Integer defaultQueryTimeoutSeconds;
/**
@@ -210,7 +207,6 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
return defaultQueryTimeoutSeconds;
}
-
/**
* Sets the default query timeout that will be used for {@link java.sql.Statement Statement}s created from this
* connection. <code>null</code> means that the driver default will be used.
@@ -222,7 +218,6 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
this.defaultQueryTimeoutSeconds = defaultQueryTimeoutSeconds;
}
-
/**
* The default "catalog" of connections created by this pool.
*/
@@ -254,8 +249,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
public void setDefaultCatalog(final String defaultCatalog) {
if (defaultCatalog != null && defaultCatalog.trim().length() > 0) {
this.defaultCatalog = defaultCatalog;
- }
- else {
+ } else {
this.defaultCatalog = null;
}
}
@@ -354,8 +348,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
public synchronized void setDriverClassName(final String driverClassName) {
if (driverClassName != null && driverClassName.trim().length() > 0) {
this.driverClassName = driverClassName;
- }
- else {
+ } else {
this.driverClassName = null;
}
}
@@ -535,10 +528,10 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
* @see GenericObjectPool#setMinIdle(int)
*/
public synchronized void setMinIdle(final int minIdle) {
- this.minIdle = minIdle;
- if (connectionPool != null) {
- connectionPool.setMinIdle(minIdle);
- }
+ this.minIdle = minIdle;
+ if (connectionPool != null) {
+ connectionPool.setMinIdle(minIdle);
+ }
}
/**
@@ -577,8 +570,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
* The maximum number of milliseconds that the pool will wait (when there are no available connections) for a
* connection to be returned before throwing an exception, or <= 0 to wait indefinitely.
*/
- private long maxWaitMillis =
- BaseObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS;
+ private long maxWaitMillis = BaseObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS;
/**
* Returns the maximum number of milliseconds that the pool will wait for a connection to be returned before
@@ -1541,7 +1533,8 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
* @param pass
* The database user's password
*
- * @throws UnsupportedOperationException always thrown.
+ * @throws UnsupportedOperationException
+ * always thrown.
* @throws SQLException
* if a database access error occurs
* @return nothing - always throws UnsupportedOperationException
@@ -1651,9 +1644,9 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
* following conditions hold:
* </p>
* <ul>
- * <li>{@link #getRemoveAbandonedOnBorrow()}</li>
- * <li>{@link #getNumActive()} > {@link #getMaxTotal()} - 3</li>
- * <li>{@link #getNumIdle()} < 2</li>
+ * <li>{@link #getRemoveAbandonedOnBorrow()}</li>
+ * <li>{@link #getNumActive()} > {@link #getMaxTotal()} - 3</li>
+ * <li>{@link #getNumIdle()} < 2</li>
* </ul>
*
* @see #getRemoveAbandonedTimeout()
@@ -1734,9 +1727,9 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
* Abandoned connection cleanup happens when:
* </p>
* <ul>
- * <li>{@link #getRemoveAbandonedOnBorrow()} or {@link #getRemoveAbandonedOnMaintenance()} = true</li>
- * <li>{@link #getNumIdle() numIdle} < 2</li>
- * <li>{@link #getNumActive() numActive} > {@link #getMaxTotal() maxTotal} - 3</li>
+ * <li>{@link #getRemoveAbandonedOnBorrow()} or {@link #getRemoveAbandonedOnMaintenance()} = true</li>
+ * <li>{@link #getNumIdle() numIdle} < 2</li>
+ * <li>{@link #getNumActive() numActive} > {@link #getMaxTotal() maxTotal} - 3</li>
* </ul>
* <p>
* The default value is 300 seconds.
@@ -2132,13 +2125,13 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
/**
* Creates a JDBC connection factory for this datasource. The JDBC driver is loaded using the following algorithm:
* <ol>
- * <li>If a Driver instance has been specified via {@link #setDriver(Driver)} use it</li>
- * <li>If no Driver instance was specified and {@link #driverClassName} is specified that class is loaded using the
- * {@link ClassLoader} of this class or, if {@link #driverClassLoader} is set, {@link #driverClassName} is loaded
- * with the specified {@link ClassLoader}.</li>
- * <li>If {@link #driverClassName} is specified and the previous attempt fails, the class is loaded using the
- * context class loader of the current thread.</li>
- * <li>If a driver still isn't loaded one is loaded via the {@link DriverManager} using the specified {@link #url}.
+ * <li>If a Driver instance has been specified via {@link #setDriver(Driver)} use it</li>
+ * <li>If no Driver instance was specified and {@link #driverClassName} is specified that class is loaded using the
+ * {@link ClassLoader} of this class or, if {@link #driverClassLoader} is set, {@link #driverClassName} is loaded
+ * with the specified {@link ClassLoader}.</li>
+ * <li>If {@link #driverClassName} is specified and the previous attempt fails, the class is loaded using the
+ * context class loader of the current thread.</li>
+ * <li>If a driver still isn't loaded one is loaded via the {@link DriverManager} using the specified {@link #url}.
* </ol>
* This method exists so subclasses can replace the implementation class.
*/
http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/d5a24430/src/main/java/org/apache/commons/dbcp2/BasicDataSourceFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbcp2/BasicDataSourceFactory.java b/src/main/java/org/apache/commons/dbcp2/BasicDataSourceFactory.java
index dfd27e9..46af519 100644
--- a/src/main/java/org/apache/commons/dbcp2/BasicDataSourceFactory.java
+++ b/src/main/java/org/apache/commons/dbcp2/BasicDataSourceFactory.java
@@ -43,15 +43,14 @@ import org.apache.commons.pool2.impl.BaseObjectPoolConfig;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
/**
- * <p>JNDI object factory that creates an instance of
- * <code>BasicDataSource</code> that has been configured based on the
- * <code>RefAddr</code> values of the specified <code>Reference</code>, which
- * must match the names and data types of the <code>BasicDataSource</code> bean
- * properties with the following exceptions:</p>
+ * <p>
+ * JNDI object factory that creates an instance of <code>BasicDataSource</code> that has been configured based on the
+ * <code>RefAddr</code> values of the specified <code>Reference</code>, which must match the names and data types of the
+ * <code>BasicDataSource</code> bean properties with the following exceptions:
+ * </p>
* <ul>
- * <li><code>connectionInitSqls</code> must be passed to this factory as a
- * single String using semi-colon to delimit the statements whereas
- * <code>BasicDataSource</code> requires a collection of Strings.</li>
+ * <li><code>connectionInitSqls</code> must be passed to this factory as a single String using semi-colon to delimit the
+ * statements whereas <code>BasicDataSource</code> requires a collection of Strings.</li>
* </ul>
*
* @since 2.0
@@ -64,7 +63,7 @@ public class BasicDataSourceFactory implements ObjectFactory {
private static final String PROP_DEFAULTREADONLY = "defaultReadOnly";
private static final String PROP_DEFAULTTRANSACTIONISOLATION = "defaultTransactionIsolation";
private static final String PROP_DEFAULTCATALOG = "defaultCatalog";
- private static final String PROP_CACHESTATE ="cacheState";
+ private static final String PROP_CACHESTATE = "cacheState";
private static final String PROP_DRIVERCLASSNAME = "driverClassName";
private static final String PROP_LIFO = "lifo";
private static final String PROP_MAXTOTAL = "maxTotal";
@@ -89,8 +88,7 @@ public class BasicDataSourceFactory implements ObjectFactory {
private static final String PROP_JMX_NAME = "jmxName";
/**
- * The property name for connectionInitSqls.
- * The associated value String must be of the form [query;]*
+ * The property name for connectionInitSqls. The associated value String must be of the form [query;]*
*/
private static final String PROP_CONNECTIONINITSQLS = "connectionInitSqls";
private static final String PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED = "accessToUnderlyingConnectionAllowed";
@@ -115,99 +113,58 @@ public class BasicDataSourceFactory implements ObjectFactory {
private static final String PROP_DISCONNECTION_SQL_CODES = "disconnectionSqlCodes";
/*
- * Block with obsolete properties from DBCP 1.x.
- * Warn users that these are ignored and they should use the 2.x properties.
+ * Block with obsolete properties from DBCP 1.x. Warn users that these are ignored and they should use the 2.x
+ * properties.
*/
private static final String NUPROP_MAXACTIVE = "maxActive";
private static final String NUPROP_REMOVEABANDONED = "removeAbandoned";
private static final String NUPROP_MAXWAIT = "maxWait";
/*
- * Block with properties expected in a DataSource
- * This props will not be listed as ignored - we know that they may appear in Resource,
- * and not listing them as ignored.
+ * Block with properties expected in a DataSource This props will not be listed as ignored - we know that they may
+ * appear in Resource, and not listing them as ignored.
*/
private static final String SILENTPROP_FACTORY = "factory";
private static final String SILENTPROP_SCOPE = "scope";
private static final String SILENTPROP_SINGLETON = "singleton";
private static final String SILENTPROP_AUTH = "auth";
- private static final String[] ALL_PROPERTIES = {
- PROP_DEFAULTAUTOCOMMIT,
- PROP_DEFAULTREADONLY,
- PROP_DEFAULTTRANSACTIONISOLATION,
- PROP_DEFAULTCATALOG,
- PROP_CACHESTATE,
- PROP_DRIVERCLASSNAME,
- PROP_LIFO,
- PROP_MAXTOTAL,
- PROP_MAXIDLE,
- PROP_MINIDLE,
- PROP_INITIALSIZE,
- PROP_MAXWAITMILLIS,
- PROP_TESTONCREATE,
- PROP_TESTONBORROW,
- PROP_TESTONRETURN,
- PROP_TIMEBETWEENEVICTIONRUNSMILLIS,
- PROP_NUMTESTSPEREVICTIONRUN,
- PROP_MINEVICTABLEIDLETIMEMILLIS,
- PROP_SOFTMINEVICTABLEIDLETIMEMILLIS,
- PROP_EVICTIONPOLICYCLASSNAME,
- PROP_TESTWHILEIDLE,
- PROP_PASSWORD,
- PROP_URL,
- PROP_USERNAME,
- PROP_VALIDATIONQUERY,
- PROP_VALIDATIONQUERY_TIMEOUT,
- PROP_CONNECTIONINITSQLS,
- PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED,
- PROP_REMOVEABANDONEDONBORROW,
- PROP_REMOVEABANDONEDONMAINTENANCE,
- PROP_REMOVEABANDONEDTIMEOUT,
- PROP_LOGABANDONED,
- PROP_ABANDONEDUSAGETRACKING,
- PROP_POOLPREPAREDSTATEMENTS,
- PROP_MAXOPENPREPAREDSTATEMENTS,
- PROP_CONNECTIONPROPERTIES,
- PROP_MAXCONNLIFETIMEMILLIS,
- PROP_LOGEXPIREDCONNECTIONS,
- PROP_ROLLBACK_ON_RETURN,
- PROP_ENABLE_AUTOCOMMIT_ON_RETURN,
- PROP_DEFAULT_QUERYTIMEOUT,
- PROP_FASTFAIL_VALIDATION,
- PROP_DISCONNECTION_SQL_CODES,
- PROP_JMX_NAME
- };
+ private static final String[] ALL_PROPERTIES = {PROP_DEFAULTAUTOCOMMIT, PROP_DEFAULTREADONLY,
+ PROP_DEFAULTTRANSACTIONISOLATION, PROP_DEFAULTCATALOG, PROP_CACHESTATE, PROP_DRIVERCLASSNAME, PROP_LIFO,
+ PROP_MAXTOTAL, PROP_MAXIDLE, PROP_MINIDLE, PROP_INITIALSIZE, PROP_MAXWAITMILLIS, PROP_TESTONCREATE,
+ PROP_TESTONBORROW, PROP_TESTONRETURN, PROP_TIMEBETWEENEVICTIONRUNSMILLIS, PROP_NUMTESTSPEREVICTIONRUN,
+ PROP_MINEVICTABLEIDLETIMEMILLIS, PROP_SOFTMINEVICTABLEIDLETIMEMILLIS, PROP_EVICTIONPOLICYCLASSNAME,
+ PROP_TESTWHILEIDLE, PROP_PASSWORD, PROP_URL, PROP_USERNAME, PROP_VALIDATIONQUERY,
+ PROP_VALIDATIONQUERY_TIMEOUT, PROP_CONNECTIONINITSQLS, PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED,
+ PROP_REMOVEABANDONEDONBORROW, PROP_REMOVEABANDONEDONMAINTENANCE, PROP_REMOVEABANDONEDTIMEOUT,
+ PROP_LOGABANDONED, PROP_ABANDONEDUSAGETRACKING, PROP_POOLPREPAREDSTATEMENTS, PROP_MAXOPENPREPAREDSTATEMENTS,
+ PROP_CONNECTIONPROPERTIES, PROP_MAXCONNLIFETIMEMILLIS, PROP_LOGEXPIREDCONNECTIONS, PROP_ROLLBACK_ON_RETURN,
+ PROP_ENABLE_AUTOCOMMIT_ON_RETURN, PROP_DEFAULT_QUERYTIMEOUT, PROP_FASTFAIL_VALIDATION,
+ PROP_DISCONNECTION_SQL_CODES, PROP_JMX_NAME };
/**
- * Obsolete properties from DBCP 1.x. with warning strings suggesting
- * new properties. LinkedHashMap will guarantee that properties will be listed
- * to output in order of insertion into map.
+ * Obsolete properties from DBCP 1.x. with warning strings suggesting new properties. LinkedHashMap will guarantee
+ * that properties will be listed to output in order of insertion into map.
*/
private static final Map<String, String> NUPROP_WARNTEXT = new LinkedHashMap<>();
static {
- NUPROP_WARNTEXT.put(
- NUPROP_MAXACTIVE,
+ NUPROP_WARNTEXT.put(NUPROP_MAXACTIVE,
"Property " + NUPROP_MAXACTIVE + " is not used in DBCP2, use " + PROP_MAXTOTAL + " instead. "
- + PROP_MAXTOTAL + " default value is " + GenericObjectPoolConfig.DEFAULT_MAX_TOTAL+".");
- NUPROP_WARNTEXT.put(
- NUPROP_REMOVEABANDONED,
- "Property " + NUPROP_REMOVEABANDONED + " is not used in DBCP2,"
- + " use one or both of "
+ + PROP_MAXTOTAL + " default value is " + GenericObjectPoolConfig.DEFAULT_MAX_TOTAL + ".");
+ NUPROP_WARNTEXT.put(NUPROP_REMOVEABANDONED,
+ "Property " + NUPROP_REMOVEABANDONED + " is not used in DBCP2," + " use one or both of "
+ PROP_REMOVEABANDONEDONBORROW + " or " + PROP_REMOVEABANDONEDONMAINTENANCE + " instead. "
+ "Both have default value set to false.");
- NUPROP_WARNTEXT.put(
- NUPROP_MAXWAIT,
- "Property " + NUPROP_MAXWAIT + " is not used in DBCP2"
- + " , use " + PROP_MAXWAITMILLIS + " instead. "
- + PROP_MAXWAITMILLIS + " default value is " + BaseObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS+".");
+ NUPROP_WARNTEXT.put(NUPROP_MAXWAIT,
+ "Property " + NUPROP_MAXWAIT + " is not used in DBCP2" + " , use " + PROP_MAXWAITMILLIS + " instead. "
+ + PROP_MAXWAITMILLIS + " default value is " + BaseObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS
+ + ".");
}
/**
- * Silent Properties.
- * These properties will not be listed as ignored - we know that they may appear in JDBC Resource references,
- * and we will not list them as ignored.
+ * Silent Properties. These properties will not be listed as ignored - we know that they may appear in JDBC Resource
+ * references, and we will not list them as ignored.
*/
private static final List<String> SILENT_PROPERTIES = new ArrayList<>();
@@ -222,23 +179,28 @@ public class BasicDataSourceFactory implements ObjectFactory {
// -------------------------------------------------- ObjectFactory Methods
/**
- * <p>Create and return a new <code>BasicDataSource</code> instance. If no
- * instance can be created, return <code>null</code> instead.</p>
+ * <p>
+ * Create and return a new <code>BasicDataSource</code> instance. If no instance can be created, return
+ * <code>null</code> instead.
+ * </p>
*
- * @param obj The possibly null object containing location or
- * reference information that can be used in creating an object
- * @param name The name of this object relative to <code>nameCtx</code>
- * @param nameCtx The context relative to which the <code>name</code>
- * parameter is specified, or <code>null</code> if <code>name</code>
- * is relative to the default initial context
- * @param environment The possibly null environment that is used in
- * creating this object
+ * @param obj
+ * The possibly null object containing location or reference information that can be used in creating an
+ * object
+ * @param name
+ * The name of this object relative to <code>nameCtx</code>
+ * @param nameCtx
+ * The context relative to which the <code>name</code> parameter is specified, or <code>null</code> if
+ * <code>name</code> is relative to the default initial context
+ * @param environment
+ * The possibly null environment that is used in creating this object
*
- * @throws Exception if an exception occurs creating the instance
+ * @throws Exception
+ * if an exception occurs creating the instance
*/
@Override
- public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable<?,?> environment)
- throws Exception {
+ public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx,
+ final Hashtable<?, ?> environment) throws Exception {
// We only know how to deal with <code>javax.naming.Reference</code>s
// that specify a class name of "javax.sql.DataSource"
@@ -274,29 +236,30 @@ public class BasicDataSourceFactory implements ObjectFactory {
}
/**
- * Collects warnings and info messages. Warnings are generated when an obsolete
- * property is set. Unknown properties generate info messages.
+ * Collects warnings and info messages. Warnings are generated when an obsolete property is set. Unknown properties
+ * generate info messages.
*
- * @param ref Reference to check properties of
- * @param name Name provided to getObject
- * @param warnings container for warning messages
- * @param infoMessages container for info messages
+ * @param ref
+ * Reference to check properties of
+ * @param name
+ * Name provided to getObject
+ * @param warnings
+ * container for warning messages
+ * @param infoMessages
+ * container for info messages
*/
private void validatePropertyNames(final Reference ref, final Name name, final List<String> warnings,
- final List<String> infoMessages) {
+ final List<String> infoMessages) {
final List<String> allPropsAsList = Arrays.asList(ALL_PROPERTIES);
final String nameString = name != null ? "Name = " + name.toString() + " " : "";
- if (NUPROP_WARNTEXT!=null && !NUPROP_WARNTEXT.keySet().isEmpty()) {
+ if (NUPROP_WARNTEXT != null && !NUPROP_WARNTEXT.keySet().isEmpty()) {
for (final String propertyName : NUPROP_WARNTEXT.keySet()) {
final RefAddr ra = ref.get(propertyName);
if (ra != null && !allPropsAsList.contains(ra.getType())) {
final StringBuilder stringBuilder = new StringBuilder(nameString);
final String propertyValue = ra.getContent().toString();
- stringBuilder.append(NUPROP_WARNTEXT.get(propertyName))
- .append(" You have set value of \"")
- .append(propertyValue)
- .append("\" for \"")
- .append(propertyName)
+ stringBuilder.append(NUPROP_WARNTEXT.get(propertyName)).append(" You have set value of \"")
+ .append(propertyValue).append("\" for \"").append(propertyName)
.append("\" property, which is being ignored.");
warnings.add(stringBuilder.toString());
}
@@ -309,17 +272,12 @@ public class BasicDataSourceFactory implements ObjectFactory {
final String propertyName = ra.getType();
// If property name is not in the properties list, we haven't warned on it
// and it is not in the "silent" list, tell user we are ignoring it.
- if (!(allPropsAsList.contains(propertyName)
- || NUPROP_WARNTEXT.keySet().contains(propertyName)
+ if (!(allPropsAsList.contains(propertyName) || NUPROP_WARNTEXT.keySet().contains(propertyName)
|| SILENT_PROPERTIES.contains(propertyName))) {
final String propertyValue = ra.getContent().toString();
final StringBuilder stringBuilder = new StringBuilder(nameString);
- stringBuilder.append("Ignoring unknown property: ")
- .append("value of \"")
- .append(propertyValue)
- .append("\" for \"")
- .append(propertyName)
- .append("\" property");
+ stringBuilder.append("Ignoring unknown property: ").append("value of \"").append(propertyValue)
+ .append("\" for \"").append(propertyName).append("\" property");
infoMessages.add(stringBuilder.toString());
}
}
@@ -353,20 +311,15 @@ public class BasicDataSourceFactory implements ObjectFactory {
int level = PoolableConnectionFactory.UNKNOWN_TRANSACTIONISOLATION;
if ("NONE".equalsIgnoreCase(value)) {
level = Connection.TRANSACTION_NONE;
- }
- else if ("READ_COMMITTED".equalsIgnoreCase(value)) {
+ } else if ("READ_COMMITTED".equalsIgnoreCase(value)) {
level = Connection.TRANSACTION_READ_COMMITTED;
- }
- else if ("READ_UNCOMMITTED".equalsIgnoreCase(value)) {
+ } else if ("READ_UNCOMMITTED".equalsIgnoreCase(value)) {
level = Connection.TRANSACTION_READ_UNCOMMITTED;
- }
- else if ("REPEATABLE_READ".equalsIgnoreCase(value)) {
+ } else if ("REPEATABLE_READ".equalsIgnoreCase(value)) {
level = Connection.TRANSACTION_REPEATABLE_READ;
- }
- else if ("SERIALIZABLE".equalsIgnoreCase(value)) {
+ } else if ("SERIALIZABLE".equalsIgnoreCase(value)) {
level = Connection.TRANSACTION_SERIALIZABLE;
- }
- else {
+ } else {
try {
level = Integer.parseInt(value);
} catch (final NumberFormatException e) {
@@ -541,12 +494,12 @@ public class BasicDataSourceFactory implements ObjectFactory {
value = properties.getProperty(PROP_CONNECTIONPROPERTIES);
if (value != null) {
- final Properties p = getProperties(value);
- final Enumeration<?> e = p.propertyNames();
- while (e.hasMoreElements()) {
- final String propertyName = (String) e.nextElement();
- dataSource.addConnectionProperty(propertyName, p.getProperty(propertyName));
- }
+ final Properties p = getProperties(value);
+ final Enumeration<?> e = p.propertyNames();
+ while (e.hasMoreElements()) {
+ final String propertyName = (String) e.nextElement();
+ dataSource.addConnectionProperty(propertyName, p.getProperty(propertyName));
+ }
}
value = properties.getProperty(PROP_MAXCONNLIFETIMEMILLIS);
@@ -600,24 +553,29 @@ public class BasicDataSourceFactory implements ObjectFactory {
}
/**
- * <p>Parse properties from the string. Format of the string must be [propertyName=property;]*<p>
+ * <p>
+ * Parse properties from the string. Format of the string must be [propertyName=property;]*
+ * <p>
+ *
* @param propText
* @return Properties
* @throws Exception
*/
private static Properties getProperties(final String propText) throws Exception {
- final Properties p = new Properties();
- if (propText != null) {
- p.load(new ByteArrayInputStream(
- propText.replace(';', '\n').getBytes(StandardCharsets.ISO_8859_1)));
- }
- return p;
+ final Properties p = new Properties();
+ if (propText != null) {
+ p.load(new ByteArrayInputStream(propText.replace(';', '\n').getBytes(StandardCharsets.ISO_8859_1)));
+ }
+ return p;
}
/**
* Parse list of property values from a delimited string
- * @param value delimited list of values
- * @param delimiter character used to separate values in the list
+ *
+ * @param value
+ * delimited list of values
+ * @param delimiter
+ * character used to separate values in the list
* @return String Collection of values
*/
private static Collection<String> parseList(final String value, final char delimiter) {
http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/d5a24430/src/main/java/org/apache/commons/dbcp2/ConnectionFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbcp2/ConnectionFactory.java b/src/main/java/org/apache/commons/dbcp2/ConnectionFactory.java
index 38ea381..e49c654 100644
--- a/src/main/java/org/apache/commons/dbcp2/ConnectionFactory.java
+++ b/src/main/java/org/apache/commons/dbcp2/ConnectionFactory.java
@@ -26,11 +26,11 @@ import java.sql.SQLException;
*/
public interface ConnectionFactory {
/**
- * Create a new {@link java.sql.Connection} in an
- * implementation specific fashion.
+ * Create a new {@link java.sql.Connection} in an implementation specific fashion.
*
* @return a new {@link java.sql.Connection}
- * @throws SQLException if a database error occurs creating the connection
+ * @throws SQLException
+ * if a database error occurs creating the connection
*/
Connection createConnection() throws SQLException;
}
http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/d5a24430/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java b/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
index 0fbc9ee..e4280b2 100644
--- a/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
+++ b/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
@@ -44,29 +44,24 @@ import java.util.concurrent.Executor;
/**
* A base delegating implementation of {@link Connection}.
* <p>
- * All of the methods from the {@link Connection} interface
- * simply check to see that the {@link Connection} is active,
- * and call the corresponding method on the "delegate"
- * provided in my constructor.
+ * All of the methods from the {@link Connection} interface simply check to see that the {@link Connection} is active,
+ * and call the corresponding method on the "delegate" provided in my constructor.
* </p>
* <p>
- * Extends AbandonedTrace to implement Connection tracking and
- * logging of code which created the Connection. Tracking the
- * Connection ensures that the AbandonedObjectPool can close
- * this connection and recycle it if its pool of connections
- * is nearing exhaustion and this connection's last usage is
- * older than the removeAbandonedTimeout.
+ * Extends AbandonedTrace to implement Connection tracking and logging of code which created the Connection. Tracking
+ * the Connection ensures that the AbandonedObjectPool can close this connection and recycle it if its pool of
+ * connections is nearing exhaustion and this connection's last usage is older than the removeAbandonedTimeout.
* </p>
*
- * @param <C> the Connection type
+ * @param <C>
+ * the Connection type
*
* @since 2.0
*/
-public class DelegatingConnection<C extends Connection> extends AbandonedTrace
- implements Connection {
+public class DelegatingConnection<C extends Connection> extends AbandonedTrace implements Connection {
- private static final Map<String, ClientInfoStatus> EMPTY_FAILED_PROPERTIES =
- Collections.<String, ClientInfoStatus>emptyMap();
+ private static final Map<String, ClientInfoStatus> EMPTY_FAILED_PROPERTIES = Collections
+ .<String, ClientInfoStatus>emptyMap();
/** My delegate {@link Connection}. */
private volatile C connection;
@@ -79,20 +74,18 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
private Integer defaultQueryTimeoutSeconds;
/**
- * Creates a wrapper for the Connection which traces this
- * Connection in the AbandonedObjectPool.
+ * Creates a wrapper for the Connection which traces this Connection in the AbandonedObjectPool.
*
- * @param c the {@link Connection} to delegate all calls to.
+ * @param c
+ * the {@link Connection} to delegate all calls to.
*/
public DelegatingConnection(final C c) {
super();
connection = c;
}
-
/**
- * Returns a string representation of the metadata associated with
- * the innermost delegate connection.
+ * Returns a string representation of the metadata associated with the innermost delegate connection.
*/
@Override
public String toString() {
@@ -103,8 +96,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
try {
if (c.isClosed()) {
s = "connection is closed";
- }
- else {
+ } else {
final StringBuffer sb = new StringBuffer();
sb.append(hashCode());
final DatabaseMetaData meta = c.getMetaData();
@@ -118,8 +110,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
s = sb.toString();
}
}
- }
- catch (final SQLException ex) {
+ } catch (final SQLException ex) {
// Ignore
}
}
@@ -133,6 +124,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
/**
* Returns my underlying {@link Connection}.
+ *
* @return my underlying {@link Connection}.
*/
public C getDelegate() {
@@ -146,7 +138,8 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
/**
* Compares innermost delegate to the given connection.
*
- * @param c connection to compare innermost delegate with
+ * @param c
+ * connection to compare innermost delegate with
* @return true if innermost delegate equals <code>c</code>
*/
public boolean innermostDelegateEquals(final Connection c) {
@@ -157,22 +150,16 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
return innerCon.equals(c);
}
-
/**
- * If my underlying {@link Connection} is not a
- * {@code DelegatingConnection}, returns it,
- * otherwise recursively invokes this method on
- * my delegate.
+ * If my underlying {@link Connection} is not a {@code DelegatingConnection}, returns it, otherwise recursively
+ * invokes this method on my delegate.
* <p>
- * Hence this method will return the first
- * delegate that is not a {@code DelegatingConnection},
- * or {@code null} when no non-{@code DelegatingConnection}
- * delegate can be found by traversing this chain.
+ * Hence this method will return the first delegate that is not a {@code DelegatingConnection}, or {@code null} when
+ * no non-{@code DelegatingConnection} delegate can be found by traversing this chain.
* </p>
* <p>
- * This method is useful when you may have nested
- * {@code DelegatingConnection}s, and you want to make
- * sure to obtain a "genuine" {@link Connection}.
+ * This method is useful when you may have nested {@code DelegatingConnection}s, and you want to make sure to obtain
+ * a "genuine" {@link Connection}.
* </p>
*
* @return innermost delegate.
@@ -181,19 +168,17 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
return getInnermostDelegateInternal();
}
-
/**
- * Although this method is public, it is part of the internal API and should
- * not be used by clients. The signature of this method may change at any
- * time including in ways that break backwards compatibility.
+ * Although this method is public, it is part of the internal API and should not be used by clients. The signature
+ * of this method may change at any time including in ways that break backwards compatibility.
*
* @return innermost delegate.
*/
public final Connection getInnermostDelegateInternal() {
Connection c = connection;
- while(c != null && c instanceof DelegatingConnection) {
- c = ((DelegatingConnection<?>)c).getDelegateInternal();
- if(this == c) {
+ while (c != null && c instanceof DelegatingConnection) {
+ c = ((DelegatingConnection<?>) c).getDelegateInternal();
+ if (this == c) {
return null;
}
}
@@ -211,12 +196,11 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
/**
- * Closes the underlying connection, and close any Statements that were not
- * explicitly closed. Sub-classes that override this method must:
+ * Closes the underlying connection, and close any Statements that were not explicitly closed. Sub-classes that
+ * override this method must:
* <ol>
* <li>Call passivate()</li>
- * <li>Call close (or the equivalent appropriate action) on the wrapped
- * connection</li>
+ * <li>Call close (or the equivalent appropriate action) on the wrapped connection</li>
* <li>Set _closed to <code>false</code></li>
* </ol>
*/
@@ -256,8 +240,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
private void initializeStatement(final DelegatingStatement ds) throws SQLException {
- if (defaultQueryTimeoutSeconds != null &&
- defaultQueryTimeoutSeconds.intValue() != ds.getQueryTimeout()) {
+ if (defaultQueryTimeoutSeconds != null && defaultQueryTimeoutSeconds.intValue() != ds.getQueryTimeout()) {
ds.setQueryTimeout(defaultQueryTimeoutSeconds.intValue());
}
}
@@ -266,28 +249,24 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
public Statement createStatement() throws SQLException {
checkOpen();
try {
- final DelegatingStatement ds =
- new DelegatingStatement(this, connection.createStatement());
+ final DelegatingStatement ds = new DelegatingStatement(this, connection.createStatement());
initializeStatement(ds);
return ds;
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
}
@Override
- public Statement createStatement(final int resultSetType,
- final int resultSetConcurrency) throws SQLException {
+ public Statement createStatement(final int resultSetType, final int resultSetConcurrency) throws SQLException {
checkOpen();
try {
- final DelegatingStatement ds = new DelegatingStatement(
- this, connection.createStatement(resultSetType,resultSetConcurrency));
+ final DelegatingStatement ds = new DelegatingStatement(this,
+ connection.createStatement(resultSetType, resultSetConcurrency));
initializeStatement(ds);
return ds;
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
@@ -297,29 +276,26 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
public PreparedStatement prepareStatement(final String sql) throws SQLException {
checkOpen();
try {
- final DelegatingPreparedStatement dps = new DelegatingPreparedStatement(
- this, connection.prepareStatement(sql));
+ final DelegatingPreparedStatement dps = new DelegatingPreparedStatement(this,
+ connection.prepareStatement(sql));
initializeStatement(dps);
return dps;
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
}
@Override
- public PreparedStatement prepareStatement(final String sql,
- final int resultSetType,
- final int resultSetConcurrency) throws SQLException {
+ public PreparedStatement prepareStatement(final String sql, final int resultSetType, final int resultSetConcurrency)
+ throws SQLException {
checkOpen();
try {
- final DelegatingPreparedStatement dps = new DelegatingPreparedStatement(
- this, connection.prepareStatement(sql,resultSetType,resultSetConcurrency));
+ final DelegatingPreparedStatement dps = new DelegatingPreparedStatement(this,
+ connection.prepareStatement(sql, resultSetType, resultSetConcurrency));
initializeStatement(dps);
return dps;
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
@@ -329,35 +305,30 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
public CallableStatement prepareCall(final String sql) throws SQLException {
checkOpen();
try {
- final DelegatingCallableStatement dcs =
- new DelegatingCallableStatement(this, connection.prepareCall(sql));
+ final DelegatingCallableStatement dcs = new DelegatingCallableStatement(this, connection.prepareCall(sql));
initializeStatement(dcs);
return dcs;
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
}
@Override
- public CallableStatement prepareCall(final String sql,
- final int resultSetType,
- final int resultSetConcurrency) throws SQLException {
+ public CallableStatement prepareCall(final String sql, final int resultSetType, final int resultSetConcurrency)
+ throws SQLException {
checkOpen();
try {
- final DelegatingCallableStatement dcs = new DelegatingCallableStatement(
- this, connection.prepareCall(sql, resultSetType,resultSetConcurrency));
+ final DelegatingCallableStatement dcs = new DelegatingCallableStatement(this,
+ connection.prepareCall(sql, resultSetType, resultSetConcurrency));
initializeStatement(dcs);
return dcs;
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
}
-
@Override
public void clearWarnings() throws SQLException {
checkOpen();
@@ -368,7 +339,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
public void commit() throws SQLException {
checkOpen();
@@ -379,11 +349,10 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
/**
* Returns the state caching flag.
*
- * @return the state caching flag
+ * @return the state caching flag
*/
public boolean getCacheState() {
return cacheState;
@@ -404,7 +373,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
public String getCatalog() throws SQLException {
checkOpen();
@@ -416,7 +384,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
public DatabaseMetaData getMetaData() throws SQLException {
checkOpen();
@@ -428,7 +395,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
public int getTransactionIsolation() throws SQLException {
checkOpen();
@@ -440,9 +406,8 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
- public Map<String,Class<?>> getTypeMap() throws SQLException {
+ public Map<String, Class<?>> getTypeMap() throws SQLException {
checkOpen();
try {
return connection.getTypeMap();
@@ -452,7 +417,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
public SQLWarning getWarnings() throws SQLException {
checkOpen();
@@ -464,7 +428,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
public boolean isReadOnly() throws SQLException {
checkOpen();
@@ -480,7 +443,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
public String nativeSQL(final String sql) throws SQLException {
checkOpen();
@@ -492,7 +454,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
public void rollback() throws SQLException {
checkOpen();
@@ -503,7 +464,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
/**
* Gets the default query timeout that will be used for {@link Statement}s created from this connection.
* <code>null</code> means that the driver default will be used.
@@ -514,7 +474,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
return defaultQueryTimeoutSeconds;
}
-
/**
* Sets the default query timeout that will be used for {@link Statement}s created from this connection.
* <code>null</code> means that the driver default will be used.
@@ -526,25 +485,25 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
this.defaultQueryTimeoutSeconds = defaultQueryTimeoutSeconds;
}
-
/**
* Sets the state caching flag.
*
- * @param cacheState The new value for the state caching flag
+ * @param cacheState
+ * The new value for the state caching flag
*/
public void setCacheState(final boolean cacheState) {
this.cacheState = cacheState;
}
/**
- * Can be used to clear cached state when it is known that the underlying
- * connection may have been accessed directly.
+ * Can be used to clear cached state when it is known that the underlying connection may have been accessed
+ * directly.
*/
public void clearCachedState() {
autoCommitCached = null;
readOnlyCached = null;
if (connection instanceof DelegatingConnection) {
- ((DelegatingConnection<?>)connection).clearCachedState();
+ ((DelegatingConnection<?>) connection).clearCachedState();
}
}
@@ -563,8 +522,14 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
@Override
- public void setCatalog(final String catalog) throws SQLException
- { checkOpen(); try { connection.setCatalog(catalog); } catch (final SQLException e) { handleException(e); } }
+ public void setCatalog(final String catalog) throws SQLException {
+ checkOpen();
+ try {
+ connection.setCatalog(catalog);
+ } catch (final SQLException e) {
+ handleException(e);
+ }
+ }
@Override
public void setReadOnly(final boolean readOnly) throws SQLException {
@@ -580,7 +545,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
public void setTransactionIsolation(final int level) throws SQLException {
checkOpen();
@@ -591,9 +555,8 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
- public void setTypeMap(final Map<String,Class<?>> map) throws SQLException {
+ public void setTypeMap(final Map<String, Class<?>> map) throws SQLException {
checkOpen();
try {
connection.setTypeMap(map);
@@ -608,7 +571,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
protected void checkOpen() throws SQLException {
- if(closed) {
+ if (closed) {
if (null != connection) {
String label = "";
try {
@@ -616,19 +579,17 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
} catch (final Exception ex) {
// ignore, leave label empty
}
- throw new SQLException
- ("Connection " + label + " is closed.");
+ throw new SQLException("Connection " + label + " is closed.");
}
- throw new SQLException
- ("Connection is null.");
+ throw new SQLException("Connection is null.");
}
}
protected void activate() {
closed = false;
setLastUsed();
- if(connection instanceof DelegatingConnection) {
- ((DelegatingConnection<?>)connection).activate();
+ if (connection instanceof DelegatingConnection) {
+ ((DelegatingConnection<?>) connection).activate();
}
}
@@ -637,7 +598,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
// Statement's when it is closed.
// DBCP-288. Not all the traced objects will be statements
final List<AbandonedTrace> traces = getTrace();
- if(traces != null && traces.size() > 0) {
+ if (traces != null && traces.size() > 0) {
final Iterator<AbandonedTrace> traceIter = traces.iterator();
while (traceIter.hasNext()) {
final Object trace = traceIter.next();
@@ -654,7 +615,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
setLastUsed(0);
}
-
@Override
public int getHoldability() throws SQLException {
checkOpen();
@@ -666,7 +626,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
public void setHoldability(final int holdability) throws SQLException {
checkOpen();
@@ -677,7 +636,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
public Savepoint setSavepoint() throws SQLException {
checkOpen();
@@ -689,7 +647,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
public Savepoint setSavepoint(final String name) throws SQLException {
checkOpen();
@@ -701,7 +658,6 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
public void rollback(final Savepoint savepoint) throws SQLException {
checkOpen();
@@ -712,10 +668,8 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
- public void releaseSavepoint(final Savepoint savepoint)
- throws SQLException {
+ public void releaseSavepoint(final Savepoint savepoint) throws SQLException {
checkOpen();
try {
connection.releaseSavepoint(savepoint);
@@ -724,56 +678,46 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
}
-
@Override
- public Statement createStatement(final int resultSetType,
- final int resultSetConcurrency,
- final int resultSetHoldability) throws SQLException {
+ public Statement createStatement(final int resultSetType, final int resultSetConcurrency,
+ final int resultSetHoldability) throws SQLException {
checkOpen();
try {
final DelegatingStatement ds = new DelegatingStatement(this,
- connection.createStatement(resultSetType, resultSetConcurrency,
- resultSetHoldability));
+ connection.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability));
initializeStatement(ds);
return ds;
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
}
@Override
- public PreparedStatement prepareStatement(final String sql, final int resultSetType,
- final int resultSetConcurrency,
- final int resultSetHoldability) throws SQLException {
+ public PreparedStatement prepareStatement(final String sql, final int resultSetType, final int resultSetConcurrency,
+ final int resultSetHoldability) throws SQLException {
checkOpen();
try {
- final DelegatingPreparedStatement dps = new DelegatingPreparedStatement(
- this, connection.prepareStatement(sql, resultSetType,
- resultSetConcurrency, resultSetHoldability));
+ final DelegatingPreparedStatement dps = new DelegatingPreparedStatement(this,
+ connection.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability));
initializeStatement(dps);
return dps;
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
}
@Override
- public CallableStatement prepareCall(final String sql, final int resultSetType,
- final int resultSetConcurrency,
- final int resultSetHoldability) throws SQLException {
+ public CallableStatement prepareCall(final String sql, final int resultSetType, final int resultSetConcurrency,
+ final int resultSetHoldability) throws SQLException {
checkOpen();
try {
- final DelegatingCallableStatement dcs = new DelegatingCallableStatement(
- this, connection.prepareCall(sql, resultSetType,
- resultSetConcurrency, resultSetHoldability));
+ final DelegatingCallableStatement dcs = new DelegatingCallableStatement(this,
+ connection.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability));
initializeStatement(dcs);
return dcs;
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
@@ -783,12 +727,11 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
public PreparedStatement prepareStatement(final String sql, final int autoGeneratedKeys) throws SQLException {
checkOpen();
try {
- final DelegatingPreparedStatement dps = new DelegatingPreparedStatement(
- this, connection.prepareStatement(sql, autoGeneratedKeys));
+ final DelegatingPreparedStatement dps = new DelegatingPreparedStatement(this,
+ connection.prepareStatement(sql, autoGeneratedKeys));
initializeStatement(dps);
return dps;
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
@@ -798,12 +741,11 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
public PreparedStatement prepareStatement(final String sql, final int columnIndexes[]) throws SQLException {
checkOpen();
try {
- final DelegatingPreparedStatement dps = new DelegatingPreparedStatement(
- this, connection.prepareStatement(sql, columnIndexes));
+ final DelegatingPreparedStatement dps = new DelegatingPreparedStatement(this,
+ connection.prepareStatement(sql, columnIndexes));
initializeStatement(dps);
return dps;
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
@@ -813,18 +755,16 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
public PreparedStatement prepareStatement(final String sql, final String columnNames[]) throws SQLException {
checkOpen();
try {
- final DelegatingPreparedStatement dps = new DelegatingPreparedStatement(
- this, connection.prepareStatement(sql, columnNames));
+ final DelegatingPreparedStatement dps = new DelegatingPreparedStatement(this,
+ connection.prepareStatement(sql, columnNames));
initializeStatement(dps);
return dps;
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
}
-
@Override
public boolean isWrapperFor(final Class<?> iface) throws SQLException {
if (iface.isAssignableFrom(getClass())) {
@@ -852,8 +792,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
checkOpen();
try {
return connection.createArrayOf(typeName, elements);
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
@@ -864,8 +803,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
checkOpen();
try {
return connection.createBlob();
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
@@ -876,8 +814,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
checkOpen();
try {
return connection.createClob();
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
@@ -888,8 +825,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
checkOpen();
try {
return connection.createNClob();
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
@@ -900,8 +836,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
checkOpen();
try {
return connection.createSQLXML();
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
@@ -912,8 +847,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
checkOpen();
try {
return connection.createStruct(typeName, attributes);
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
@@ -926,8 +860,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
}
try {
return connection.isValid(timeout);
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return false;
}
@@ -938,11 +871,9 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
try {
checkOpen();
connection.setClientInfo(name, value);
- }
- catch (final SQLClientInfoException e) {
+ } catch (final SQLClientInfoException e) {
throw e;
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
throw new SQLClientInfoException("Connection is closed.", EMPTY_FAILED_PROPERTIES, e);
}
}
@@ -952,11 +883,9 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
try {
checkOpen();
connection.setClientInfo(properties);
- }
- catch (final SQLClientInfoException e) {
+ } catch (final SQLClientInfoException e) {
throw e;
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
throw new SQLClientInfoException("Connection is closed.", EMPTY_FAILED_PROPERTIES, e);
}
}
@@ -966,8 +895,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
checkOpen();
try {
return connection.getClientInfo();
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
@@ -978,8 +906,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
checkOpen();
try {
return connection.getClientInfo(name);
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
@@ -990,8 +917,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
checkOpen();
try {
connection.setSchema(schema);
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
}
}
@@ -1001,8 +927,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
checkOpen();
try {
return connection.getSchema();
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return null;
}
@@ -1013,20 +938,17 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
checkOpen();
try {
connection.abort(executor);
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
}
}
@Override
- public void setNetworkTimeout(final Executor executor, final int milliseconds)
- throws SQLException {
+ public void setNetworkTimeout(final Executor executor, final int milliseconds) throws SQLException {
checkOpen();
try {
connection.setNetworkTimeout(executor, milliseconds);
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
}
}
@@ -1036,8 +958,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace
checkOpen();
try {
return connection.getNetworkTimeout();
- }
- catch (final SQLException e) {
+ } catch (final SQLException e) {
handleException(e);
return 0;
}