Sort members in AB order so it's easier to find stuff.
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 @@
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.
- * <p>
- * 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.
- * </p>
- * <p>
- * This method is useful when you may have nested {@code DelegatingResultSet}s, and you want to make sure to obtain
- * a "genuine" {@link ResultSet}.
- * </p>
- *
- * @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 @@
}
@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 @@
}
@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 @@
}
@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 databaseMetaData.getCatalogSeparator();
@@ -205,10 +195,10 @@
}
@Override
- public ResultSet getCatalogs() throws SQLException {
+ public ResultSet getClientInfoProperties() throws SQLException {
connection.checkOpen();
try {
- return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getCatalogs());
+ return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getClientInfoProperties());
} catch (final SQLException e) {
handleException(e);
throw new AssertionError();
@@ -309,6 +299,15 @@
}
}
+ /**
+ * Gets the underlying database meta data.
+ *
+ * @return The underlying database meta data.
+ */
+ public DatabaseMetaData getDelegate() {
+ return databaseMetaData;
+ }
+
@Override
public int getDriverMajorVersion() {
return databaseMetaData.getDriverMajorVersion();
@@ -363,6 +362,32 @@
}
@Override
+ public ResultSet getFunctionColumns(final String catalog, final String schemaPattern,
+ final String functionNamePattern, final String columnNamePattern) throws SQLException {
+ connection.checkOpen();
+ try {
+ return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getFunctionColumns(catalog,
+ schemaPattern, functionNamePattern, columnNamePattern));
+ } catch (final SQLException e) {
+ handleException(e);
+ throw new AssertionError();
+ }
+ }
+
+ @Override
+ public ResultSet getFunctions(final String catalog, final String schemaPattern, final String functionNamePattern)
+ throws SQLException {
+ connection.checkOpen();
+ try {
+ return DelegatingResultSet.wrapResultSet(connection,
+ databaseMetaData.getFunctions(catalog, schemaPattern, functionNamePattern));
+ } catch (final SQLException e) {
+ handleException(e);
+ throw new AssertionError();
+ }
+ }
+
+ @Override
public String getIdentifierQuoteString() throws SQLException {
try {
return databaseMetaData.getIdentifierQuoteString();
@@ -398,6 +423,31 @@
}
}
+ /**
+ * If my underlying {@link ResultSet} is not a {@code DelegatingResultSet}, returns it, otherwise recursively
+ * invokes this method on my delegate.
+ * <p>
+ * 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.
+ * </p>
+ * <p>
+ * This method is useful when you may have nested {@code DelegatingResultSet}s, and you want to make sure to obtain
+ * a "genuine" {@link ResultSet}.
+ * </p>
+ *
+ * @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;
+ }
+
@Override
public int getJDBCMajorVersion() throws SQLException {
try {
@@ -654,16 +704,6 @@
}
@Override
- public String getProcedureTerm() throws SQLException {
- try {
- return databaseMetaData.getProcedureTerm();
- } catch (final SQLException e) {
- handleException(e);
- throw new AssertionError();
- }
- }
-
- @Override
public ResultSet getProcedures(final String catalog, final String schemaPattern, final String procedureNamePattern)
throws SQLException {
connection.checkOpen();
@@ -677,6 +717,29 @@
}
@Override
+ public String getProcedureTerm() throws SQLException {
+ try {
+ return databaseMetaData.getProcedureTerm();
+ } catch (final SQLException e) {
+ handleException(e);
+ throw new AssertionError();
+ }
+ }
+
+ @Override
+ public ResultSet getPseudoColumns(final String catalog, final String schemaPattern, final String tableNamePattern,
+ final String columnNamePattern) throws SQLException {
+ connection.checkOpen();
+ try {
+ return DelegatingResultSet.wrapResultSet(connection,
+ databaseMetaData.getPseudoColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern));
+ } catch (final SQLException e) {
+ handleException(e);
+ throw new AssertionError();
+ }
+ }
+
+ @Override
public int getResultSetHoldability() throws SQLException {
try {
return databaseMetaData.getResultSetHoldability();
@@ -687,6 +750,58 @@
}
@Override
+ public RowIdLifetime getRowIdLifetime() throws SQLException {
+ try {
+ return databaseMetaData.getRowIdLifetime();
+ } catch (final SQLException e) {
+ handleException(e);
+ throw new AssertionError();
+ }
+ }
+
+ @Override
+ public ResultSet getSchemas() throws SQLException {
+ connection.checkOpen();
+ try {
+ return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getSchemas());
+ } catch (final SQLException e) {
+ handleException(e);
+ throw new AssertionError();
+ }
+ }
+
+ @Override
+ public ResultSet getSchemas(final String catalog, final String schemaPattern) throws SQLException {
+ connection.checkOpen();
+ try {
+ return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getSchemas(catalog, schemaPattern));
+ } catch (final SQLException e) {
+ handleException(e);
+ throw new AssertionError();
+ }
+ }
+
+ @Override
+ public String getSchemaTerm() throws SQLException {
+ try {
+ return databaseMetaData.getSchemaTerm();
+ } catch (final SQLException e) {
+ handleException(e);
+ throw new AssertionError();
+ }
+ }
+
+ @Override
+ public String getSearchStringEscape() throws SQLException {
+ try {
+ return databaseMetaData.getSearchStringEscape();
+ } catch (final SQLException e) {
+ handleException(e);
+ throw new AssertionError();
+ }
+ }
+
+ @Override
public String getSQLKeywords() throws SQLException {
try {
return databaseMetaData.getSQLKeywords();
@@ -707,37 +822,6 @@
}
@Override
- public String getSchemaTerm() throws SQLException {
- try {
- return databaseMetaData.getSchemaTerm();
- } catch (final SQLException e) {
- handleException(e);
- throw new AssertionError();
- }
- }
-
- @Override
- public ResultSet getSchemas() throws SQLException {
- connection.checkOpen();
- try {
- return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getSchemas());
- } catch (final SQLException e) {
- handleException(e);
- throw new AssertionError();
- }
- }
-
- @Override
- public String getSearchStringEscape() throws SQLException {
- try {
- return databaseMetaData.getSearchStringEscape();
- } catch (final SQLException e) {
- handleException(e);
- throw new AssertionError();
- }
- }
-
- @Override
public String getStringFunctions() throws SQLException {
try {
return databaseMetaData.getStringFunctions();
@@ -797,10 +881,12 @@
}
@Override
- public ResultSet getTableTypes() throws SQLException {
+ public ResultSet getTables(final String catalog, final String schemaPattern, final String tableNamePattern,
+ final String[] types) throws SQLException {
connection.checkOpen();
try {
- return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getTableTypes());
+ return DelegatingResultSet.wrapResultSet(connection,
+ databaseMetaData.getTables(catalog, schemaPattern, tableNamePattern, types));
} catch (final SQLException e) {
handleException(e);
throw new AssertionError();
@@ -808,12 +894,10 @@
}
@Override
- public ResultSet getTables(final String catalog, final String schemaPattern, final String tableNamePattern,
- final String[] types) throws SQLException {
+ public ResultSet getTableTypes() throws SQLException {
connection.checkOpen();
try {
- return DelegatingResultSet.wrapResultSet(connection,
- databaseMetaData.getTables(catalog, schemaPattern, tableNamePattern, types));
+ return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getTableTypes());
} catch (final SQLException e) {
handleException(e);
throw new AssertionError();
@@ -887,6 +971,14 @@
}
}
+ protected void handleException(final SQLException e) throws SQLException {
+ if (connection != null) {
+ connection.handleException(e);
+ } else {
+ throw e;
+ }
+ }
+
@Override
public boolean insertsAreDetected(final int type) throws SQLException {
try {
@@ -918,6 +1010,17 @@
}
@Override
+ public boolean isWrapperFor(final Class<?> iface) throws SQLException {
+ if (iface.isAssignableFrom(getClass())) {
+ return true;
+ } else if (iface.isAssignableFrom(databaseMetaData.getClass())) {
+ return true;
+ } else {
+ return databaseMetaData.isWrapperFor(iface);
+ }
+ }
+
+ @Override
public boolean locatorsUpdateCopy() throws SQLException {
try {
return databaseMetaData.locatorsUpdateCopy();
@@ -1098,6 +1201,26 @@
}
@Override
+ public boolean supportsAlterTableWithAddColumn() throws SQLException {
+ try {
+ return databaseMetaData.supportsAlterTableWithAddColumn();
+ } catch (final SQLException e) {
+ handleException(e);
+ return false;
+ }
+ }
+
+ @Override
+ public boolean supportsAlterTableWithDropColumn() throws SQLException {
+ try {
+ return databaseMetaData.supportsAlterTableWithDropColumn();
+ } catch (final SQLException e) {
+ handleException(e);
+ return false;
+ }
+ }
+
+ @Override
public boolean supportsANSI92EntryLevelSQL() throws SQLException {
try {
return databaseMetaData.supportsANSI92EntryLevelSQL();
@@ -1128,26 +1251,6 @@
}
@Override
- public boolean supportsAlterTableWithAddColumn() throws SQLException {
- try {
- return databaseMetaData.supportsAlterTableWithAddColumn();
- } catch (final SQLException e) {
- handleException(e);
- return false;
- }
- }
-
- @Override
- public boolean supportsAlterTableWithDropColumn() throws SQLException {
- try {
- return databaseMetaData.supportsAlterTableWithDropColumn();
- } catch (final SQLException e) {
- handleException(e);
- return false;
- }
- }
-
- @Override
public boolean supportsBatchUpdates() throws SQLException {
try {
return databaseMetaData.supportsBatchUpdates();
@@ -1658,6 +1761,16 @@
}
@Override
+ public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
+ try {
+ return databaseMetaData.supportsStoredFunctionsUsingCallSyntax();
+ } catch (final SQLException e) {
+ handleException(e);
+ return false;
+ }
+ }
+
+ @Override
public boolean supportsStoredProcedures() throws SQLException {
try {
return databaseMetaData.supportsStoredProcedures();
@@ -1687,6 +1800,8 @@
}
}
+ /* JDBC_4_ANT_KEY_BEGIN */
+
@Override
public boolean supportsSubqueriesInIns() throws SQLException {
try {
@@ -1758,6 +1873,17 @@
}
@Override
+ public <T> T unwrap(final Class<T> iface) throws SQLException {
+ if (iface.isAssignableFrom(getClass())) {
+ return iface.cast(this);
+ } else if (iface.isAssignableFrom(databaseMetaData.getClass())) {
+ return iface.cast(databaseMetaData);
+ } else {
+ return databaseMetaData.unwrap(iface);
+ }
+ }
+
+ @Override
public boolean updatesAreDetected(final int type) throws SQLException {
try {
return databaseMetaData.updatesAreDetected(type);
@@ -1767,6 +1893,8 @@
}
}
+ /* JDBC_4_ANT_KEY_END */
+
@Override
public boolean usesLocalFilePerTable() throws SQLException {
try {
@@ -1786,132 +1914,4 @@
return false;
}
}
-
- /* JDBC_4_ANT_KEY_BEGIN */
-
- @Override
- public boolean isWrapperFor(final Class<?> iface) throws SQLException {
- if (iface.isAssignableFrom(getClass())) {
- return true;
- } else if (iface.isAssignableFrom(databaseMetaData.getClass())) {
- return true;
- } else {
- return databaseMetaData.isWrapperFor(iface);
- }
- }
-
- @Override
- public <T> T unwrap(final Class<T> iface) throws SQLException {
- if (iface.isAssignableFrom(getClass())) {
- return iface.cast(this);
- } else if (iface.isAssignableFrom(databaseMetaData.getClass())) {
- return iface.cast(databaseMetaData);
- } else {
- return databaseMetaData.unwrap(iface);
- }
- }
-
- @Override
- public RowIdLifetime getRowIdLifetime() throws SQLException {
- try {
- return databaseMetaData.getRowIdLifetime();
- } catch (final SQLException e) {
- handleException(e);
- throw new AssertionError();
- }
- }
-
- @Override
- public ResultSet getSchemas(final String catalog, final String schemaPattern) throws SQLException {
- connection.checkOpen();
- try {
- return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getSchemas(catalog, schemaPattern));
- } catch (final SQLException e) {
- handleException(e);
- throw new AssertionError();
- }
- }
-
- @Override
- public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
- try {
- return databaseMetaData.autoCommitFailureClosesAllResultSets();
- } catch (final SQLException e) {
- handleException(e);
- return false;
- }
- }
-
- @Override
- public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
- try {
- return databaseMetaData.supportsStoredFunctionsUsingCallSyntax();
- } catch (final SQLException e) {
- handleException(e);
- return false;
- }
- }
-
- @Override
- public ResultSet getClientInfoProperties() throws SQLException {
- connection.checkOpen();
- try {
- return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getClientInfoProperties());
- } catch (final SQLException e) {
- handleException(e);
- throw new AssertionError();
- }
- }
-
- @Override
- public ResultSet getFunctions(final String catalog, final String schemaPattern, final String functionNamePattern)
- throws SQLException {
- connection.checkOpen();
- try {
- return DelegatingResultSet.wrapResultSet(connection,
- databaseMetaData.getFunctions(catalog, schemaPattern, functionNamePattern));
- } catch (final SQLException e) {
- handleException(e);
- throw new AssertionError();
- }
- }
-
- @Override
- public ResultSet getFunctionColumns(final String catalog, final String schemaPattern,
- final String functionNamePattern, final String columnNamePattern) throws SQLException {
- connection.checkOpen();
- try {
- return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getFunctionColumns(catalog,
- schemaPattern, functionNamePattern, columnNamePattern));
- } catch (final SQLException e) {
- handleException(e);
- throw new AssertionError();
- }
- }
-
- /* JDBC_4_ANT_KEY_END */
-
- @Override
- public ResultSet getPseudoColumns(final String catalog, final String schemaPattern, final String tableNamePattern,
- final String columnNamePattern) throws SQLException {
- connection.checkOpen();
- try {
- return DelegatingResultSet.wrapResultSet(connection,
- databaseMetaData.getPseudoColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern));
- } catch (final SQLException e) {
- handleException(e);
- throw new AssertionError();
- }
- }
-
- @Override
- public boolean generatedKeyAlwaysReturned() throws SQLException {
- connection.checkOpen();
- try {
- return databaseMetaData.generatedKeyAlwaysReturned();
- } catch (final SQLException e) {
- handleException(e);
- return false;
- }
- }
}