commons-dbcp git commit: Sort members in AB order so it's easier to find stuff.
Repository: commons-dbcp Updated Branches: refs/heads/master b7df9811b -> 99facd021 Sort members in AB order so it's easier to find stuff. Project: http://git-wip-us.apache.org/repos/asf/commons-dbcp/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-dbcp/commit/99facd02 Tree: http://git-wip-us.apache.org/repos/asf/commons-dbcp/tree/99facd02 Diff: http://git-wip-us.apache.org/repos/asf/commons-dbcp/diff/99facd02 Branch: refs/heads/master Commit: 99facd0219053f660c43b318b0966de40354d76d Parents: b7df981 Author: Gary Gregory Authored: Sun Jun 17 10:11:12 2018 -0600 Committer: Gary Gregory Committed: Sun Jun 17 10:11:12 2018 -0600 -- .../apache/commons/dbcp2/TesterResultSet.java | 836 +-- 1 file changed, 418 insertions(+), 418 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/99facd02/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java -- diff --git a/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java b/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java index a980605..f5c8342 100644 --- a/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java +++ b/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java @@ -40,43 +40,62 @@ import java.sql.SQLXML; * A dummy {@link ResultSet}, for testing purposes. */ public class TesterResultSet implements ResultSet { -public TesterResultSet(final Statement stmt) { -_statement = stmt; -} +protected int _type = ResultSet.TYPE_FORWARD_ONLY; -public TesterResultSet(final Statement stmt, final Object[][] data) { +protected int _concurrency = ResultSet.CONCUR_READ_ONLY; + +protected Object[][] _data = null; + +protected int _currentRow = -1; +protected Statement _statement = null; + +protected int _rowsLeft = 2; +protected boolean _open = true; + +public TesterResultSet(final Statement stmt) { _statement = stmt; -_data = data; } - public TesterResultSet(final Statement stmt, final int type, final int concurrency) { _statement = stmt; _data = null; _type = type; _concurrency = concurrency; } +public TesterResultSet(final Statement stmt, final Object[][] data) { +_statement = stmt; +_data = data; +} -protected int _type = ResultSet.TYPE_FORWARD_ONLY; -protected int _concurrency = ResultSet.CONCUR_READ_ONLY; +@Override +public boolean absolute( final int row ) throws SQLException { +checkOpen(); +return false; +} -protected Object[][] _data = null; -protected int _currentRow = -1; +@Override +public void afterLast() throws SQLException { +checkOpen(); +} -protected Statement _statement = null; -protected int _rowsLeft = 2; -protected boolean _open = true; +@Override +public void beforeFirst() throws SQLException { +checkOpen(); +} @Override -public boolean next() throws SQLException { +public void cancelRowUpdates() throws SQLException { checkOpen(); -if (_data != null) { -_currentRow++; -return _currentRow < _data.length; -} -if(--_rowsLeft > 0) { -return true; +} + +protected void checkOpen() throws SQLException { +if(!_open) { +throw new SQLException("ResultSet is closed."); } -return false; +} + +@Override +public void clearWarnings() throws SQLException { +checkOpen(); } @Override @@ -94,63 +113,50 @@ public class TesterResultSet implements ResultSet { } @Override -public boolean wasNull() throws SQLException { +public void deleteRow() throws SQLException { checkOpen(); -return false; } @Override -public String getString(final int columnIndex) throws SQLException { -checkOpen(); -if (columnIndex == -1) { -throw new SQLException("broken connection"); -} -if (_data != null) { -return (String) getObject(columnIndex); -} -return "String" + columnIndex; -} - -@Override -public boolean getBoolean(final int columnIndex) throws SQLException { +public int findColumn(final String columnName) throws SQLException { checkOpen(); -return true; +return 1; } @Override -public byte getByte(final int columnIndex) throws SQLException { +public boolean first() throws SQLException { checkOpen(); -return (byte)columnIndex; +return false; } @Override -public short getShort(final int columnIndex) throws SQLException { +public Array getArray(final int i) throws
[2/2] commons-dbcp git commit: Sort members in AB order so it's easier to find stuff.
Sort members in AB order so it's easier to find stuff. Project: http://git-wip-us.apache.org/repos/asf/commons-dbcp/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-dbcp/commit/b7df9811 Tree: http://git-wip-us.apache.org/repos/asf/commons-dbcp/tree/b7df9811 Diff: http://git-wip-us.apache.org/repos/asf/commons-dbcp/diff/b7df9811 Branch: refs/heads/master Commit: b7df9811bf66d7f8ae855a82572fc8472b206c5b Parents: c5dc98d Author: Gary Gregory Authored: Sun Jun 17 10:08:21 2018 -0600 Committer: Gary Gregory Committed: Sun Jun 17 10:08:21 2018 -0600 -- .../commons/dbcp2/DelegatingResultSet.java | 1188 +- 1 file changed, 594 insertions(+), 594 deletions(-) --
[1/2] commons-dbcp git commit: Sort members in AB order so it's easier to find stuff.
Repository: commons-dbcp Updated Branches: refs/heads/master c5dc98d98 -> b7df9811b http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/b7df9811/src/main/java/org/apache/commons/dbcp2/DelegatingResultSet.java -- diff --git a/src/main/java/org/apache/commons/dbcp2/DelegatingResultSet.java b/src/main/java/org/apache/commons/dbcp2/DelegatingResultSet.java index ce44833..cbfa857 100644 --- a/src/main/java/org/apache/commons/dbcp2/DelegatingResultSet.java +++ b/src/main/java/org/apache/commons/dbcp2/DelegatingResultSet.java @@ -54,33 +54,47 @@ import java.util.Map; */ public final class DelegatingResultSet extends AbandonedTrace implements ResultSet { -/** My delegate. **/ -private final ResultSet resultSet; - -/** The Statement that created me, if any. **/ -private Statement statement; - -/** The Connection that created me, if any. **/ -private Connection connection; +/** + * Wraps the given result set in a delegate. + * + * @param connection + *The Connection which created the ResultSet. + * @param resultSet + *The ResultSet to wrap. + * @return a new delegate. + */ +public static ResultSet wrapResultSet(final Connection connection, final ResultSet resultSet) { +if (null == resultSet) { +return null; +} +return new DelegatingResultSet(connection, resultSet); +} /** - * Creates a wrapper for the ResultSet which traces this ResultSet to the Statement which created it and the code - * which created it. - * - * Private to ensure all construction is {@link #wrapResultSet(Statement, ResultSet)} - * + * Wraps the given result set in a delegate. * * @param statement *The Statement which created the ResultSet. * @param resultSet *The ResultSet to wrap. + * @return a new delegate. */ -private DelegatingResultSet(final Statement statement, final ResultSet resultSet) { -super((AbandonedTrace) statement); -this.statement = statement; -this.resultSet = resultSet; +public static ResultSet wrapResultSet(final Statement statement, final ResultSet resultSet) { +if (null == resultSet) { +return null; +} +return new DelegatingResultSet(statement, resultSet); } +/** My delegate. **/ +private final ResultSet resultSet; + +/** The Statement that created me, if any. **/ +private Statement statement; + +/** The Connection that created me, if any. **/ +private Connection connection; + /** * Creates a wrapper for the ResultSet which traces this ResultSet to the Connection which created it (via, for * example DatabaseMetadata, and the code which created it. @@ -100,111 +114,27 @@ public final class DelegatingResultSet extends AbandonedTrace implements ResultS } /** - * Wraps the given result set in a delegate. + * Creates a wrapper for the ResultSet which traces this ResultSet to the Statement which created it and the code + * which created it. + * + * Private to ensure all construction is {@link #wrapResultSet(Statement, ResultSet)} + * * * @param statement *The Statement which created the ResultSet. * @param resultSet *The ResultSet to wrap. - * @return a new delegate. - */ -public static ResultSet wrapResultSet(final Statement statement, final ResultSet resultSet) { -if (null == resultSet) { -return null; -} -return new DelegatingResultSet(statement, resultSet); -} - -/** - * Wraps the given result set in a delegate. - * - * @param connection - *The Connection which created the ResultSet. - * @param resultSet - *The ResultSet to wrap. - * @return a new delegate. - */ -public static ResultSet wrapResultSet(final Connection connection, final ResultSet resultSet) { -if (null == resultSet) { -return null; -} -return new DelegatingResultSet(connection, resultSet); -} - -/** - * Gets my delegate. - * - * @return my delegate. - */ -public ResultSet getDelegate() { -return resultSet; -} - -/** - * If my underlying {@link ResultSet} is not a {@code DelegatingResultSet}, returns it, otherwise recursively - * invokes this method on my delegate. - * - * Hence this method will return the first delegate that is not a {@code DelegatingResultSet}, or {@code null} when - * no non-{@code DelegatingResultSet} delegate can be found by traversing this chain. - * - * - * This method is useful when you may have nested {@code DelegatingResultSet}s, and you want to make sure to obtain - * a "genuine"
commons-dbcp git commit: Sort members in AB order so it's easier to find stuff.
Repository: commons-dbcp Updated Branches: refs/heads/master 21d75a867 -> 63bee061f Sort members in AB order so it's easier to find stuff. Project: http://git-wip-us.apache.org/repos/asf/commons-dbcp/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-dbcp/commit/63bee061 Tree: http://git-wip-us.apache.org/repos/asf/commons-dbcp/tree/63bee061 Diff: http://git-wip-us.apache.org/repos/asf/commons-dbcp/diff/63bee061 Branch: refs/heads/master Commit: 63bee061f37d09d409aa02d4de122fdd94b538bd Parents: 21d75a8 Author: Gary Gregory Authored: Sun Jun 17 10:00:41 2018 -0600 Committer: Gary Gregory Committed: Sun Jun 17 10:00:41 2018 -0600 -- .../commons/dbcp2/TesterCallableStatement.java | 328 +-- 1 file changed, 164 insertions(+), 164 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/63bee061/src/test/java/org/apache/commons/dbcp2/TesterCallableStatement.java -- diff --git a/src/test/java/org/apache/commons/dbcp2/TesterCallableStatement.java b/src/test/java/org/apache/commons/dbcp2/TesterCallableStatement.java index 29acf7f..31ad314 100644 --- a/src/test/java/org/apache/commons/dbcp2/TesterCallableStatement.java +++ b/src/test/java/org/apache/commons/dbcp2/TesterCallableStatement.java @@ -60,397 +60,408 @@ public class TesterCallableStatement extends TesterPreparedStatement implements } @Override -public void registerOutParameter(final int parameterIndex, final int sqlType) throws SQLException { +public Array getArray(final int i) throws SQLException { +return null; } @Override -public void registerOutParameter(final int parameterIndex, final int sqlType, final int scale) throws SQLException { +public Array getArray(final String parameterName) throws SQLException { +return null; } @Override -public boolean wasNull() throws SQLException { -return false; +public BigDecimal getBigDecimal(final int parameterIndex) throws SQLException { +return null; } +/** + * @deprecated + */ +@Deprecated @Override -public String getString(final int parameterIndex) throws SQLException { +public BigDecimal getBigDecimal(final int parameterIndex, final int scale) throws SQLException { return null; } @Override -public boolean getBoolean(final int parameterIndex) throws SQLException { -return false; +public BigDecimal getBigDecimal(final String parameterName) throws SQLException { +return null; } @Override -public byte getByte(final int parameterIndex) throws SQLException { -return 0; +public Blob getBlob(final int i) throws SQLException { +return null; } @Override -public short getShort(final int parameterIndex) throws SQLException { -return 0; +public Blob getBlob(final String parameterName) throws SQLException { +return null; } @Override -public int getInt(final int parameterIndex) throws SQLException { -return 0; +public boolean getBoolean(final int parameterIndex) throws SQLException { +return false; } @Override -public long getLong(final int parameterIndex) throws SQLException { -return 0; +public boolean getBoolean(final String parameterName) throws SQLException { +return false; } @Override -public float getFloat(final int parameterIndex) throws SQLException { +public byte getByte(final int parameterIndex) throws SQLException { return 0; } @Override -public double getDouble(final int parameterIndex) throws SQLException { +public byte getByte(final String parameterName) throws SQLException { return 0; } -/** - * @deprecated - */ -@Deprecated @Override -public BigDecimal getBigDecimal(final int parameterIndex, final int scale) throws SQLException { -return null; +public byte[] getBytes(final int parameterIndex) throws SQLException { +return new byte[0]; } @Override -public byte[] getBytes(final int parameterIndex) throws SQLException { +public byte[] getBytes(final String parameterName) throws SQLException { return new byte[0]; } @Override -public Date getDate(final int parameterIndex) throws SQLException { +public Reader getCharacterStream(final int parameterIndex) throws SQLException { return null; } @Override -public Time getTime(final int parameterIndex) throws SQLException { +public Reader getCharacterStream(final String parameterName) throws SQLException { return null; } @Override -public Timestamp getTimestamp(final int parameterIndex)
commons-dbcp git commit: Sort members in AB order so it's easier to find stuff.
Repository: commons-dbcp Updated Branches: refs/heads/master 812121b8e -> e176d65e0 Sort members in AB order so it's easier to find stuff. Project: http://git-wip-us.apache.org/repos/asf/commons-dbcp/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-dbcp/commit/e176d65e Tree: http://git-wip-us.apache.org/repos/asf/commons-dbcp/tree/e176d65e Diff: http://git-wip-us.apache.org/repos/asf/commons-dbcp/diff/e176d65e Branch: refs/heads/master Commit: e176d65e03aee3135bf91691c0a43f0ef7f24b02 Parents: 812121b Author: Gary Gregory Authored: Sun Jun 17 09:54:45 2018 -0600 Committer: Gary Gregory Committed: Sun Jun 17 09:54:45 2018 -0600 -- .../dbcp2/DelegatingCallableStatement.java | 580 +-- 1 file changed, 290 insertions(+), 290 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/e176d65e/src/main/java/org/apache/commons/dbcp2/DelegatingCallableStatement.java -- diff --git a/src/main/java/org/apache/commons/dbcp2/DelegatingCallableStatement.java b/src/main/java/org/apache/commons/dbcp2/DelegatingCallableStatement.java index 978467a..b652149 100644 --- a/src/main/java/org/apache/commons/dbcp2/DelegatingCallableStatement.java +++ b/src/main/java/org/apache/commons/dbcp2/DelegatingCallableStatement.java @@ -65,41 +65,45 @@ public class DelegatingCallableStatement extends DelegatingPreparedStatement imp } @Override -public void registerOutParameter(final int parameterIndex, final int sqlType) throws SQLException { +public Array getArray(final int i) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().registerOutParameter(parameterIndex, sqlType); +return getDelegateCallableStatement().getArray(i); } catch (final SQLException e) { handleException(e); +return null; } } @Override -public void registerOutParameter(final int parameterIndex, final int sqlType, final int scale) throws SQLException { +public Array getArray(final String parameterName) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().registerOutParameter(parameterIndex, sqlType, scale); +return getDelegateCallableStatement().getArray(parameterName); } catch (final SQLException e) { handleException(e); +return null; } } @Override -public boolean wasNull() throws SQLException { +public BigDecimal getBigDecimal(final int parameterIndex) throws SQLException { checkOpen(); try { -return getDelegateCallableStatement().wasNull(); +return getDelegateCallableStatement().getBigDecimal(parameterIndex); } catch (final SQLException e) { handleException(e); -return false; +return null; } } +/** @deprecated Use {@link #getBigDecimal(int)} or {@link #getBigDecimal(String)} */ @Override -public String getString(final int parameterIndex) throws SQLException { +@Deprecated +public BigDecimal getBigDecimal(final int parameterIndex, final int scale) throws SQLException { checkOpen(); try { -return getDelegateCallableStatement().getString(parameterIndex); +return getDelegateCallableStatement().getBigDecimal(parameterIndex, scale); } catch (final SQLException e) { handleException(e); return null; @@ -107,65 +111,65 @@ public class DelegatingCallableStatement extends DelegatingPreparedStatement imp } @Override -public boolean getBoolean(final int parameterIndex) throws SQLException { +public BigDecimal getBigDecimal(final String parameterName) throws SQLException { checkOpen(); try { -return getDelegateCallableStatement().getBoolean(parameterIndex); +return getDelegateCallableStatement().getBigDecimal(parameterName); } catch (final SQLException e) { handleException(e); -return false; +return null; } } @Override -public byte getByte(final int parameterIndex) throws SQLException { +public Blob getBlob(final int i) throws SQLException { checkOpen(); try { -return getDelegateCallableStatement().getByte(parameterIndex); +return getDelegateCallableStatement().getBlob(i); } catch (final SQLException e) { handleException(e); -return 0; +return null; } } @Override -public short getShort(final int parameterIndex) throws SQLException { +public Blob getBlob(final String parameterName) throws
commons-dbcp git commit: Sort members in AB order so it's easier to find stuff.
Repository: commons-dbcp Updated Branches: refs/heads/master f2e00c045 -> 37daf894a Sort members in AB order so it's easier to find stuff. Project: http://git-wip-us.apache.org/repos/asf/commons-dbcp/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-dbcp/commit/37daf894 Tree: http://git-wip-us.apache.org/repos/asf/commons-dbcp/tree/37daf894 Diff: http://git-wip-us.apache.org/repos/asf/commons-dbcp/diff/37daf894 Branch: refs/heads/master Commit: 37daf894acfcb89582e701a36e1695f772fee3a4 Parents: f2e00c0 Author: Gary Gregory Authored: Sun Jun 17 08:53:38 2018 -0600 Committer: Gary Gregory Committed: Sun Jun 17 08:53:38 2018 -0600 -- .../commons/dbcp2/TesterPreparedStatement.java | 276 +-- 1 file changed, 138 insertions(+), 138 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/37daf894/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java -- diff --git a/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java b/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java index 814797b..292ecb9 100644 --- a/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java +++ b/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java @@ -86,10 +86,9 @@ public class TesterPreparedStatement extends TesterStatement implements Prepared } } -public TesterPreparedStatement(final Connection conn, final String sql, final String columnNames[]) { -super(conn); +public TesterPreparedStatement(final Connection conn, final String sql, final int resultSetType, final int resultSetConcurrency) { +super(conn, resultSetType, resultSetConcurrency); _sql = sql; -_columnNames = columnNames; try { _catalog = conn.getCatalog(); } catch (final SQLException e) { @@ -97,8 +96,9 @@ public class TesterPreparedStatement extends TesterStatement implements Prepared } } -public TesterPreparedStatement(final Connection conn, final String sql, final int resultSetType, final int resultSetConcurrency) { -super(conn, resultSetType, resultSetConcurrency); +public TesterPreparedStatement(final Connection conn, final String sql, final int resultSetType, final int resultSetConcurrency, +final int resultSetHoldability) { +super(conn, resultSetType, resultSetConcurrency, resultSetHoldability); _sql = sql; try { _catalog = conn.getCatalog(); @@ -107,10 +107,10 @@ public class TesterPreparedStatement extends TesterStatement implements Prepared } } -public TesterPreparedStatement(final Connection conn, final String sql, final int resultSetType, final int resultSetConcurrency, -final int resultSetHoldability) { -super(conn, resultSetType, resultSetConcurrency, resultSetHoldability); +public TesterPreparedStatement(final Connection conn, final String sql, final String columnNames[]) { +super(conn); _sql = sql; +_columnNames = columnNames; try { _catalog = conn.getCatalog(); } catch (final SQLException e) { @@ -118,40 +118,37 @@ public class TesterPreparedStatement extends TesterStatement implements Prepared } } -/** for junit test only */ -public String getSql() { -return _sql; -} - -public String getCatalog() { -return _catalog; +@Override +public void addBatch() throws SQLException { +checkOpen(); } -public int getAutoGeneratedKeys() { -return _autoGeneratedKeys; +@Override +public void clearParameters() throws SQLException { +checkOpen(); } -public int[] getColumnIndexes() { -return _columnIndexes; +@Override +public boolean execute() throws SQLException { +checkOpen(); return true; } -public String[] getColumnNames() { -return _columnNames; +@Override +public boolean execute(final String sql, final int autoGeneratedKeys) throws SQLException { +checkOpen(); +return true; } @Override -public ResultSet executeQuery(final String sql) throws SQLException { +public boolean execute(final String sl, final int columnIndexes[]) throws SQLException { checkOpen(); -if("null".equals(sql)) { -return null; -} -return new TesterResultSet(this, _resultSetType, _resultSetConcurrency); +return true; } @Override -public int executeUpdate(final String sql) throws SQLException { +public boolean execute(final String sql, final String columnNames[]) throws SQLException { checkOpen(); -return _rowsUpdated; +
commons-dbcp git commit: Sort members in AB order so it's easier to find stuff.
Repository: commons-dbcp Updated Branches: refs/heads/master f05518d99 -> b383b9c38 Sort members in AB order so it's easier to find stuff. Project: http://git-wip-us.apache.org/repos/asf/commons-dbcp/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-dbcp/commit/b383b9c3 Tree: http://git-wip-us.apache.org/repos/asf/commons-dbcp/tree/b383b9c3 Diff: http://git-wip-us.apache.org/repos/asf/commons-dbcp/diff/b383b9c3 Branch: refs/heads/master Commit: b383b9c38090f9eae7ccc7bd82052141a3eeca60 Parents: f05518d Author: Gary Gregory Authored: Sun Jun 17 08:36:03 2018 -0600 Committer: Gary Gregory Committed: Sun Jun 17 08:36:03 2018 -0600 -- .../apache/commons/dbcp2/TesterStatement.java | 287 ++- 1 file changed, 144 insertions(+), 143 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/b383b9c3/src/test/java/org/apache/commons/dbcp2/TesterStatement.java -- diff --git a/src/test/java/org/apache/commons/dbcp2/TesterStatement.java b/src/test/java/org/apache/commons/dbcp2/TesterStatement.java index 361eff6..c4b0a17 100644 --- a/src/test/java/org/apache/commons/dbcp2/TesterStatement.java +++ b/src/test/java/org/apache/commons/dbcp2/TesterStatement.java @@ -27,16 +27,33 @@ import java.sql.Statement; * A dummy {@link Statement}, for testing purposes. */ public class TesterStatement implements Statement { +protected Connection _connection = null; + +protected boolean _open = true; + +protected int _rowsUpdated = 1; + +protected boolean _executeResponse = true; +protected int _maxFieldSize = 1024; +protected int _maxRows = 1024; +protected boolean _escapeProcessing = false; +protected int _queryTimeout = 1000; +protected String _cursorName = null; +protected int _fetchDirection = 1; +protected int _fetchSize = 1; +protected int _resultSetConcurrency = 1; +protected int _resultSetType = 1; +private int _resultSetHoldability = 1; +protected ResultSet _resultSet = null; + public TesterStatement(final Connection conn) { _connection = conn; } - public TesterStatement(final Connection conn, final int resultSetType, final int resultSetConcurrency) { _connection = conn; _resultSetType = resultSetType; _resultSetConcurrency = resultSetConcurrency; } - public TesterStatement(final Connection conn, final int resultSetType, final int resultSetConcurrency, final int resultSetHoldability) { _connection = conn; @@ -45,50 +62,30 @@ public class TesterStatement implements Statement { _resultSetHoldability = resultSetHoldability; } -protected Connection _connection = null; -protected boolean _open = true; -protected int _rowsUpdated = 1; -protected boolean _executeResponse = true; -protected int _maxFieldSize = 1024; -protected int _maxRows = 1024; -protected boolean _escapeProcessing = false; -protected int _queryTimeout = 1000; -protected String _cursorName = null; -protected int _fetchDirection = 1; -protected int _fetchSize = 1; -protected int _resultSetConcurrency = 1; -protected int _resultSetType = 1; -private int _resultSetHoldability = 1; -protected ResultSet _resultSet = null; +@Override +public void addBatch(final String sql) throws SQLException { +checkOpen(); +} @Override -public ResultSet executeQuery(final String sql) throws SQLException { +public void cancel() throws SQLException { checkOpen(); -if("null".equals(sql)) { -return null; -} -if("invalid".equals(sql)) { -throw new SQLException("invalid query"); -} -if ("broken".equals(sql)) { -throw new SQLException("broken connection"); -} -if("select username".equals(sql)) { -final String userName = ((TesterConnection) _connection).getUserName(); -final Object[][] data = {{userName}}; -return new TesterResultSet(this, data); -} -// Simulate timeout if queryTimout is set to less than 5 seconds -if (_queryTimeout > 0 && _queryTimeout < 5) { -throw new SQLException("query timeout"); +} + +protected void checkOpen() throws SQLException { +if(!_open) { +throw new SQLException("Connection is closed."); } -return new TesterResultSet(this); } @Override -public int executeUpdate(final String sql) throws SQLException { +public void clearBatch() throws SQLException { +checkOpen(); +} + +@Override +public void clearWarnings() throws SQLException { checkOpen(); -return _rowsUpdated; }
commons-dbcp git commit: Sort members in AB order so it's easier to find stuff.
Repository: commons-dbcp Updated Branches: refs/heads/master 11dca5f87 -> f05518d99 Sort members in AB order so it's easier to find stuff. Project: http://git-wip-us.apache.org/repos/asf/commons-dbcp/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-dbcp/commit/f05518d9 Tree: http://git-wip-us.apache.org/repos/asf/commons-dbcp/tree/f05518d9 Diff: http://git-wip-us.apache.org/repos/asf/commons-dbcp/diff/f05518d9 Branch: refs/heads/master Commit: f05518d99227ade0b7928592c28a67ff1f0b3bf3 Parents: 11dca5f Author: Gary Gregory Authored: Sat Jun 16 17:39:08 2018 -0600 Committer: Gary Gregory Committed: Sat Jun 16 17:39:08 2018 -0600 -- .../commons/dbcp2/DelegatingStatement.java | 538 +-- 1 file changed, 269 insertions(+), 269 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/f05518d9/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 76557d3..00f440f 100644 --- a/src/main/java/org/apache/commons/dbcp2/DelegatingStatement.java +++ b/src/main/java/org/apache/commons/dbcp2/DelegatingStatement.java @@ -42,6 +42,8 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { /** The connection that created me. **/ private DelegatingConnection connection; +private boolean closed = false; + /** * Create a wrapper for the Statement which traces this Statement to the Connection which created it and the code * which created it. @@ -58,66 +60,60 @@ public class DelegatingStatement extends AbandonedTrace implements Statement { } /** - * Returns my underlying {@link Statement}. * - * @return my underlying {@link Statement}. - * @see #getInnermostDelegate + * @throws SQLException + * thrown by the delegating statement. + * @since 2.4.0 made public, was protected in 2.3.0. */ -public Statement getDelegate() { -return statement; +public void activate() throws SQLException { +if (statement instanceof DelegatingStatement) { +((DelegatingStatement) statement).activate(); +} } -/** - * If my underlying {@link Statement} is not a {@code DelegatingStatement}, returns it, otherwise recursively - * invokes this method on my delegate. - * - * Hence this method will return the first delegate that is not a {@code DelegatingStatement} or {@code null} when - * no non-{@code DelegatingStatement} delegate can be found by traversing this chain. - * - * - * This method is useful when you may have nested {@code DelegatingStatement}s, and you want to make sure to obtain - * a "genuine" {@link Statement}. - * - * - * @return The innermost delegate. - * - * @see #getDelegate - */ -@SuppressWarnings("resource") -public Statement getInnermostDelegate() { -Statement s = statement; -while (s != null && s instanceof DelegatingStatement) { -s = ((DelegatingStatement) s).getDelegate(); -if (this == s) { -return null; -} +@Override +public void addBatch(final String sql) throws SQLException { +checkOpen(); +try { +statement.addBatch(sql); +} catch (final SQLException e) { +handleException(e); } -return s; } -/** - * Sets my delegate. - * - * @param statement - *my delegate. - */ -public void setDelegate(final Statement statement) { -this.statement = statement; +@Override +public void cancel() throws SQLException { +checkOpen(); +try { +statement.cancel(); +} catch (final SQLException e) { +handleException(e); +} } -private boolean closed = false; - -protected boolean isClosedInternal() { -return closed; +protected void checkOpen() throws SQLException { +if (isClosed()) { +throw new SQLException(this.getClass().getName() + " with address: \"" + this.toString() + "\" is closed."); +} } -protected void setClosedInternal(final boolean closed) { -this.closed = closed; +@Override +public void clearBatch() throws SQLException { +checkOpen(); +try { +statement.clearBatch(); +} catch (final SQLException e) { +handleException(e); +} } -protected void checkOpen() throws SQLException { -if (isClosed()) { -throw new SQLException(this.getClass().getName() + " with address:
commons-dbcp git commit: Sort members in AB order so it's easier to find stuff.
Repository: commons-dbcp Updated Branches: refs/heads/master f4cdc188e -> e45c8fbc3 Sort members in AB order so it's easier to find stuff. Project: http://git-wip-us.apache.org/repos/asf/commons-dbcp/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-dbcp/commit/e45c8fbc Tree: http://git-wip-us.apache.org/repos/asf/commons-dbcp/tree/e45c8fbc Diff: http://git-wip-us.apache.org/repos/asf/commons-dbcp/diff/e45c8fbc Branch: refs/heads/master Commit: e45c8fbc3e119e5044bd0143ba253380ec45ecbf Parents: f4cdc18 Author: Gary Gregory Authored: Sat Jun 16 17:32:01 2018 -0600 Committer: Gary Gregory Committed: Sat Jun 16 17:32:01 2018 -0600 -- .../dbcp2/DelegatingDatabaseMetaData.java | 390 +-- 1 file changed, 195 insertions(+), 195 deletions(-) -- http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/e45c8fbc/src/main/java/org/apache/commons/dbcp2/DelegatingDatabaseMetaData.java -- diff --git a/src/main/java/org/apache/commons/dbcp2/DelegatingDatabaseMetaData.java b/src/main/java/org/apache/commons/dbcp2/DelegatingDatabaseMetaData.java index 4a36cb9..d345371 100644 --- a/src/main/java/org/apache/commons/dbcp2/DelegatingDatabaseMetaData.java +++ b/src/main/java/org/apache/commons/dbcp2/DelegatingDatabaseMetaData.java @@ -56,48 +56,6 @@ public class DelegatingDatabaseMetaData implements DatabaseMetaData { this.databaseMetaData = databaseMetaData; } -/** - * Gets the underlying database meta data. - * - * @return The underlying database meta data. - */ -public DatabaseMetaData getDelegate() { -return databaseMetaData; -} - -/** - * If my underlying {@link ResultSet} is not a {@code DelegatingResultSet}, returns it, otherwise recursively - * invokes this method on my delegate. - * - * Hence this method will return the first delegate that is not a {@code DelegatingResultSet}, or {@code null} when - * no non-{@code DelegatingResultSet} delegate can be found by traversing this chain. - * - * - * This method is useful when you may have nested {@code DelegatingResultSet}s, and you want to make sure to obtain - * a "genuine" {@link ResultSet}. - * - * - * @return the innermost database meta data. - */ -public DatabaseMetaData getInnermostDelegate() { -DatabaseMetaData m = databaseMetaData; -while (m != null && m instanceof DelegatingDatabaseMetaData) { -m = ((DelegatingDatabaseMetaData) m).getDelegate(); -if (this == m) { -return null; -} -} -return m; -} - -protected void handleException(final SQLException e) throws SQLException { -if (connection != null) { -connection.handleException(e); -} else { -throw e; -} -} - @Override public boolean allProceduresAreCallable() throws SQLException { try { @@ -119,6 +77,16 @@ public class DelegatingDatabaseMetaData implements DatabaseMetaData { } @Override +public boolean autoCommitFailureClosesAllResultSets() throws SQLException { +try { +return databaseMetaData.autoCommitFailureClosesAllResultSets(); +} catch (final SQLException e) { +handleException(e); +return false; +} +} + +@Override public boolean dataDefinitionCausesTransactionCommit() throws SQLException { try { return databaseMetaData.dataDefinitionCausesTransactionCommit(); @@ -159,6 +127,17 @@ public class DelegatingDatabaseMetaData implements DatabaseMetaData { } @Override +public boolean generatedKeyAlwaysReturned() throws SQLException { +connection.checkOpen(); +try { +return databaseMetaData.generatedKeyAlwaysReturned(); +} catch (final SQLException e) { +handleException(e); +return false; +} +} + +@Override public ResultSet getAttributes(final String catalog, final String schemaPattern, final String typeNamePattern, final String attributeNamePattern) throws SQLException { connection.checkOpen(); @@ -185,6 +164,17 @@ public class DelegatingDatabaseMetaData implements DatabaseMetaData { } @Override +public ResultSet getCatalogs() throws SQLException { +connection.checkOpen(); +try { +return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getCatalogs()); +} catch (final SQLException e) { +handleException(e); +throw new AssertionError(); +} +} + +@Override public String getCatalogSeparator() throws SQLException { try { return