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 <garydgreg...@gmail.com>
Authored: Sat Jun 16 17:32:01 2018 -0600
Committer: Gary Gregory <garydgreg...@gmail.com>
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.
-     * <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 @@ 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 databaseMetaData.getCatalogSeparator();
@@ -205,10 +195,10 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @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 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
         }
     }
 
+    /**
+     * 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 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @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 @@ public class DelegatingDatabaseMetaData implements 
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;
+    }
+
     @Override
     public int getJDBCMajorVersion() throws SQLException {
         try {
@@ -654,6 +704,19 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @Override
+    public ResultSet getProcedures(final String catalog, final String 
schemaPattern, final String procedureNamePattern)
+            throws SQLException {
+        connection.checkOpen();
+        try {
+            return DelegatingResultSet.wrapResultSet(connection,
+                    databaseMetaData.getProcedures(catalog, schemaPattern, 
procedureNamePattern));
+        } catch (final SQLException e) {
+            handleException(e);
+            throw new AssertionError();
+        }
+    }
+
+    @Override
     public String getProcedureTerm() throws SQLException {
         try {
             return databaseMetaData.getProcedureTerm();
@@ -664,12 +727,12 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @Override
-    public ResultSet getProcedures(final String catalog, final String 
schemaPattern, final String procedureNamePattern)
-            throws SQLException {
+    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.getProcedures(catalog, schemaPattern, 
procedureNamePattern));
+                    databaseMetaData.getPseudoColumns(catalog, schemaPattern, 
tableNamePattern, columnNamePattern));
         } catch (final SQLException e) {
             handleException(e);
             throw new AssertionError();
@@ -687,9 +750,9 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @Override
-    public String getSQLKeywords() throws SQLException {
+    public RowIdLifetime getRowIdLifetime() throws SQLException {
         try {
-            return databaseMetaData.getSQLKeywords();
+            return databaseMetaData.getRowIdLifetime();
         } catch (final SQLException e) {
             handleException(e);
             throw new AssertionError();
@@ -697,19 +760,21 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @Override
-    public int getSQLStateType() throws SQLException {
+    public ResultSet getSchemas() throws SQLException {
+        connection.checkOpen();
         try {
-            return databaseMetaData.getSQLStateType();
+            return DelegatingResultSet.wrapResultSet(connection, 
databaseMetaData.getSchemas());
         } catch (final SQLException e) {
             handleException(e);
-            return 0;
+            throw new AssertionError();
         }
     }
 
     @Override
-    public String getSchemaTerm() throws SQLException {
+    public ResultSet getSchemas(final String catalog, final String 
schemaPattern) throws SQLException {
+        connection.checkOpen();
         try {
-            return databaseMetaData.getSchemaTerm();
+            return DelegatingResultSet.wrapResultSet(connection, 
databaseMetaData.getSchemas(catalog, schemaPattern));
         } catch (final SQLException e) {
             handleException(e);
             throw new AssertionError();
@@ -717,10 +782,9 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @Override
-    public ResultSet getSchemas() throws SQLException {
-        connection.checkOpen();
+    public String getSchemaTerm() throws SQLException {
         try {
-            return DelegatingResultSet.wrapResultSet(connection, 
databaseMetaData.getSchemas());
+            return databaseMetaData.getSchemaTerm();
         } catch (final SQLException e) {
             handleException(e);
             throw new AssertionError();
@@ -738,6 +802,26 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @Override
+    public String getSQLKeywords() throws SQLException {
+        try {
+            return databaseMetaData.getSQLKeywords();
+        } catch (final SQLException e) {
+            handleException(e);
+            throw new AssertionError();
+        }
+    }
+
+    @Override
+    public int getSQLStateType() throws SQLException {
+        try {
+            return databaseMetaData.getSQLStateType();
+        } catch (final SQLException e) {
+            handleException(e);
+            return 0;
+        }
+    }
+
+    @Override
     public String getStringFunctions() throws SQLException {
         try {
             return databaseMetaData.getStringFunctions();
@@ -797,10 +881,12 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @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 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @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 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
         }
     }
 
+    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 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @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,9 +1201,9 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @Override
-    public boolean supportsANSI92EntryLevelSQL() throws SQLException {
+    public boolean supportsAlterTableWithAddColumn() throws SQLException {
         try {
-            return databaseMetaData.supportsANSI92EntryLevelSQL();
+            return databaseMetaData.supportsAlterTableWithAddColumn();
         } catch (final SQLException e) {
             handleException(e);
             return false;
@@ -1108,9 +1211,9 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @Override
-    public boolean supportsANSI92FullSQL() throws SQLException {
+    public boolean supportsAlterTableWithDropColumn() throws SQLException {
         try {
-            return databaseMetaData.supportsANSI92FullSQL();
+            return databaseMetaData.supportsAlterTableWithDropColumn();
         } catch (final SQLException e) {
             handleException(e);
             return false;
@@ -1118,9 +1221,9 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @Override
-    public boolean supportsANSI92IntermediateSQL() throws SQLException {
+    public boolean supportsANSI92EntryLevelSQL() throws SQLException {
         try {
-            return databaseMetaData.supportsANSI92IntermediateSQL();
+            return databaseMetaData.supportsANSI92EntryLevelSQL();
         } catch (final SQLException e) {
             handleException(e);
             return false;
@@ -1128,9 +1231,9 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @Override
-    public boolean supportsAlterTableWithAddColumn() throws SQLException {
+    public boolean supportsANSI92FullSQL() throws SQLException {
         try {
-            return databaseMetaData.supportsAlterTableWithAddColumn();
+            return databaseMetaData.supportsANSI92FullSQL();
         } catch (final SQLException e) {
             handleException(e);
             return false;
@@ -1138,9 +1241,9 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @Override
-    public boolean supportsAlterTableWithDropColumn() throws SQLException {
+    public boolean supportsANSI92IntermediateSQL() throws SQLException {
         try {
-            return databaseMetaData.supportsAlterTableWithDropColumn();
+            return databaseMetaData.supportsANSI92IntermediateSQL();
         } catch (final SQLException e) {
             handleException(e);
             return false;
@@ -1658,6 +1761,16 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @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 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
         }
     }
 
+    /* JDBC_4_ANT_KEY_BEGIN */
+
     @Override
     public boolean supportsSubqueriesInIns() throws SQLException {
         try {
@@ -1758,49 +1873,6 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @Override
-    public boolean updatesAreDetected(final int type) throws SQLException {
-        try {
-            return databaseMetaData.updatesAreDetected(type);
-        } catch (final SQLException e) {
-            handleException(e);
-            return false;
-        }
-    }
-
-    @Override
-    public boolean usesLocalFilePerTable() throws SQLException {
-        try {
-            return databaseMetaData.usesLocalFilePerTable();
-        } catch (final SQLException e) {
-            handleException(e);
-            return false;
-        }
-    }
-
-    @Override
-    public boolean usesLocalFiles() throws SQLException {
-        try {
-            return databaseMetaData.usesLocalFiles();
-        } catch (final SQLException e) {
-            handleException(e);
-            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);
@@ -1812,103 +1884,31 @@ public class DelegatingDatabaseMetaData implements 
DatabaseMetaData {
     }
 
     @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 {
+    public boolean updatesAreDetected(final int type) throws SQLException {
         try {
-            return databaseMetaData.supportsStoredFunctionsUsingCallSyntax();
+            return databaseMetaData.updatesAreDetected(type);
         } 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();
+    public boolean usesLocalFilePerTable() throws SQLException {
         try {
-            return DelegatingResultSet.wrapResultSet(connection,
-                    databaseMetaData.getPseudoColumns(catalog, schemaPattern, 
tableNamePattern, columnNamePattern));
+            return databaseMetaData.usesLocalFilePerTable();
         } catch (final SQLException e) {
             handleException(e);
-            throw new AssertionError();
+            return false;
         }
     }
 
     @Override
-    public boolean generatedKeyAlwaysReturned() throws SQLException {
-        connection.checkOpen();
+    public boolean usesLocalFiles() throws SQLException {
         try {
-            return databaseMetaData.generatedKeyAlwaysReturned();
+            return databaseMetaData.usesLocalFiles();
         } catch (final SQLException e) {
             handleException(e);
             return false;

Reply via email to