Repository: commons-dbcp Updated Branches: refs/heads/master 6658eba68 -> 87266fdb9
http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/87266fdb/src/main/java/org/apache/commons/dbcp2/DelegatingStatement.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbcp2/DelegatingStatement.java b/src/main/java/org/apache/commons/dbcp2/DelegatingStatement.java index 46671d5..310bb01 100644 --- a/src/main/java/org/apache/commons/dbcp2/DelegatingStatement.java +++ b/src/main/java/org/apache/commons/dbcp2/DelegatingStatement.java @@ -44,9 +44,9 @@ import java.util.List; */ public class DelegatingStatement extends AbandonedTrace implements Statement { /** My delegate. */ - private Statement _stmt = null; + private Statement statement = null; /** The connection that created me. **/ - private DelegatingConnection<?> _conn = null; + private DelegatingConnection<?> connection = null; /** * Create a wrapper for the Statement which traces this @@ -58,8 +58,8 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { */ public DelegatingStatement(final DelegatingConnection<?> c, final Statement s) { super(c); - _stmt = s; - _conn = c; + statement = s; + connection = c; } /** @@ -68,7 +68,7 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { * @see #getInnermostDelegate */ public Statement getDelegate() { - return _stmt; + return statement; } @@ -89,7 +89,7 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { * @see #getDelegate */ public Statement getInnermostDelegate() { - Statement s = _stmt; + Statement s = statement; while(s != null && s instanceof DelegatingStatement) { s = ((DelegatingStatement)s).getDelegate(); if(this == s) { @@ -101,17 +101,17 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { /** Sets my delegate. */ public void setDelegate(final Statement s) { - _stmt = s; + statement = s; } - private boolean _closed = false; + private boolean closed = false; protected boolean isClosedInternal() { - return _closed; + return closed; } protected void setClosedInternal(final boolean closed) { - this._closed = closed; + this.closed = closed; } protected void checkOpen() throws SQLException { @@ -133,9 +133,9 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { } try { try { - if (_conn != null) { - _conn.removeTrace(this); - _conn = null; + if (connection != null) { + connection.removeTrace(this); + connection = null; } // The JDBC spec requires that a statement close any open @@ -151,8 +151,8 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { clearTrace(); } - if (_stmt != null) { - _stmt.close(); + if (statement != null) { + statement.close(); } } catch (final SQLException e) { @@ -160,14 +160,14 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { } } finally { - _closed = true; - _stmt = null; + closed = true; + statement = null; } } protected void handleException(final SQLException e) throws SQLException { - if (_conn != null) { - _conn.handleException(e); + if (connection != null) { + connection.handleException(e); } else { throw e; @@ -180,8 +180,8 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { * @since 2.4.0 made public, was protected in 2.3.0. */ public void activate() throws SQLException { - if(_stmt instanceof DelegatingStatement) { - ((DelegatingStatement)_stmt).activate(); + if(statement instanceof DelegatingStatement) { + ((DelegatingStatement)statement).activate(); } } @@ -191,8 +191,8 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { * @since 2.4.0 made public, was protected in 2.3.0. */ public void passivate() throws SQLException { - if(_stmt instanceof DelegatingStatement) { - ((DelegatingStatement)_stmt).passivate(); + if(statement instanceof DelegatingStatement) { + ((DelegatingStatement)statement).passivate(); } } @@ -203,17 +203,17 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { } protected DelegatingConnection<?> getConnectionInternal() { - return _conn; + return connection; } @Override public ResultSet executeQuery(final String sql) throws SQLException { checkOpen(); - if (_conn != null) { - _conn.setLastUsed(); + if (connection != null) { + connection.setLastUsed(); } try { - return DelegatingResultSet.wrapResultSet(this,_stmt.executeQuery(sql)); + return DelegatingResultSet.wrapResultSet(this,statement.executeQuery(sql)); } catch (final SQLException e) { handleException(e); @@ -225,7 +225,7 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { public ResultSet getResultSet() throws SQLException { checkOpen(); try { - return DelegatingResultSet.wrapResultSet(this,_stmt.getResultSet()); + return DelegatingResultSet.wrapResultSet(this,statement.getResultSet()); } catch (final SQLException e) { handleException(e); @@ -236,11 +236,11 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { @Override public int executeUpdate(final String sql) throws SQLException { checkOpen(); - if (_conn != null) { - _conn.setLastUsed(); + if (connection != null) { + connection.setLastUsed(); } try { - return _stmt.executeUpdate(sql); + return statement.executeUpdate(sql); } catch (final SQLException e) { handleException(e); return 0; } @@ -248,56 +248,56 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { @Override public int getMaxFieldSize() throws SQLException - { checkOpen(); try { return _stmt.getMaxFieldSize(); } catch (final SQLException e) { handleException(e); return 0; } } + { checkOpen(); try { return statement.getMaxFieldSize(); } catch (final SQLException e) { handleException(e); return 0; } } @Override public void setMaxFieldSize(final int max) throws SQLException - { checkOpen(); try { _stmt.setMaxFieldSize(max); } catch (final SQLException e) { handleException(e); } } + { checkOpen(); try { statement.setMaxFieldSize(max); } catch (final SQLException e) { handleException(e); } } @Override public int getMaxRows() throws SQLException - { checkOpen(); try { return _stmt.getMaxRows(); } catch (final SQLException e) { handleException(e); return 0; } } + { checkOpen(); try { return statement.getMaxRows(); } catch (final SQLException e) { handleException(e); return 0; } } @Override public void setMaxRows(final int max) throws SQLException - { checkOpen(); try { _stmt.setMaxRows(max); } catch (final SQLException e) { handleException(e); } } + { checkOpen(); try { statement.setMaxRows(max); } catch (final SQLException e) { handleException(e); } } @Override public void setEscapeProcessing(final boolean enable) throws SQLException - { checkOpen(); try { _stmt.setEscapeProcessing(enable); } catch (final SQLException e) { handleException(e); } } + { checkOpen(); try { statement.setEscapeProcessing(enable); } catch (final SQLException e) { handleException(e); } } @Override public int getQueryTimeout() throws SQLException - { checkOpen(); try { return _stmt.getQueryTimeout(); } catch (final SQLException e) { handleException(e); return 0; } } + { checkOpen(); try { return statement.getQueryTimeout(); } catch (final SQLException e) { handleException(e); return 0; } } @Override public void setQueryTimeout(final int seconds) throws SQLException - { checkOpen(); try { _stmt.setQueryTimeout(seconds); } catch (final SQLException e) { handleException(e); } } + { checkOpen(); try { statement.setQueryTimeout(seconds); } catch (final SQLException e) { handleException(e); } } @Override public void cancel() throws SQLException - { checkOpen(); try { _stmt.cancel(); } catch (final SQLException e) { handleException(e); } } + { checkOpen(); try { statement.cancel(); } catch (final SQLException e) { handleException(e); } } @Override public SQLWarning getWarnings() throws SQLException - { checkOpen(); try { return _stmt.getWarnings(); } catch (final SQLException e) { handleException(e); throw new AssertionError(); } } + { checkOpen(); try { return statement.getWarnings(); } catch (final SQLException e) { handleException(e); throw new AssertionError(); } } @Override public void clearWarnings() throws SQLException - { checkOpen(); try { _stmt.clearWarnings(); } catch (final SQLException e) { handleException(e); } } + { checkOpen(); try { statement.clearWarnings(); } catch (final SQLException e) { handleException(e); } } @Override public void setCursorName(final String name) throws SQLException - { checkOpen(); try { _stmt.setCursorName(name); } catch (final SQLException e) { handleException(e); } } + { checkOpen(); try { statement.setCursorName(name); } catch (final SQLException e) { handleException(e); } } @Override public boolean execute(final String sql) throws SQLException { checkOpen(); - if (_conn != null) { - _conn.setLastUsed(); + if (connection != null) { + connection.setLastUsed(); } try { - return _stmt.execute(sql); + return statement.execute(sql); } catch (final SQLException e) { handleException(e); return false; @@ -306,52 +306,52 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { @Override public int getUpdateCount() throws SQLException - { checkOpen(); try { return _stmt.getUpdateCount(); } catch (final SQLException e) { handleException(e); return 0; } } + { checkOpen(); try { return statement.getUpdateCount(); } catch (final SQLException e) { handleException(e); return 0; } } @Override public boolean getMoreResults() throws SQLException - { checkOpen(); try { return _stmt.getMoreResults(); } catch (final SQLException e) { handleException(e); return false; } } + { checkOpen(); try { return statement.getMoreResults(); } catch (final SQLException e) { handleException(e); return false; } } @Override public void setFetchDirection(final int direction) throws SQLException - { checkOpen(); try { _stmt.setFetchDirection(direction); } catch (final SQLException e) { handleException(e); } } + { checkOpen(); try { statement.setFetchDirection(direction); } catch (final SQLException e) { handleException(e); } } @Override public int getFetchDirection() throws SQLException - { checkOpen(); try { return _stmt.getFetchDirection(); } catch (final SQLException e) { handleException(e); return 0; } } + { checkOpen(); try { return statement.getFetchDirection(); } catch (final SQLException e) { handleException(e); return 0; } } @Override public void setFetchSize(final int rows) throws SQLException - { checkOpen(); try { _stmt.setFetchSize(rows); } catch (final SQLException e) { handleException(e); } } + { checkOpen(); try { statement.setFetchSize(rows); } catch (final SQLException e) { handleException(e); } } @Override public int getFetchSize() throws SQLException - { checkOpen(); try { return _stmt.getFetchSize(); } catch (final SQLException e) { handleException(e); return 0; } } + { checkOpen(); try { return statement.getFetchSize(); } catch (final SQLException e) { handleException(e); return 0; } } @Override public int getResultSetConcurrency() throws SQLException - { checkOpen(); try { return _stmt.getResultSetConcurrency(); } catch (final SQLException e) { handleException(e); return 0; } } + { checkOpen(); try { return statement.getResultSetConcurrency(); } catch (final SQLException e) { handleException(e); return 0; } } @Override public int getResultSetType() throws SQLException - { checkOpen(); try { return _stmt.getResultSetType(); } catch (final SQLException e) { handleException(e); return 0; } } + { checkOpen(); try { return statement.getResultSetType(); } catch (final SQLException e) { handleException(e); return 0; } } @Override public void addBatch(final String sql) throws SQLException - { checkOpen(); try { _stmt.addBatch(sql); } catch (final SQLException e) { handleException(e); } } + { checkOpen(); try { statement.addBatch(sql); } catch (final SQLException e) { handleException(e); } } @Override public void clearBatch() throws SQLException - { checkOpen(); try { _stmt.clearBatch(); } catch (final SQLException e) { handleException(e); } } + { checkOpen(); try { statement.clearBatch(); } catch (final SQLException e) { handleException(e); } } @Override public int[] executeBatch() throws SQLException { checkOpen(); - if (_conn != null) { - _conn.setLastUsed(); + if (connection != null) { + connection.setLastUsed(); } try { - return _stmt.executeBatch(); + return statement.executeBatch(); } catch (final SQLException e) { handleException(e); throw new AssertionError(); @@ -365,18 +365,18 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { */ @Override public String toString() { - return _stmt == null ? "NULL" : _stmt.toString(); + return statement == null ? "NULL" : statement.toString(); } @Override public boolean getMoreResults(final int current) throws SQLException - { checkOpen(); try { return _stmt.getMoreResults(current); } catch (final SQLException e) { handleException(e); return false; } } + { checkOpen(); try { return statement.getMoreResults(current); } catch (final SQLException e) { handleException(e); return false; } } @Override public ResultSet getGeneratedKeys() throws SQLException { checkOpen(); try { - return DelegatingResultSet.wrapResultSet(this, _stmt.getGeneratedKeys()); + return DelegatingResultSet.wrapResultSet(this, statement.getGeneratedKeys()); } catch (final SQLException e) { handleException(e); throw new AssertionError(); @@ -386,11 +386,11 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { @Override public int executeUpdate(final String sql, final int autoGeneratedKeys) throws SQLException { checkOpen(); - if (_conn != null) { - _conn.setLastUsed(); + if (connection != null) { + connection.setLastUsed(); } try { - return _stmt.executeUpdate(sql, autoGeneratedKeys); + return statement.executeUpdate(sql, autoGeneratedKeys); } catch (final SQLException e) { handleException(e); return 0; @@ -400,11 +400,11 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { @Override public int executeUpdate(final String sql, final int columnIndexes[]) throws SQLException { checkOpen(); - if (_conn != null) { - _conn.setLastUsed(); + if (connection != null) { + connection.setLastUsed(); } try { - return _stmt.executeUpdate(sql, columnIndexes); + return statement.executeUpdate(sql, columnIndexes); } catch (final SQLException e) { handleException(e); return 0; @@ -414,11 +414,11 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { @Override public int executeUpdate(final String sql, final String columnNames[]) throws SQLException { checkOpen(); - if (_conn != null) { - _conn.setLastUsed(); + if (connection != null) { + connection.setLastUsed(); } try { - return _stmt.executeUpdate(sql, columnNames); + return statement.executeUpdate(sql, columnNames); } catch (final SQLException e) { handleException(e); return 0; @@ -428,11 +428,11 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { @Override public boolean execute(final String sql, final int autoGeneratedKeys) throws SQLException { checkOpen(); - if (_conn != null) { - _conn.setLastUsed(); + if (connection != null) { + connection.setLastUsed(); } try { - return _stmt.execute(sql, autoGeneratedKeys); + return statement.execute(sql, autoGeneratedKeys); } catch (final SQLException e) { handleException(e); return false; @@ -442,11 +442,11 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { @Override public boolean execute(final String sql, final int columnIndexes[]) throws SQLException { checkOpen(); - if (_conn != null) { - _conn.setLastUsed(); + if (connection != null) { + connection.setLastUsed(); } try { - return _stmt.execute(sql, columnIndexes); + return statement.execute(sql, columnIndexes); } catch (final SQLException e) { handleException(e); return false; @@ -456,11 +456,11 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { @Override public boolean execute(final String sql, final String columnNames[]) throws SQLException { checkOpen(); - if (_conn != null) { - _conn.setLastUsed(); + if (connection != null) { + connection.setLastUsed(); } try { - return _stmt.execute(sql, columnNames); + return statement.execute(sql, columnNames); } catch (final SQLException e) { handleException(e); return false; @@ -469,14 +469,14 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { @Override public int getResultSetHoldability() throws SQLException - { checkOpen(); try { return _stmt.getResultSetHoldability(); } catch (final SQLException e) { handleException(e); return 0; } } + { checkOpen(); try { return statement.getResultSetHoldability(); } catch (final SQLException e) { handleException(e); return 0; } } /* * Note was protected prior to JDBC 4 */ @Override public boolean isClosed() throws SQLException { - return _closed; + return closed; } @@ -484,10 +484,10 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { public boolean isWrapperFor(final Class<?> iface) throws SQLException { if (iface.isAssignableFrom(getClass())) { return true; - } else if (iface.isAssignableFrom(_stmt.getClass())) { + } else if (iface.isAssignableFrom(statement.getClass())) { return true; } else { - return _stmt.isWrapperFor(iface); + return statement.isWrapperFor(iface); } } @@ -495,10 +495,10 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { public <T> T unwrap(final Class<T> iface) throws SQLException { if (iface.isAssignableFrom(getClass())) { return iface.cast(this); - } else if (iface.isAssignableFrom(_stmt.getClass())) { - return iface.cast(_stmt); + } else if (iface.isAssignableFrom(statement.getClass())) { + return iface.cast(statement); } else { - return _stmt.unwrap(iface); + return statement.unwrap(iface); } } @@ -506,7 +506,7 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { public void setPoolable(final boolean poolable) throws SQLException { checkOpen(); try { - _stmt.setPoolable(poolable); + statement.setPoolable(poolable); } catch (final SQLException e) { handleException(e); @@ -517,7 +517,7 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { public boolean isPoolable() throws SQLException { checkOpen(); try { - return _stmt.isPoolable(); + return statement.isPoolable(); } catch (final SQLException e) { handleException(e); @@ -529,7 +529,7 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { public void closeOnCompletion() throws SQLException { checkOpen(); try { - _stmt.closeOnCompletion(); + statement.closeOnCompletion(); } catch (final SQLException e) { handleException(e); } @@ -539,7 +539,7 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { public boolean isCloseOnCompletion() throws SQLException { checkOpen(); try { - return _stmt.isCloseOnCompletion(); + return statement.isCloseOnCompletion(); } catch (final SQLException e) { handleException(e); return false; http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/87266fdb/src/main/java/org/apache/commons/dbcp2/DriverConnectionFactory.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbcp2/DriverConnectionFactory.java b/src/main/java/org/apache/commons/dbcp2/DriverConnectionFactory.java index b1d439c..ba48766 100644 --- a/src/main/java/org/apache/commons/dbcp2/DriverConnectionFactory.java +++ b/src/main/java/org/apache/commons/dbcp2/DriverConnectionFactory.java @@ -27,24 +27,24 @@ import java.util.Properties; * @since 2.0 */ public class DriverConnectionFactory implements ConnectionFactory { + + private final String connectionUri; + private final Driver driver; + private final Properties properties; + public DriverConnectionFactory(final Driver driver, final String connectUri, final Properties props) { - _driver = driver; - _connectUri = connectUri; - _props = props; + this.driver = driver; + this.connectionUri = connectUri; + this.properties = props; } - @Override public Connection createConnection() throws SQLException { - return _driver.connect(_connectUri,_props); + return driver.connect(connectionUri,properties); } - private final Driver _driver; - private final String _connectUri; - private final Properties _props; - @Override public String toString() { - return this.getClass().getName() + " [" + String.valueOf(_driver) + ";" + - String.valueOf(_connectUri) + ";" + String.valueOf(_props) + "]"; + return this.getClass().getName() + " [" + String.valueOf(driver) + ";" + + String.valueOf(connectionUri) + ";" + String.valueOf(properties) + "]"; } } http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/87266fdb/src/main/java/org/apache/commons/dbcp2/DriverManagerConnectionFactory.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbcp2/DriverManagerConnectionFactory.java b/src/main/java/org/apache/commons/dbcp2/DriverManagerConnectionFactory.java index b7fab34..562c017 100644 --- a/src/main/java/org/apache/commons/dbcp2/DriverManagerConnectionFactory.java +++ b/src/main/java/org/apache/commons/dbcp2/DriverManagerConnectionFactory.java @@ -43,54 +43,54 @@ public class DriverManagerConnectionFactory implements ConnectionFactory { /** * Constructor for DriverManagerConnectionFactory. - * @param connectUri a database url of the form + * @param connectionUri a database url of the form * <code> jdbc:<em>subprotocol</em>:<em>subname</em></code> * @since 2.2 */ - public DriverManagerConnectionFactory(final String connectUri) { - _connectUri = connectUri; - _props = new Properties(); + public DriverManagerConnectionFactory(final String connectionUri) { + this.connectionUri = connectionUri; + this.propeties = new Properties(); } /** * Constructor for DriverManagerConnectionFactory. - * @param connectUri a database url of the form + * @param connectionUri a database url of the form * <code> jdbc:<em>subprotocol</em>:<em>subname</em></code> - * @param props a list of arbitrary string tag/value pairs as + * @param properties a list of arbitrary string tag/value pairs as * connection arguments; normally at least a "user" and "password" * property should be included. */ - public DriverManagerConnectionFactory(final String connectUri, final Properties props) { - _connectUri = connectUri; - _props = props; + public DriverManagerConnectionFactory(final String connectionUri, final Properties properties) { + this.connectionUri = connectionUri; + this.propeties = properties; } /** * Constructor for DriverManagerConnectionFactory. - * @param connectUri a database url of the form + * @param connectionUri a database url of the form * <code>jdbc:<em>subprotocol</em>:<em>subname</em></code> - * @param uname the database user - * @param passwd the user's password + * @param userName the database user + * @param userPassword the user's password */ - public DriverManagerConnectionFactory(final String connectUri, final String uname, final String passwd) { - _connectUri = connectUri; - _uname = uname; - _passwd = passwd; + public DriverManagerConnectionFactory(final String connectionUri, final String userName, final String userPassword) { + this.connectionUri = connectionUri; + this.userName = userName; + this.userPassword = userPassword; } @Override public Connection createConnection() throws SQLException { - if(null == _props) { - if(_uname == null && _passwd == null) { - return DriverManager.getConnection(_connectUri); + if (null == propeties) { + if (userName == null && userPassword == null) { + return DriverManager.getConnection(connectionUri); } - return DriverManager.getConnection(_connectUri,_uname,_passwd); + return DriverManager.getConnection(connectionUri, userName, userPassword); } - return DriverManager.getConnection(_connectUri,_props); + return DriverManager.getConnection(connectionUri, propeties); } - private String _connectUri = null; - private String _uname = null; - private String _passwd = null; - private Properties _props = null; + private String connectionUri = null; + private String userName = null; + private String userPassword = null; + private Properties propeties = null; } http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/87266fdb/src/main/java/org/apache/commons/dbcp2/PStmtKey.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbcp2/PStmtKey.java b/src/main/java/org/apache/commons/dbcp2/PStmtKey.java index 3de19b8..36b3c09 100644 --- a/src/main/java/org/apache/commons/dbcp2/PStmtKey.java +++ b/src/main/java/org/apache/commons/dbcp2/PStmtKey.java @@ -31,31 +31,31 @@ import org.apache.commons.dbcp2.PoolingConnection.StatementType; public class PStmtKey { /** SQL defining Prepared or Callable Statement */ - private final String _sql; + private final String sql; /** Result set type */ - private final Integer _resultSetType; + private final Integer resultSetType; /** Result set concurrency */ - private final Integer _resultSetConcurrency; + private final Integer resultSetConcurrency; /** Result set holdability */ - private final Integer _resultSetHoldability; + private final Integer resultSetHoldability; /** Database catalog */ - private final String _catalog; + private final String catalog; /** Auto generated keys */ - private final Integer _autoGeneratedKeys; + private final Integer autoGeneratedKeys; /** column indexes */ - private final int[] _columnIndexes; + private final int[] columnIndexes; /** column names */ - private final String[] _columnNames; + private final String[] columnNames; /** Statement type */ - private final StatementType _stmtType; + private final StatementType statementType; /** Statement builder */ private StatementBuilder builder; @@ -69,20 +69,20 @@ public class PStmtKey { } public PStmtKey(final String sql, final String catalog, final StatementType stmtType) { - _sql = sql; - _catalog = catalog; - _stmtType = stmtType; - _autoGeneratedKeys = null; - _columnIndexes = null; - _columnNames = null; - _resultSetType = null; - _resultSetConcurrency = null; - _resultSetHoldability = null; + this.sql = sql; + this.catalog = catalog; + this.statementType = stmtType; + this.autoGeneratedKeys = null; + this.columnIndexes = null; + this.columnNames = null; + this.resultSetType = null; + this.resultSetConcurrency = null; + this.resultSetHoldability = null; // create builder if (stmtType == StatementType.PREPARED_STATEMENT) { - builder = new PreparedStatementSQL(); + this.builder = new PreparedStatementSQL(); } else if (stmtType == StatementType.CALLABLE_STATEMENT) { - builder = new PreparedCallSQL(); + this.builder = new PreparedCallSQL(); } } @@ -91,47 +91,47 @@ public class PStmtKey { } public PStmtKey(final String sql, final String catalog, final StatementType stmtType, final Integer autoGeneratedKeys) { - _sql = sql; - _catalog = catalog; - _stmtType = stmtType; - _autoGeneratedKeys = autoGeneratedKeys; - _columnIndexes = null; - _columnNames = null; - _resultSetType = null; - _resultSetConcurrency = null; - _resultSetHoldability = null; + this.sql = sql; + this.catalog = catalog; + this.statementType = stmtType; + this.autoGeneratedKeys = autoGeneratedKeys; + this.columnIndexes = null; + this.columnNames = null; + this.resultSetType = null; + this.resultSetConcurrency = null; + this.resultSetHoldability = null; // create builder if (stmtType == StatementType.PREPARED_STATEMENT) { - builder = new PreparedStatementWithAutoGeneratedKeys(); + this.builder = new PreparedStatementWithAutoGeneratedKeys(); } else if (stmtType == StatementType.CALLABLE_STATEMENT) { - builder = new PreparedCallSQL(); + this.builder = new PreparedCallSQL(); } } public PStmtKey(final String sql, final String catalog, final int[] columnIndexes) { - _sql = sql; - _catalog = catalog; - _stmtType = StatementType.PREPARED_STATEMENT; - _autoGeneratedKeys = null; - _columnIndexes = columnIndexes == null ? null : Arrays.copyOf(columnIndexes, columnIndexes.length); - _columnNames = null; - _resultSetType = null; - _resultSetConcurrency = null; - _resultSetHoldability = null; + this.sql = sql; + this.catalog = catalog; + this.statementType = StatementType.PREPARED_STATEMENT; + this.autoGeneratedKeys = null; + this.columnIndexes = columnIndexes == null ? null : Arrays.copyOf(columnIndexes, columnIndexes.length); + this.columnNames = null; + this.resultSetType = null; + this.resultSetConcurrency = null; + this.resultSetHoldability = null; // create builder - builder = new PreparedStatementWithColumnIndexes(); + this.builder = new PreparedStatementWithColumnIndexes(); } public PStmtKey(final String sql, final String catalog, final String[] columnNames) { - _sql = sql; - _catalog = catalog; - _stmtType = StatementType.PREPARED_STATEMENT; - _autoGeneratedKeys = null; - _columnIndexes = null; - _columnNames = columnNames == null ? null : Arrays.copyOf(columnNames, columnNames.length); - _resultSetType = null; - _resultSetConcurrency = null; - _resultSetHoldability = null; + this.sql = sql; + this.catalog = catalog; + this.statementType = StatementType.PREPARED_STATEMENT; + this.autoGeneratedKeys = null; + this.columnIndexes = null; + this.columnNames = columnNames == null ? null : Arrays.copyOf(columnNames, columnNames.length); + this.resultSetType = null; + this.resultSetConcurrency = null; + this.resultSetHoldability = null; // create builder builder = new PreparedStatementWithColumnNames(); } @@ -145,20 +145,20 @@ public class PStmtKey { } public PStmtKey(final String sql, final String catalog, final int resultSetType, final int resultSetConcurrency, final StatementType stmtType) { - _sql = sql; - _catalog = catalog; - _resultSetType = Integer.valueOf(resultSetType); - _resultSetConcurrency = Integer.valueOf(resultSetConcurrency); - _resultSetHoldability = null; - _stmtType = stmtType; - _autoGeneratedKeys = null; - _columnIndexes = null; - _columnNames = null; + this.sql = sql; + this.catalog = catalog; + this.resultSetType = Integer.valueOf(resultSetType); + this.resultSetConcurrency = Integer.valueOf(resultSetConcurrency); + this.resultSetHoldability = null; + this.statementType = stmtType; + this.autoGeneratedKeys = null; + this.columnIndexes = null; + this.columnNames = null; // create builder if (stmtType == StatementType.PREPARED_STATEMENT) { - builder = new PreparedStatementWithResultSetConcurrency(); + this.builder = new PreparedStatementWithResultSetConcurrency(); } else if (stmtType == StatementType.CALLABLE_STATEMENT) { - builder = new PreparedCallWithResultSetConcurrency(); + this.builder = new PreparedCallWithResultSetConcurrency(); } } @@ -169,58 +169,58 @@ public class PStmtKey { public PStmtKey(final String sql, final String catalog, final int resultSetType, final int resultSetConcurrency, final int resultSetHoldability, final StatementType stmtType) { - _sql = sql; - _catalog = catalog; - _resultSetType = Integer.valueOf(resultSetType); - _resultSetConcurrency = Integer.valueOf(resultSetConcurrency); - _resultSetHoldability = Integer.valueOf(resultSetHoldability); - _stmtType = stmtType; - _autoGeneratedKeys = null; - _columnIndexes = null; - _columnNames = null; + this.sql = sql; + this.catalog = catalog; + this.resultSetType = Integer.valueOf(resultSetType); + this.resultSetConcurrency = Integer.valueOf(resultSetConcurrency); + this.resultSetHoldability = Integer.valueOf(resultSetHoldability); + this.statementType = stmtType; + this.autoGeneratedKeys = null; + this.columnIndexes = null; + this.columnNames = null; // create builder if (stmtType == StatementType.PREPARED_STATEMENT) { - builder = new PreparedStatementWithResultSetHoldability(); + this.builder = new PreparedStatementWithResultSetHoldability(); } else if (stmtType == StatementType.CALLABLE_STATEMENT) { - builder = new PreparedCallWithResultSetHoldability(); + this.builder = new PreparedCallWithResultSetHoldability(); } } public String getSql() { - return _sql; + return sql; } public Integer getResultSetType() { - return _resultSetType; + return resultSetType; } public Integer getResultSetConcurrency() { - return _resultSetConcurrency; + return resultSetConcurrency; } public Integer getResultSetHoldability() { - return _resultSetHoldability; + return resultSetHoldability; } public Integer getAutoGeneratedKeys() { - return _autoGeneratedKeys; + return autoGeneratedKeys; } public int[] getColumnIndexes() { - return _columnIndexes; + return columnIndexes; } public String[] getColumnNames() { - return _columnNames; + return columnNames; } public String getCatalog() { - return _catalog; + return catalog; } public StatementType getStmtType() { - return _stmtType; + return statementType; } @Override @@ -235,55 +235,55 @@ public class PStmtKey { return false; } final PStmtKey other = (PStmtKey) obj; - if (_catalog == null) { - if (other._catalog != null) { + if (catalog == null) { + if (other.catalog != null) { return false; } - } else if (!_catalog.equals(other._catalog)) { + } else if (!catalog.equals(other.catalog)) { return false; } - if (_resultSetConcurrency == null) { - if (other._resultSetConcurrency != null) { + if (resultSetConcurrency == null) { + if (other.resultSetConcurrency != null) { return false; } - } else if (!_resultSetConcurrency.equals(other._resultSetConcurrency)) { + } else if (!resultSetConcurrency.equals(other.resultSetConcurrency)) { return false; } - if (_resultSetType == null) { - if (other._resultSetType != null) { + if (resultSetType == null) { + if (other.resultSetType != null) { return false; } - } else if (!_resultSetType.equals(other._resultSetType)) { + } else if (!resultSetType.equals(other.resultSetType)) { return false; } - if (_resultSetHoldability == null) { - if (other._resultSetHoldability != null) { + if (resultSetHoldability == null) { + if (other.resultSetHoldability != null) { return false; } - } else if (!_resultSetHoldability.equals(other._resultSetHoldability)) { + } else if (!resultSetHoldability.equals(other.resultSetHoldability)) { return false; } - if (_autoGeneratedKeys == null) { - if (other._autoGeneratedKeys != null) { + if (autoGeneratedKeys == null) { + if (other.autoGeneratedKeys != null) { return false; } - } else if (!_autoGeneratedKeys.equals(other._autoGeneratedKeys)) { + } else if (!autoGeneratedKeys.equals(other.autoGeneratedKeys)) { return false; } - if (!Arrays.equals(_columnIndexes, other._columnIndexes)) { + if (!Arrays.equals(columnIndexes, other.columnIndexes)) { return false; } - if (!Arrays.equals(_columnNames, other._columnNames)) { + if (!Arrays.equals(columnNames, other.columnNames)) { return false; } - if (_sql == null) { - if (other._sql != null) { + if (sql == null) { + if (other.sql != null) { return false; } - } else if (!_sql.equals(other._sql)) { + } else if (!sql.equals(other.sql)) { return false; } - if (_stmtType != other._stmtType) { + if (statementType != other.statementType) { return false; } return true; @@ -293,15 +293,15 @@ public class PStmtKey { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + (_catalog == null ? 0 : _catalog.hashCode()); - result = prime * result + (_resultSetConcurrency == null ? 0 : _resultSetConcurrency.hashCode()); - result = prime * result + (_resultSetType == null ? 0 : _resultSetType.hashCode()); - result = prime * result + (_resultSetHoldability == null ? 0 : _resultSetHoldability.hashCode()); - result = prime * result + (_sql == null ? 0 : _sql.hashCode()); - result = prime * result + (_autoGeneratedKeys == null ? 0 : _autoGeneratedKeys.hashCode()); - result = prime * result + Arrays.hashCode(_columnIndexes); - result = prime * result + Arrays.hashCode(_columnNames); - result = prime * result + _stmtType.hashCode(); + result = prime * result + (catalog == null ? 0 : catalog.hashCode()); + result = prime * result + (resultSetConcurrency == null ? 0 : resultSetConcurrency.hashCode()); + result = prime * result + (resultSetType == null ? 0 : resultSetType.hashCode()); + result = prime * result + (resultSetHoldability == null ? 0 : resultSetHoldability.hashCode()); + result = prime * result + (sql == null ? 0 : sql.hashCode()); + result = prime * result + (autoGeneratedKeys == null ? 0 : autoGeneratedKeys.hashCode()); + result = prime * result + Arrays.hashCode(columnIndexes); + result = prime * result + Arrays.hashCode(columnNames); + result = prime * result + statementType.hashCode(); return result; } @@ -309,23 +309,23 @@ public class PStmtKey { public String toString() { final StringBuffer buf = new StringBuffer(); buf.append("PStmtKey: sql="); - buf.append(_sql); + buf.append(sql); buf.append(", catalog="); - buf.append(_catalog); + buf.append(catalog); buf.append(", resultSetType="); - buf.append(_resultSetType); + buf.append(resultSetType); buf.append(", resultSetConcurrency="); - buf.append(_resultSetConcurrency); + buf.append(resultSetConcurrency); buf.append(", resultSetHoldability="); - buf.append(_resultSetHoldability); + buf.append(resultSetHoldability); buf.append(", autoGeneratedKeys="); - buf.append(_autoGeneratedKeys); + buf.append(autoGeneratedKeys); buf.append(", columnIndexes="); - buf.append(Arrays.toString(_columnIndexes)); + buf.append(Arrays.toString(columnIndexes)); buf.append(", columnNames="); - buf.append(Arrays.toString(_columnNames)); + buf.append(Arrays.toString(columnNames)); buf.append(", statementType="); - buf.append(_stmtType); + buf.append(statementType); return buf.toString(); } @@ -349,7 +349,7 @@ public class PStmtKey { private class PreparedStatementSQL implements StatementBuilder { @Override public Statement createStatement(final Connection connection) throws SQLException { - final PreparedStatement statement = connection.prepareStatement(_sql); + final PreparedStatement statement = connection.prepareStatement(sql); return statement; } } @@ -361,7 +361,7 @@ public class PStmtKey { @Override public Statement createStatement(final Connection connection) throws SQLException { final PreparedStatement statement = connection.prepareStatement( - _sql, _autoGeneratedKeys.intValue()); + sql, autoGeneratedKeys.intValue()); return statement; } } @@ -373,7 +373,7 @@ public class PStmtKey { @Override public Statement createStatement(final Connection connection) throws SQLException { final PreparedStatement statement = connection.prepareStatement( - _sql, _columnIndexes); + sql, columnIndexes); return statement; } } @@ -385,7 +385,7 @@ public class PStmtKey { @Override public Statement createStatement(final Connection connection) throws SQLException { final PreparedStatement statement = connection.prepareStatement( - _sql, _resultSetType.intValue(), _resultSetConcurrency.intValue()); + sql, resultSetType.intValue(), resultSetConcurrency.intValue()); return statement; } } @@ -397,8 +397,8 @@ public class PStmtKey { @Override public Statement createStatement(final Connection connection) throws SQLException { final PreparedStatement statement = connection.prepareStatement( - _sql, _resultSetType.intValue(), _resultSetConcurrency.intValue(), - _resultSetHoldability.intValue()); + sql, resultSetType.intValue(), resultSetConcurrency.intValue(), + resultSetHoldability.intValue()); return statement; } } @@ -410,7 +410,7 @@ public class PStmtKey { @Override public Statement createStatement(final Connection connection) throws SQLException { final PreparedStatement statement = connection.prepareStatement( - _sql, _columnNames); + sql, columnNames); return statement; } } @@ -421,7 +421,7 @@ public class PStmtKey { private class PreparedCallSQL implements StatementBuilder { @Override public Statement createStatement(final Connection connection) throws SQLException { - final PreparedStatement statement = connection.prepareCall(_sql); + final PreparedStatement statement = connection.prepareCall(sql); return statement; } } @@ -433,7 +433,7 @@ public class PStmtKey { @Override public Statement createStatement(final Connection connection) throws SQLException { final PreparedStatement statement = connection.prepareCall( - _sql, _resultSetType.intValue(), _resultSetConcurrency.intValue()); + sql, resultSetType.intValue(), resultSetConcurrency.intValue()); return statement; } } @@ -445,8 +445,8 @@ public class PStmtKey { @Override public Statement createStatement(final Connection connection) throws SQLException { final PreparedStatement statement = connection.prepareCall( - _sql, _resultSetType.intValue(), _resultSetConcurrency.intValue(), - _resultSetHoldability.intValue()); + sql, resultSetType.intValue(), resultSetConcurrency.intValue(), + resultSetHoldability.intValue()); return statement; } } http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/87266fdb/src/main/java/org/apache/commons/dbcp2/PoolableCallableStatement.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbcp2/PoolableCallableStatement.java b/src/main/java/org/apache/commons/dbcp2/PoolableCallableStatement.java index 023da51..b9dccad 100644 --- a/src/main/java/org/apache/commons/dbcp2/PoolableCallableStatement.java +++ b/src/main/java/org/apache/commons/dbcp2/PoolableCallableStatement.java @@ -39,27 +39,27 @@ public class PoolableCallableStatement extends DelegatingCallableStatement { /** * The {@link KeyedObjectPool} from which this CallableStatement was obtained. */ - private final KeyedObjectPool<PStmtKey, DelegatingPreparedStatement> _pool; + private final KeyedObjectPool<PStmtKey, DelegatingPreparedStatement> pool; /** * Key for this statement in the containing {@link KeyedObjectPool}. */ - private final PStmtKey _key; + private final PStmtKey key; /** * Constructor. * - * @param stmt the underlying {@link CallableStatement} + * @param callableStatement the underlying {@link CallableStatement} * @param key the key for this statement in the {@link KeyedObjectPool} * @param pool the {@link KeyedObjectPool} from which this CallableStatement was obtained - * @param conn the {@link DelegatingConnection} that created this CallableStatement + * @param connection the {@link DelegatingConnection} that created this CallableStatement */ - public PoolableCallableStatement(final CallableStatement stmt, final PStmtKey key, + public PoolableCallableStatement(final CallableStatement callableStatement, final PStmtKey key, final KeyedObjectPool<PStmtKey, DelegatingPreparedStatement> pool, - final DelegatingConnection<Connection> conn) { - super(conn, stmt); - _pool = pool; - _key = key; + final DelegatingConnection<Connection> connection) { + super(connection, callableStatement); + this.pool = pool; + this.key = key; // Remove from trace now because this statement will be // added by the activate method. @@ -76,7 +76,7 @@ public class PoolableCallableStatement extends DelegatingCallableStatement { // calling close twice should have no effect if (!isClosed()) { try { - _pool.returnObject(_key, this); + pool.returnObject(key, this); } catch (final SQLException e) { throw e; } catch (final RuntimeException e) { http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/87266fdb/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java b/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java index f598232..8602413 100644 --- a/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java +++ b/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java @@ -53,9 +53,9 @@ public class PoolableConnection extends DelegatingConnection<Connection> impleme } /** The pool to which I should return. */ - private final ObjectPool<PoolableConnection> _pool; + private final ObjectPool<PoolableConnection> pool; - private final ObjectNameWrapper _jmxObjectName; + private final ObjectNameWrapper jmxObjectName; // Use a prepared statement for validation, retaining the last used SQL to // check if the validation query has changed. @@ -66,16 +66,16 @@ public class PoolableConnection extends DelegatingConnection<Connection> impleme * Indicate that unrecoverable SQLException was thrown when using this connection. Such a connection should be * considered broken and not pass validation in the future. */ - private boolean _fatalSqlExceptionThrown = false; + private boolean fatalSqlExceptionThrown = false; /** * SQL_STATE codes considered to signal fatal conditions. Overrides the defaults in * {@link Utils#DISCONNECTION_SQL_CODES} (plus anything starting with {@link Utils#DISCONNECTION_SQL_CODE_PREFIX}). */ - private final Collection<String> _disconnectionSqlCodes; + private final Collection<String> disconnectionSqlCodes; /** Whether or not to fast fail validation after fatal connection errors */ - private final boolean _fastFailValidation; + private final boolean fastFailValidation; /** * @@ -95,10 +95,10 @@ public class PoolableConnection extends DelegatingConnection<Connection> impleme final ObjectName jmxObjectName, final Collection<String> disconnectSqlCodes, final boolean fastFailValidation) { super(conn); - _pool = pool; - _jmxObjectName = ObjectNameWrapper.wrap(jmxObjectName); - _disconnectionSqlCodes = disconnectSqlCodes; - _fastFailValidation = fastFailValidation; + this.pool = pool; + this.jmxObjectName = ObjectNameWrapper.wrap(jmxObjectName); + this.disconnectionSqlCodes = disconnectSqlCodes; + this.fastFailValidation = fastFailValidation; if (jmxObjectName != null) { try { @@ -168,7 +168,7 @@ public class PoolableConnection extends DelegatingConnection<Connection> impleme isUnderlyingConnectionClosed = getDelegateInternal().isClosed(); } catch (final SQLException e) { try { - _pool.invalidateObject(this); + pool.invalidateObject(this); } catch (final IllegalStateException ise) { // pool is closed, so close the connection passivate(); @@ -188,7 +188,7 @@ public class PoolableConnection extends DelegatingConnection<Connection> impleme // Abnormal close: underlying connection closed unexpectedly, so we // must destroy this proxy try { - _pool.invalidateObject(this); + pool.invalidateObject(this); } catch (final IllegalStateException e) { // pool is closed, so close the connection passivate(); @@ -200,7 +200,7 @@ public class PoolableConnection extends DelegatingConnection<Connection> impleme // Normal close: underlying connection is still open, so we // simply need to return this proxy to the pool try { - _pool.returnObject(this); + pool.returnObject(this); } catch (final IllegalStateException e) { // pool is closed, so close the connection passivate(); @@ -220,8 +220,8 @@ public class PoolableConnection extends DelegatingConnection<Connection> impleme */ @Override public void reallyClose() throws SQLException { - if (_jmxObjectName != null) { - _jmxObjectName.unregisterMBean(); + if (jmxObjectName != null) { + jmxObjectName.unregisterMBean(); } if (validationPreparedStatement != null) { @@ -262,7 +262,7 @@ public class PoolableConnection extends DelegatingConnection<Connection> impleme * if validation fails or an SQLException occurs during validation */ public void validate(final String sql, int timeout) throws SQLException { - if (_fastFailValidation && _fatalSqlExceptionThrown) { + if (fastFailValidation && fatalSqlExceptionThrown) { throw new SQLException(Utils.getMessage("poolableConnection.validate.fastFail")); } @@ -313,10 +313,10 @@ public class PoolableConnection extends DelegatingConnection<Connection> impleme boolean fatalException = false; final String sqlState = e.getSQLState(); if (sqlState != null) { - fatalException = _disconnectionSqlCodes == null + fatalException = disconnectionSqlCodes == null ? sqlState.startsWith(Utils.DISCONNECTION_SQL_CODE_PREFIX) || Utils.DISCONNECTION_SQL_CODES.contains(sqlState) - : _disconnectionSqlCodes.contains(sqlState); + : disconnectionSqlCodes.contains(sqlState); if (!fatalException) { final SQLException nextException = e.getNextException(); if (nextException != null && nextException != e) { @@ -329,7 +329,7 @@ public class PoolableConnection extends DelegatingConnection<Connection> impleme @Override protected void handleException(final SQLException e) throws SQLException { - _fatalSqlExceptionThrown |= isDisconnectionSqlException(e); + fatalSqlExceptionThrown |= isDisconnectionSqlException(e); super.handleException(e); } } http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/87266fdb/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java b/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java index 791f953..e366e6d 100644 --- a/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java +++ b/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java @@ -58,7 +58,7 @@ public class PoolableConnectionFactory */ public PoolableConnectionFactory(final ConnectionFactory connFactory, final ObjectName dataSourceJmxObjectName) { - _connFactory = connFactory; + this.connectionFactory = connFactory; this.dataSourceJmxName = dataSourceJmxObjectName; } @@ -70,7 +70,7 @@ public class PoolableConnectionFactory * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s. */ public void setValidationQuery(final String validationQuery) { - _validationQuery = validationQuery; + this.validationQuery = validationQuery; } /** @@ -79,10 +79,10 @@ public class PoolableConnectionFactory * executing a validation query. Use a value less than or equal to 0 for * no timeout. * - * @param timeout new validation query timeout value in seconds + * @param timeoutSeconds new validation query timeout value in seconds */ - public void setValidationQueryTimeout(final int timeout) { - _validationQueryTimeout = timeout; + public void setValidationQueryTimeout(final int timeoutSeconds) { + this.validationQueryTimeoutSeconds = timeoutSeconds; } /** @@ -91,7 +91,7 @@ public class PoolableConnectionFactory * @param connectionInitSqls SQL statement to initialize {@link Connection}s. */ public void setConnectionInitSql(final Collection<String> connectionInitSqls) { - _connectionInitSqls = connectionInitSqls; + this.connectionInitSqls = connectionInitSqls; } /** @@ -99,14 +99,14 @@ public class PoolableConnectionFactory * @param pool the {@link ObjectPool} in which to pool those {@link Connection}s */ public synchronized void setPool(final ObjectPool<PoolableConnection> pool) { - if(null != _pool && pool != _pool) { + if(null != this.pool && pool != this.pool) { try { - _pool.close(); + this.pool.close(); } catch(final Exception e) { // ignored !?! } } - _pool = pool; + this.pool = pool; } /** @@ -114,7 +114,7 @@ public class PoolableConnectionFactory * @return the connection pool */ public synchronized ObjectPool<PoolableConnection> getPool() { - return _pool; + return pool; } /** @@ -122,7 +122,7 @@ public class PoolableConnectionFactory * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s */ public void setDefaultReadOnly(final Boolean defaultReadOnly) { - _defaultReadOnly = defaultReadOnly; + this.defaultReadOnly = defaultReadOnly; } /** @@ -130,7 +130,7 @@ public class PoolableConnectionFactory * @param defaultAutoCommit the default "auto commit" setting for borrowed {@link Connection}s */ public void setDefaultAutoCommit(final Boolean defaultAutoCommit) { - _defaultAutoCommit = defaultAutoCommit; + this.defaultAutoCommit = defaultAutoCommit; } /** @@ -138,7 +138,7 @@ public class PoolableConnectionFactory * @param defaultTransactionIsolation the default "Transaction Isolation" setting for returned {@link Connection}s */ public void setDefaultTransactionIsolation(final int defaultTransactionIsolation) { - _defaultTransactionIsolation = defaultTransactionIsolation; + this.defaultTransactionIsolation = defaultTransactionIsolation; } /** @@ -146,11 +146,11 @@ public class PoolableConnectionFactory * @param defaultCatalog the default "catalog" setting for borrowed {@link Connection}s */ public void setDefaultCatalog(final String defaultCatalog) { - _defaultCatalog = defaultCatalog; + this.defaultCatalog = defaultCatalog; } public void setCacheState(final boolean cacheState) { - this._cacheState = cacheState; + this.cacheState = cacheState; } public void setPoolStatements(final boolean poolStatements) { @@ -220,7 +220,7 @@ public class PoolableConnectionFactory * @since 2.1 */ public Collection<String> getDisconnectionSqlCodes() { - return _disconnectionSqlCodes; + return disconnectionSqlCodes; } /** @@ -229,7 +229,7 @@ public class PoolableConnectionFactory * @since 2.1 */ public void setDisconnectionSqlCodes(final Collection<String> disconnectionSqlCodes) { - _disconnectionSqlCodes = disconnectionSqlCodes; + this.disconnectionSqlCodes = disconnectionSqlCodes; } /** @@ -242,7 +242,7 @@ public class PoolableConnectionFactory * @since 2.1 */ public boolean isFastFailValidation() { - return _fastFailValidation; + return fastFailValidation; } /** @@ -252,12 +252,12 @@ public class PoolableConnectionFactory * @since 2.1 */ public void setFastFailValidation(final boolean fastFailValidation) { - _fastFailValidation = fastFailValidation; + this.fastFailValidation = fastFailValidation; } @Override public PooledObject<PoolableConnection> makeObject() throws Exception { - Connection conn = _connFactory.createConnection(); + Connection conn = connectionFactory.createConnection(); if (conn == null) { throw new IllegalStateException("Connection factory returned null from createConnection"); } @@ -296,7 +296,7 @@ public class PoolableConnectionFactory final KeyedObjectPool<PStmtKey,DelegatingPreparedStatement> stmtPool = new GenericKeyedObjectPool<>((PoolingConnection)conn, config); ((PoolingConnection)conn).setStatementPool(stmtPool); - ((PoolingConnection) conn).setCacheState(_cacheState); + ((PoolingConnection) conn).setCacheState(cacheState); } // Register this connection with JMX @@ -308,15 +308,15 @@ public class PoolableConnectionFactory Constants.JMX_CONNECTION_BASE_EXT + connIndex); } - final PoolableConnection pc = new PoolableConnection(conn, _pool, connJmxName, - _disconnectionSqlCodes, _fastFailValidation); - pc.setCacheState(_cacheState); + final PoolableConnection pc = new PoolableConnection(conn, pool, connJmxName, + disconnectionSqlCodes, fastFailValidation); + pc.setCacheState(cacheState); return new DefaultPooledObject<>(pc); } protected void initializeConnection(final Connection conn) throws SQLException { - final Collection<String> sqls = _connectionInitSqls; + final Collection<String> sqls = connectionInitSqls; if(conn.isClosed()) { throw new SQLException("initializeConnection: connection closed"); } @@ -359,7 +359,7 @@ public class PoolableConnectionFactory if(conn.isClosed()) { throw new SQLException("validateConnection: connection closed"); } - conn.validate(_validationQuery, _validationQueryTimeout); + conn.validate(validationQuery, validationQueryTimeoutSeconds); } @Override @@ -402,21 +402,21 @@ public class PoolableConnectionFactory final PoolableConnection conn = p.getObject(); conn.activate(); - if (_defaultAutoCommit != null && - conn.getAutoCommit() != _defaultAutoCommit.booleanValue()) { - conn.setAutoCommit(_defaultAutoCommit.booleanValue()); + if (defaultAutoCommit != null && + conn.getAutoCommit() != defaultAutoCommit.booleanValue()) { + conn.setAutoCommit(defaultAutoCommit.booleanValue()); } - if (_defaultTransactionIsolation != UNKNOWN_TRANSACTIONISOLATION && - conn.getTransactionIsolation() != _defaultTransactionIsolation) { - conn.setTransactionIsolation(_defaultTransactionIsolation); + if (defaultTransactionIsolation != UNKNOWN_TRANSACTIONISOLATION && + conn.getTransactionIsolation() != defaultTransactionIsolation) { + conn.setTransactionIsolation(defaultTransactionIsolation); } - if (_defaultReadOnly != null && - conn.isReadOnly() != _defaultReadOnly.booleanValue()) { - conn.setReadOnly(_defaultReadOnly.booleanValue()); + if (defaultReadOnly != null && + conn.isReadOnly() != defaultReadOnly.booleanValue()) { + conn.setReadOnly(defaultReadOnly.booleanValue()); } - if (_defaultCatalog != null && - !_defaultCatalog.equals(conn.getCatalog())) { - conn.setCatalog(_defaultCatalog); + if (defaultCatalog != null && + !defaultCatalog.equals(conn.getCatalog())) { + conn.setCatalog(defaultCatalog); } conn.setDefaultQueryTimeout(defaultQueryTimeoutSeconds); } @@ -435,7 +435,7 @@ public class PoolableConnectionFactory } protected ConnectionFactory getConnectionFactory() { - return _connFactory; + return connectionFactory; } protected boolean getPoolStatements() { @@ -447,7 +447,7 @@ public class PoolableConnectionFactory } protected boolean getCacheState() { - return _cacheState; + return cacheState; } protected ObjectName getDataSourceJmxName() { @@ -458,21 +458,21 @@ public class PoolableConnectionFactory return connectionIndex; } - private final ConnectionFactory _connFactory; + private final ConnectionFactory connectionFactory; private final ObjectName dataSourceJmxName; - private volatile String _validationQuery = null; - private volatile int _validationQueryTimeout = -1; - private Collection<String> _connectionInitSqls = null; - private Collection<String> _disconnectionSqlCodes = null; - private boolean _fastFailValidation = false; - private volatile ObjectPool<PoolableConnection> _pool = null; - private Boolean _defaultReadOnly = null; - private Boolean _defaultAutoCommit = null; + private volatile String validationQuery = null; + private volatile int validationQueryTimeoutSeconds = -1; + private Collection<String> connectionInitSqls = null; + private Collection<String> disconnectionSqlCodes = null; + private boolean fastFailValidation = false; + private volatile ObjectPool<PoolableConnection> pool = null; + private Boolean defaultReadOnly = null; + private Boolean defaultAutoCommit = null; private boolean enableAutoCommitOnReturn = true; private boolean rollbackOnReturn = true; - private int _defaultTransactionIsolation = UNKNOWN_TRANSACTIONISOLATION; - private String _defaultCatalog; - private boolean _cacheState; + private int defaultTransactionIsolation = UNKNOWN_TRANSACTIONISOLATION; + private String defaultCatalog; + private boolean cacheState; private boolean poolStatements = false; private int maxOpenPreparedStatements = GenericKeyedObjectPoolConfig.DEFAULT_MAX_TOTAL_PER_KEY; http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/87266fdb/src/main/java/org/apache/commons/dbcp2/PoolablePreparedStatement.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbcp2/PoolablePreparedStatement.java b/src/main/java/org/apache/commons/dbcp2/PoolablePreparedStatement.java index 5e1d9e1..1665595 100644 --- a/src/main/java/org/apache/commons/dbcp2/PoolablePreparedStatement.java +++ b/src/main/java/org/apache/commons/dbcp2/PoolablePreparedStatement.java @@ -43,12 +43,12 @@ public class PoolablePreparedStatement<K> extends DelegatingPreparedStatement { /** * The {@link KeyedObjectPool} from which I was obtained. */ - private final KeyedObjectPool<K, PoolablePreparedStatement<K>> _pool; + private final KeyedObjectPool<K, PoolablePreparedStatement<K>> pool; /** * My "key" as used by {@link KeyedObjectPool}. */ - private final K _key; + private final K key; private volatile boolean batchAdded = false; @@ -63,8 +63,8 @@ public class PoolablePreparedStatement<K> extends DelegatingPreparedStatement { final KeyedObjectPool<K, PoolablePreparedStatement<K>> pool, final DelegatingConnection<?> conn) { super(conn, stmt); - _pool = pool; - _key = key; + this.pool = pool; + this.key = key; // Remove from trace now because this statement will be // added by the activate method. @@ -99,7 +99,7 @@ public class PoolablePreparedStatement<K> extends DelegatingPreparedStatement { // calling close twice should have no effect if (!isClosed()) { try { - _pool.returnObject(_key, this); + pool.returnObject(key, this); } catch(final SQLException e) { throw e; } catch(final RuntimeException e) { http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/87266fdb/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java b/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java index 8745950..4987bed 100644 --- a/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java +++ b/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java @@ -66,7 +66,7 @@ public class PoolingConnection extends DelegatingConnection<Connection> } /** Pool of {@link PreparedStatement}s. and {@link CallableStatement}s */ - private KeyedObjectPool<PStmtKey, DelegatingPreparedStatement> _pstmtPool = null; + private KeyedObjectPool<PStmtKey, DelegatingPreparedStatement> pstmtPool = null; /** * Constructor. @@ -98,9 +98,9 @@ public class PoolingConnection extends DelegatingConnection<Connection> @Override public synchronized void close() throws SQLException { try { - if (null != _pstmtPool) { - final KeyedObjectPool<PStmtKey,DelegatingPreparedStatement> oldpool = _pstmtPool; - _pstmtPool = null; + if (null != pstmtPool) { + final KeyedObjectPool<PStmtKey,DelegatingPreparedStatement> oldpool = pstmtPool; + pstmtPool = null; try { oldpool.close(); } catch(final RuntimeException e) { @@ -291,11 +291,11 @@ public class PoolingConnection extends DelegatingConnection<Connection> if (key.getStmtType() == StatementType.PREPARED_STATEMENT ) { final PreparedStatement statement = (PreparedStatement) key.createStatement(getDelegate()); @SuppressWarnings({"rawtypes", "unchecked"}) // Unable to find way to avoid this - final PoolablePreparedStatement pps = new PoolablePreparedStatement(statement, key, _pstmtPool, this); + final PoolablePreparedStatement pps = new PoolablePreparedStatement(statement, key, pstmtPool, this); return new DefaultPooledObject<DelegatingPreparedStatement>(pps); } final CallableStatement statement = (CallableStatement) key.createStatement(getDelegate()); - final PoolableCallableStatement pcs = new PoolableCallableStatement(statement, key, _pstmtPool, this); + final PoolableCallableStatement pcs = new PoolableCallableStatement(statement, key, pstmtPool, this); return new DefaultPooledObject<DelegatingPreparedStatement>(pcs); } @@ -332,7 +332,7 @@ public class PoolingConnection extends DelegatingConnection<Connection> @Override public CallableStatement prepareCall(final String sql) throws SQLException { try { - return (CallableStatement) _pstmtPool.borrowObject(createKey(sql, StatementType.CALLABLE_STATEMENT)); + return (CallableStatement) pstmtPool.borrowObject(createKey(sql, StatementType.CALLABLE_STATEMENT)); } catch (final NoSuchElementException e) { throw new SQLException("MaxOpenCallableStatements limit reached", e); } catch (final RuntimeException e) { @@ -353,7 +353,7 @@ public class PoolingConnection extends DelegatingConnection<Connection> @Override public CallableStatement prepareCall(final String sql, final int resultSetType, final int resultSetConcurrency) throws SQLException { try { - return (CallableStatement) _pstmtPool.borrowObject(createKey(sql, resultSetType, + return (CallableStatement) pstmtPool.borrowObject(createKey(sql, resultSetType, resultSetConcurrency, StatementType.CALLABLE_STATEMENT)); } catch (final NoSuchElementException e) { throw new SQLException("MaxOpenCallableStatements limit reached", e); @@ -377,7 +377,7 @@ public class PoolingConnection extends DelegatingConnection<Connection> public CallableStatement prepareCall(final String sql, final int resultSetType, final int resultSetConcurrency, final int resultSetHoldability) throws SQLException { try { - return (CallableStatement) _pstmtPool.borrowObject(createKey(sql, resultSetType, + return (CallableStatement) pstmtPool.borrowObject(createKey(sql, resultSetType, resultSetConcurrency, resultSetHoldability, StatementType.CALLABLE_STATEMENT)); } catch (final NoSuchElementException e) { throw new SQLException("MaxOpenCallableStatements limit reached", e); @@ -395,12 +395,12 @@ public class PoolingConnection extends DelegatingConnection<Connection> */ @Override public PreparedStatement prepareStatement(final String sql) throws SQLException { - if (null == _pstmtPool) { + if (null == pstmtPool) { throw new SQLException( "Statement pool is null - closed or invalid PoolingConnection."); } try { - return _pstmtPool.borrowObject(createKey(sql)); + return pstmtPool.borrowObject(createKey(sql)); } catch(final NoSuchElementException e) { throw new SQLException("MaxOpenPreparedStatements limit reached", e); } catch(final RuntimeException e) { @@ -412,12 +412,12 @@ public class PoolingConnection extends DelegatingConnection<Connection> @Override public PreparedStatement prepareStatement(final String sql, final int autoGeneratedKeys) throws SQLException { - if (null == _pstmtPool) { + if (null == pstmtPool) { throw new SQLException( "Statement pool is null - closed or invalid PoolingConnection."); } try { - return _pstmtPool.borrowObject(createKey(sql, autoGeneratedKeys)); + return pstmtPool.borrowObject(createKey(sql, autoGeneratedKeys)); } catch (final NoSuchElementException e) { throw new SQLException("MaxOpenPreparedStatements limit reached", e); @@ -439,12 +439,12 @@ public class PoolingConnection extends DelegatingConnection<Connection> @Override public PreparedStatement prepareStatement(final String sql, final int columnIndexes[]) throws SQLException { - if (null == _pstmtPool) { + if (null == pstmtPool) { throw new SQLException( "Statement pool is null - closed or invalid PoolingConnection."); } try { - return _pstmtPool.borrowObject(createKey(sql, columnIndexes)); + return pstmtPool.borrowObject(createKey(sql, columnIndexes)); } catch(final NoSuchElementException e) { throw new SQLException("MaxOpenPreparedStatements limit reached", e); } catch(final RuntimeException e) { @@ -463,12 +463,12 @@ public class PoolingConnection extends DelegatingConnection<Connection> */ @Override public PreparedStatement prepareStatement(final String sql, final int resultSetType, final int resultSetConcurrency) throws SQLException { - if (null == _pstmtPool) { + if (null == pstmtPool) { throw new SQLException( "Statement pool is null - closed or invalid PoolingConnection."); } try { - return _pstmtPool.borrowObject(createKey(sql,resultSetType,resultSetConcurrency)); + return pstmtPool.borrowObject(createKey(sql,resultSetType,resultSetConcurrency)); } catch(final NoSuchElementException e) { throw new SQLException("MaxOpenPreparedStatements limit reached", e); } catch(final RuntimeException e) { @@ -489,12 +489,12 @@ public class PoolingConnection extends DelegatingConnection<Connection> @Override public PreparedStatement prepareStatement(final String sql, final int resultSetType, final int resultSetConcurrency, final int resultSetHoldability) throws SQLException { - if (null == _pstmtPool) { + if (null == pstmtPool) { throw new SQLException( "Statement pool is null - closed or invalid PoolingConnection."); } try { - return _pstmtPool.borrowObject(createKey(sql, resultSetType, resultSetConcurrency, resultSetHoldability)); + return pstmtPool.borrowObject(createKey(sql, resultSetType, resultSetConcurrency, resultSetHoldability)); } catch(final NoSuchElementException e) { throw new SQLException("MaxOpenPreparedStatements limit reached", e); } catch(final RuntimeException e) { @@ -513,12 +513,12 @@ public class PoolingConnection extends DelegatingConnection<Connection> @Override public PreparedStatement prepareStatement(final String sql, final String columnNames[]) throws SQLException { - if (null == _pstmtPool) { + if (null == pstmtPool) { throw new SQLException( "Statement pool is null - closed or invalid PoolingConnection."); } try { - return _pstmtPool.borrowObject(createKey(sql, columnNames)); + return pstmtPool.borrowObject(createKey(sql, columnNames)); } catch(final NoSuchElementException e) { throw new SQLException("MaxOpenPreparedStatements limit reached", e); } catch(final RuntimeException e) { @@ -530,13 +530,13 @@ public class PoolingConnection extends DelegatingConnection<Connection> public void setStatementPool( final KeyedObjectPool<PStmtKey,DelegatingPreparedStatement> pool) { - _pstmtPool = pool; + pstmtPool = pool; } @Override public String toString() { - if (_pstmtPool != null ) { - return "PoolingConnection: " + _pstmtPool.toString(); + if (pstmtPool != null ) { + return "PoolingConnection: " + pstmtPool.toString(); } return "PoolingConnection: null"; } http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/87266fdb/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java b/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java index 2f17c45..568c66e 100644 --- a/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java +++ b/src/main/java/org/apache/commons/dbcp2/PoolingDataSource.java @@ -53,18 +53,18 @@ public class PoolingDataSource<C extends Connection> implements DataSource, Auto if (null == pool) { throw new NullPointerException("Pool must not be null."); } - _pool = pool; + this.pool = pool; // Verify that _pool's factory refers back to it. If not, log a warning and try to fix. - if (_pool instanceof GenericObjectPool<?>) { - final PoolableConnectionFactory pcf = (PoolableConnectionFactory) ((GenericObjectPool<?>) _pool).getFactory(); + if (this.pool instanceof GenericObjectPool<?>) { + final PoolableConnectionFactory pcf = (PoolableConnectionFactory) ((GenericObjectPool<?>) this.pool).getFactory(); if (pcf == null) { throw new NullPointerException("PoolableConnectionFactory must not be null."); } - if (pcf.getPool() != _pool) { + if (pcf.getPool() != this.pool) { log.warn(Utils.getMessage("poolingDataSource.factoryConfig")); @SuppressWarnings("unchecked") // PCF must have a pool of PCs final - ObjectPool<PoolableConnection> p = (ObjectPool<PoolableConnection>) _pool; + ObjectPool<PoolableConnection> p = (ObjectPool<PoolableConnection>) this.pool; pcf.setPool(p); } } @@ -77,7 +77,7 @@ public class PoolingDataSource<C extends Connection> implements DataSource, Auto @Override public void close() throws Exception { try { - _pool.close(); + pool.close(); } catch(final RuntimeException rte) { throw new RuntimeException(Utils.getMessage("pool.close.fail"), rte); } catch(final Exception e) { @@ -131,7 +131,7 @@ public class PoolingDataSource<C extends Connection> implements DataSource, Auto @Override public Connection getConnection() throws SQLException { try { - final C conn = _pool.borrowObject(); + final C conn = pool.borrowObject(); if (conn == null) { return null; } @@ -167,7 +167,7 @@ public class PoolingDataSource<C extends Connection> implements DataSource, Auto */ @Override public PrintWriter getLogWriter() { - return _logWriter; + return logWriter; } /** @@ -196,16 +196,16 @@ public class PoolingDataSource<C extends Connection> implements DataSource, Auto */ @Override public void setLogWriter(final PrintWriter out) { - _logWriter = out; + logWriter = out; } /** My log writer. */ - private PrintWriter _logWriter = null; + private PrintWriter logWriter = null; - private final ObjectPool<C> _pool; + private final ObjectPool<C> pool; protected ObjectPool<C> getPool() { - return _pool; + return pool; } /** http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/87266fdb/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java b/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java index 9cc47d6..d7f7f70 100644 --- a/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java +++ b/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java @@ -252,8 +252,8 @@ public class TestAbandonedBasicDataSource extends TestBasicDataSource { final PoolingConnection poolingConn = (PoolingConnection) poolableConn.getDelegate(); @SuppressWarnings("unchecked") final - GenericKeyedObjectPool<PStmtKey,DelegatingPreparedStatement> gkop = - (GenericKeyedObjectPool<PStmtKey,DelegatingPreparedStatement>) TesterUtils.getField(poolingConn, "_pstmtPool"); + GenericKeyedObjectPool<PStmtKey, DelegatingPreparedStatement> gkop = + (GenericKeyedObjectPool<PStmtKey, DelegatingPreparedStatement>) TesterUtils.getField(poolingConn, "pstmtPool"); Assert.assertEquals(0, conn.getTrace().size()); Assert.assertEquals(0, gkop.getNumActive()); createStatement(conn);
