    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017package org.apache.commons.dbcp2;
    018
    019import java.sql.Connection;
    020import java.sql.DatabaseMetaData;
    021import java.sql.ResultSet;
    022import java.sql.RowIdLifetime;
    023import java.sql.SQLException;
    024import java.util.Objects;
    025import java.util.concurrent.Callable;
    026
    027/**
    028 * <p>
    029 * A base delegating implementation of {@link DatabaseMetaData}.
    030 * </p>
    031 * <p>
    032 * Methods that create {@link ResultSet} objects are wrapped to create {@link DelegatingResultSet} objects and the remaining methods simply call the
    033 * corresponding method on the "delegate" provided in the constructor.
    034 * </p>
    035 *
    036 * @since 2.0
    037 */
    038public class DelegatingDatabaseMetaData implements DatabaseMetaData {
    039
    040    /** My delegate {@link DatabaseMetaData} */
    041    private final DatabaseMetaData databaseMetaData;
    042
    043    /** The connection that created me. **/
    044    private final DelegatingConnection<?> connection;
    045
    046    /**
    047     * Constructs a new instance for the given delegating connection and database meta data.
    048     *
    049     * @param connection       the delegating connection
    050     * @param databaseMetaData the database meta data
    051     */
    052    public DelegatingDatabaseMetaData(final DelegatingConnection<?> connection, final DatabaseMetaData databaseMetaData) {
    053        this.connection = Objects.requireNonNull(connection, "connection");
    054        this.databaseMetaData = Objects.requireNonNull(databaseMetaData, "databaseMetaData");
    055    }
    056
    057    @Override
    058    public boolean allProceduresAreCallable() throws SQLException {
    059        return getB(databaseMetaData::allProceduresAreCallable);
    060    }
    061
    062    @Override
    063    public boolean allTablesAreSelectable() throws SQLException {
    064        return getB(databaseMetaData::allTablesAreSelectable);
    065    }
    066
    067    @Override
    068    public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
    069        return getB(databaseMetaData::autoCommitFailureClosesAllResultSets);
    070    }
    071
    072    @Override
    073    public boolean dataDefinitionCausesTransactionCommit() throws SQLException {
    074        return getB(databaseMetaData::dataDefinitionCausesTransactionCommit);
    075    }
    076
    077    @Override
    078    public boolean dataDefinitionIgnoredInTransactions() throws SQLException {
    079        return getB(databaseMetaData::dataDefinitionIgnoredInTransactions);
    080    }
    081
    082    @Override
    083    public boolean deletesAreDetected(final int type) throws SQLException {
    084        return getB(() -> databaseMetaData.deletesAreDetected(type));
    085    }
    086
    087    @Override
    088    public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {
    089        return getB(databaseMetaData::doesMaxRowSizeIncludeBlobs);
    090    }
    091
    092    @Override
    093    public boolean generatedKeyAlwaysReturned() throws SQLException {
    094        connection.checkOpen();
    095        return getB(() -> Jdbc41Bridge.generatedKeyAlwaysReturned(databaseMetaData));
    096    }
    097
    098    private <T> T get(final Callable<T> s) throws SQLException {
    099        return get(s, null);
    100    }
    101
    102    private <T> T get(final Callable<T> s, final T defaultValue) throws SQLException {
    103        try {
    104            return s.call();
    105        } catch (final Exception e) {
    106            if (e instanceof SQLException) {
    107                handleException((SQLException) e);
    108            }
    109            return defaultValue;
    110        }
    111    }
    112
    113    @Override
    114    public ResultSet getAttributes(final String catalog, final String schemaPattern, final String typeNamePattern, final String attributeNamePattern)
    115            throws SQLException {
    116        return getRS(() -> databaseMetaData.getAttributes(catalog, schemaPattern, typeNamePattern, attributeNamePattern));
    117    }
    118
    119    private boolean getB(final Callable<Boolean> s) throws SQLException {
    120        return get(s, false);
    121    }
    122
    123    @Override
    124    public ResultSet getBestRowIdentifier(final String catalog, final String schema, final String table, final int scope, final boolean nullable)
    125            throws SQLException {
    126        return getRS(() -> databaseMetaData.getBestRowIdentifier(catalog, schema, table, scope, nullable));
    127    }
    128
    129    @Override
    130    public ResultSet getCatalogs() throws SQLException {
    131        return getRS(databaseMetaData::getCatalogs);
    132    }
    133
    134    @Override
    135    public String getCatalogSeparator() throws SQLException {
    136        return get(databaseMetaData::getCatalogSeparator);
    137    }
    138
    139    @Override
    140    public String getCatalogTerm() throws SQLException {
    141        return get(databaseMetaData::getCatalogTerm);
    142    }
    143
    144    @Override
    145    public ResultSet getClientInfoProperties() throws SQLException {
    146        return getRS(databaseMetaData::getClientInfoProperties);
    147    }
    148
    149    @Override
    150    public ResultSet getColumnPrivileges(final String catalog, final String schema, final String table, final String columnNamePattern) throws SQLException {
    151        return getRS(() -> databaseMetaData.getColumnPrivileges(catalog, schema, table, columnNamePattern));
    152    }
    153
    154    @Override
    155    public ResultSet getColumns(final String catalog, final String schemaPattern, final String tableNamePattern, final String columnNamePattern)
    156            throws SQLException {
    157        return getRS(() -> databaseMetaData.getColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern));
    158    }
    159
    160    @Override
    161    public Connection getConnection() throws SQLException {
    162        return connection;
    163    }
    164
    165    @Override
    166    public ResultSet getCrossReference(final String parentCatalog, final String parentSchema, final String parentTable, final String foreignCatalog,
    167            final String foreignSchema, final String foreignTable) throws SQLException {
    168        return getRS(() -> databaseMetaData.getCrossReference(parentCatalog, parentSchema, parentTable, foreignCatalog, foreignSchema, foreignTable));
    169    }
    170
    171    @Override
    172    public int getDatabaseMajorVersion() throws SQLException {
    173        return getI(databaseMetaData::getDatabaseMajorVersion);
    174    }
    175
    176    @Override
    177    public int getDatabaseMinorVersion() throws SQLException {
    178        return getI(databaseMetaData::getDatabaseMinorVersion);
    179    }
    180
    181    @Override
    182    public String getDatabaseProductName() throws SQLException {
    183        return get(databaseMetaData::getDatabaseProductName);
    184    }
    185
    186    @Override
    187    public String getDatabaseProductVersion() throws SQLException {
    188        return get(databaseMetaData::getDatabaseProductVersion);
    189    }
    190
    191    @Override
    192    public int getDefaultTransactionIsolation() throws SQLException {
    193        return getI(databaseMetaData::getDefaultTransactionIsolation);
    194    }
    195
    196    /**
    197     * Gets the underlying database meta data.
    198     *
    199     * @return The underlying database meta data.
    200     */
    201    public DatabaseMetaData getDelegate() {
    202        return databaseMetaData;
    203    }
    204
    205    @Override
    206    public int getDriverMajorVersion() {
    207        return databaseMetaData.getDriverMajorVersion();
    208    }
    209
    210    @Override
    211    public int getDriverMinorVersion() {
    212        return databaseMetaData.getDriverMinorVersion();
    213    }
    214
    215    @Override
    216    public String getDriverName() throws SQLException {
    217        return get(databaseMetaData::getDriverName);
    218    }
    219
    220    @Override
    221    public String getDriverVersion() throws SQLException {
    222        return get(databaseMetaData::getDriverVersion);
    223    }
    224
    225    @Override
    226    public ResultSet getExportedKeys(final String catalog, final String schema, final String table) throws SQLException {
    227        return getRS(() -> databaseMetaData.getExportedKeys(catalog, schema, table));
    228    }
    229
    230    @Override
    231    public String getExtraNameCharacters() throws SQLException {
    232        return get(databaseMetaData::getExtraNameCharacters);
    233    }
    234
    235    @Override
    236    public ResultSet getFunctionColumns(final String catalog, final String schemaPattern, final String functionNamePattern, final String columnNamePattern)
    237            throws SQLException {
    238        return getRS(() -> databaseMetaData.getFunctionColumns(catalog, schemaPattern, functionNamePattern, columnNamePattern));
    239    }
    240
    241    @Override
    242    public ResultSet getFunctions(final String catalog, final String schemaPattern, final String functionNamePattern) throws SQLException {
    243        return getRS(() -> databaseMetaData.getFunctions(catalog, schemaPattern, functionNamePattern));
    244    }
    245
    246    private int getI(final Callable<Integer> s) throws SQLException {
    247        return get(s, 0);
    248    }
    249
    250    @Override
    251    public String getIdentifierQuoteString() throws SQLException {
    252        return get(databaseMetaData::getIdentifierQuoteString);
    253    }
    254
    255    @Override
    256    public ResultSet getImportedKeys(final String catalog, final String schema, final String table) throws SQLException {
    257        return getRS(() -> databaseMetaData.getImportedKeys(catalog, schema, table));
    258    }
    259
    260    @Override
    261    public ResultSet getIndexInfo(final String catalog, final String schema, final String table, final boolean unique, final boolean approximate)
    262            throws SQLException {
    263        return getRS(() -> databaseMetaData.getIndexInfo(catalog, schema, table, unique, approximate));
    264    }
    265
    266    /**
    267     * If my underlying {@link ResultSet} is not a {@code DelegatingResultSet}, returns it, otherwise recursively invokes this method on my delegate.
    268     * <p>
    269     * Hence this method will return the first delegate that is not a {@code DelegatingResultSet}, or {@code null} when no non-{@code DelegatingResultSet}
    270     * delegate can be found by traversing this chain.
    271     * </p>
    272     * <p>
    273     * This method is useful when you may have nested {@code DelegatingResultSet}s, and you want to make sure to obtain a "genuine" {@link ResultSet}.
    274     * </p>
    275     *
    276     * @return the innermost database meta data.
    277     */
    278    public DatabaseMetaData getInnermostDelegate() {
    279        DatabaseMetaData m = databaseMetaData;
    280        while (m instanceof DelegatingDatabaseMetaData) {
    281            m = ((DelegatingDatabaseMetaData) m).getDelegate();
    282            if (this == m) {
    283                return null;
    284            }
    285        }
    286        return m;
    287    }
    288
    289    @Override
    290    public int getJDBCMajorVersion() throws SQLException {
    291        return getI(databaseMetaData::getJDBCMajorVersion);
    292    }
    293
    294    @Override
    295    public int getJDBCMinorVersion() throws SQLException {
    296        return getI(databaseMetaData::getJDBCMinorVersion);
    297    }
    298
    299    private long getL(final Callable<Long> s) throws SQLException {
    300        return get(s, 0L);
    301    }
    302
    303    @Override
    304    public int getMaxBinaryLiteralLength() throws SQLException {
    305        return getI(databaseMetaData::getMaxBinaryLiteralLength);
    306    }
    307
    308    @Override
    309    public int getMaxCatalogNameLength() throws SQLException {
    310        return getI(databaseMetaData::getMaxCatalogNameLength);
    311    }
    312
    313    @Override
    314    public int getMaxCharLiteralLength() throws SQLException {
    315        return getI(databaseMetaData::getMaxCharLiteralLength);
    316    }
    317
    318    @Override
    319    public int getMaxColumnNameLength() throws SQLException {
    320        return getI(databaseMetaData::getMaxColumnNameLength);
    321    }
    322
    323    @Override
    324    public int getMaxColumnsInGroupBy() throws SQLException {
    325        return getI(databaseMetaData::getMaxColumnsInGroupBy);
    326    }
    327
    328    @Override
    329    public int getMaxColumnsInIndex() throws SQLException {
    330        return getI(databaseMetaData::getMaxColumnsInIndex);
    331    }
    332
    333    @Override
    334    public int getMaxColumnsInOrderBy() throws SQLException {
    335        return getI(databaseMetaData::getMaxColumnsInOrderBy);
    336    }
    337
    338    @Override
    339    public int getMaxColumnsInSelect() throws SQLException {
    340        return getI(databaseMetaData::getMaxColumnsInSelect);
    341    }
    342
    343    @Override
    344    public int getMaxColumnsInTable() throws SQLException {
    345        return getI(databaseMetaData::getMaxColumnsInTable);
    346    }
    347
    348    @Override
    349    public int getMaxConnections() throws SQLException {
    350        return getI(databaseMetaData::getMaxConnections);
    351    }
    352
    353    @Override
    354    public int getMaxCursorNameLength() throws SQLException {
    355        return getI(databaseMetaData::getMaxCursorNameLength);
    356    }
    357
    358    @Override
    359    public int getMaxIndexLength() throws SQLException {
    360        return getI(databaseMetaData::getMaxIndexLength);
    361    }
    362
    363    /**
    364     * @since 2.5.0
    365     */
    366    @Override
    367    public long getMaxLogicalLobSize() throws SQLException {
    368        return getL(databaseMetaData::getMaxLogicalLobSize);
    369    }
    370
    371    @Override
    372    public int getMaxProcedureNameLength() throws SQLException {
    373        return getI(databaseMetaData::getMaxProcedureNameLength);
    374    }
    375
    376    @Override
    377    public int getMaxRowSize() throws SQLException {
    378        return getI(databaseMetaData::getMaxRowSize);
    379    }
    380
    381    @Override
    382    public int getMaxSchemaNameLength() throws SQLException {
    383        return getI(databaseMetaData::getMaxSchemaNameLength);
    384    }
    385
    386    @Override
    387    public int getMaxStatementLength() throws SQLException {
    388        return getI(databaseMetaData::getMaxStatementLength);
    389    }
    390
    391    @Override
    392    public int getMaxStatements() throws SQLException {
    393        return getI(databaseMetaData::getMaxStatements);
    394    }
    395
    396    @Override
    397    public int getMaxTableNameLength() throws SQLException {
    398        return getI(databaseMetaData::getMaxTableNameLength);
    399    }
    400
    401    @Override
    402    public int getMaxTablesInSelect() throws SQLException {
    403        return getI(databaseMetaData::getMaxTablesInSelect);
    404    }
    405
    406    @Override
    407    public int getMaxUserNameLength() throws SQLException {
    408        return getI(databaseMetaData::getMaxUserNameLength);
    409    }
    410
    411    @Override
    412    public String getNumericFunctions() throws SQLException {
    413        return get(databaseMetaData::getNumericFunctions);
    414    }
    415
    416    @Override
    417    public ResultSet getPrimaryKeys(final String catalog, final String schema, final String table) throws SQLException {
    418        return getRS(() -> databaseMetaData.getPrimaryKeys(catalog, schema, table));
    419    }
    420
    421    @Override
    422    public ResultSet getProcedureColumns(final String catalog, final String schemaPattern, final String procedureNamePattern, final String columnNamePattern)
    423            throws SQLException {
    424        return getRS(() -> databaseMetaData.getProcedureColumns(catalog, schemaPattern, procedureNamePattern, columnNamePattern));
    425    }
    426
    427    @Override
    428    public ResultSet getProcedures(final String catalog, final String schemaPattern, final String procedureNamePattern) throws SQLException {
    429        return getRS(() -> databaseMetaData.getProcedures(catalog, schemaPattern, procedureNamePattern));
    430    }
    431
    432    @Override
    433    public String getProcedureTerm() throws SQLException {
    434        return get(databaseMetaData::getProcedureTerm);
    435    }
    436
    437    @Override
    438    public ResultSet getPseudoColumns(final String catalog, final String schemaPattern, final String tableNamePattern, final String columnNamePattern)
    439            throws SQLException {
    440        return getRS(() -> Jdbc41Bridge.getPseudoColumns(databaseMetaData, catalog, schemaPattern, tableNamePattern, columnNamePattern));
    441    }
    442
    443    @Override
    444    public int getResultSetHoldability() throws SQLException {
    445        return getI(databaseMetaData::getResultSetHoldability);
    446    }
    447
    448    @Override
    449    public RowIdLifetime getRowIdLifetime() throws SQLException {
    450        return get(databaseMetaData::getRowIdLifetime);
    451    }
    452
    453    @SuppressWarnings("resource")
    454    private ResultSet getRS(final Callable<ResultSet> s) throws SQLException {
    455        connection.checkOpen();
    456        return DelegatingResultSet.wrapResultSet(connection, get(s));
    457    }
    458
    459    @Override
    460    public ResultSet getSchemas() throws SQLException {
    461        return getRS(databaseMetaData::getSchemas);
    462    }
    463
    464    @Override
    465    public ResultSet getSchemas(final String catalog, final String schemaPattern) throws SQLException {
    466        return getRS(() -> databaseMetaData.getSchemas(catalog, schemaPattern));
    467    }
    468
    469    @Override
    470    public String getSchemaTerm() throws SQLException {
    471        return get(databaseMetaData::getSchemaTerm);
    472    }
    473
    474    @Override
    475    public String getSearchStringEscape() throws SQLException {
    476        return get(databaseMetaData::getSearchStringEscape);
    477    }
    478
    479    @Override
    480    public String getSQLKeywords() throws SQLException {
    481        return get(databaseMetaData::getSQLKeywords);
    482    }
    483
    484    @Override
    485    public int getSQLStateType() throws SQLException {
    486        return getI(databaseMetaData::getSQLStateType);
    487    }
    488
    489    @Override
    490    public String getStringFunctions() throws SQLException {
    491        return get(databaseMetaData::getStringFunctions);
    492    }
    493
    494    @Override
    495    public ResultSet getSuperTables(final String catalog, final String schemaPattern, final String tableNamePattern) throws SQLException {
    496        return getRS(() -> databaseMetaData.getSuperTables(catalog, schemaPattern, tableNamePattern));
    497    }
    498
    499    @Override
    500    public ResultSet getSuperTypes(final String catalog, final String schemaPattern, final String typeNamePattern) throws SQLException {
    501        return getRS(() -> databaseMetaData.getSuperTypes(catalog, schemaPattern, typeNamePattern));
    502    }
    503
    504    @Override
    505    public String getSystemFunctions() throws SQLException {
    506        return get(databaseMetaData::getSystemFunctions);
    507    }
    508
    509    @Override
    510    public ResultSet getTablePrivileges(final String catalog, final String schemaPattern, final String tableNamePattern) throws SQLException {
    511        return getRS(() -> databaseMetaData.getTablePrivileges(catalog, schemaPattern, tableNamePattern));
    512    }
    513
    514    @Override
    515    public ResultSet getTables(final String catalog, final String schemaPattern, final String tableNamePattern, final String[] types) throws SQLException {
    516        return getRS(() -> databaseMetaData.getTables(catalog, schemaPattern, tableNamePattern, types));
    517    }
    518
    519    @Override
    520    public ResultSet getTableTypes() throws SQLException {
    521        return getRS(databaseMetaData::getTableTypes);
    522    }
    523
    524    @Override
    525    public String getTimeDateFunctions() throws SQLException {
    526        return get(databaseMetaData::getTimeDateFunctions);
    527    }
    528
    529    @Override
    530    public ResultSet getTypeInfo() throws SQLException {
    531        return getRS(databaseMetaData::getTypeInfo);
    532    }
    533
    534    @Override
    535    public ResultSet getUDTs(final String catalog, final String schemaPattern, final String typeNamePattern, final int[] types) throws SQLException {
    536        return getRS(() -> databaseMetaData.getUDTs(catalog, schemaPattern, typeNamePattern, types));
    537    }
    538
    539    @Override
    540    public String getURL() throws SQLException {
    541        return get(databaseMetaData::getURL);
    542    }
    543
    544    @Override
    545    public String getUserName() throws SQLException {
    546        return get(databaseMetaData::getUserName);
    547    }
    548
    549    @Override
    550    public ResultSet getVersionColumns(final String catalog, final String schema, final String table) throws SQLException {
    551        return getRS(() -> databaseMetaData.getVersionColumns(catalog, schema, table));
    552    }
    553
    554    /**
    555     * Delegates to the connection's {@link DelegatingConnection#handleException(SQLException)}.
    556     *
    557     * @param e the exception to throw or delegate.
    558     * @throws SQLException the exception to throw.
    559     */
    560    protected void handleException(final SQLException e) throws SQLException {
    561        if (connection == null) {
    562            throw e;
    563        }
    564        connection.handleException(e);
    565    }
    566
    567    @Override
    568    public boolean insertsAreDetected(final int type) throws SQLException {
    569        return getB(() -> databaseMetaData.insertsAreDetected(type));
    570    }
    571
    572    @Override
    573    public boolean isCatalogAtStart() throws SQLException {
    574        return getB(databaseMetaData::isCatalogAtStart);
    575    }
    576
    577    @Override
    578    public boolean isReadOnly() throws SQLException {
    579        return getB(databaseMetaData::isReadOnly);
    580    }
    581
    582    @Override
    583    public boolean isWrapperFor(final Class<?> iface) throws SQLException {
    584        if (iface.isAssignableFrom(getClass())) {
    585            return true;
    586        }
    587        if (iface.isAssignableFrom(databaseMetaData.getClass())) {
    588            return true;
    589        }
    590        return databaseMetaData.isWrapperFor(iface);
    591    }
    592
    593    @Override
    594    public boolean locatorsUpdateCopy() throws SQLException {
    595        return getB(databaseMetaData::locatorsUpdateCopy);
    596    }
    597
    598    @Override
    599    public boolean nullPlusNonNullIsNull() throws SQLException {
    600        return getB(databaseMetaData::nullPlusNonNullIsNull);
    601    }
    602
    603    @Override
    604    public boolean nullsAreSortedAtEnd() throws SQLException {
    605        return getB(databaseMetaData::nullsAreSortedAtEnd);
    606    }
    607
    608    @Override
    609    public boolean nullsAreSortedAtStart() throws SQLException {
    610        return getB(databaseMetaData::nullsAreSortedAtStart);
    611    }
    612
    613    @Override
    614    public boolean nullsAreSortedHigh() throws SQLException {
    615        return getB(databaseMetaData::nullsAreSortedHigh);
    616    }
    617
    618    @Override
    619    public boolean nullsAreSortedLow() throws SQLException {
    620        return getB(databaseMetaData::nullsAreSortedLow);
    621    }
    622
    623    @Override
    624    public boolean othersDeletesAreVisible(final int type) throws SQLException {
    625        return getB(() -> databaseMetaData.othersDeletesAreVisible(type));
    626    }
    627
    628    @Override
    629    public boolean othersInsertsAreVisible(final int type) throws SQLException {
    630        return getB(() -> databaseMetaData.othersInsertsAreVisible(type));
    631    }
    632
    633    @Override
    634    public boolean othersUpdatesAreVisible(final int type) throws SQLException {
    635        return getB(() -> databaseMetaData.othersUpdatesAreVisible(type));
    636    }
    637
    638    @Override
    639    public boolean ownDeletesAreVisible(final int type) throws SQLException {
    640        return getB(() -> databaseMetaData.ownDeletesAreVisible(type));
    641    }
    642
    643    @Override
    644    public boolean ownInsertsAreVisible(final int type) throws SQLException {
    645        return getB(() -> databaseMetaData.ownInsertsAreVisible(type));
    646    }
    647
    648    @Override
    649    public boolean ownUpdatesAreVisible(final int type) throws SQLException {
    650        return getB(() -> databaseMetaData.ownUpdatesAreVisible(type));
    651    }
    652
    653    @Override
    654    public boolean storesLowerCaseIdentifiers() throws SQLException {
    655        return getB(databaseMetaData::storesLowerCaseIdentifiers);
    656    }
    657
    658    @Override
    659    public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
    660        return getB(databaseMetaData::storesLowerCaseQuotedIdentifiers);
    661    }
    662
    663    @Override
    664    public boolean storesMixedCaseIdentifiers() throws SQLException {
    665        return getB(databaseMetaData::storesMixedCaseIdentifiers);
    666    }
    667
    668    @Override
    669    public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
    670        return getB(databaseMetaData::storesMixedCaseQuotedIdentifiers);
    671    }
    672
    673    @Override
    674    public boolean storesUpperCaseIdentifiers() throws SQLException {
    675        return getB(databaseMetaData::storesUpperCaseIdentifiers);
    676
    677    }
    678
    679    @Override
    680    public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
    681        return getB(databaseMetaData::storesUpperCaseQuotedIdentifiers);
    682    }
    683
    684    @Override
    685    public boolean supportsAlterTableWithAddColumn() throws SQLException {
    686        return getB(databaseMetaData::supportsAlterTableWithAddColumn);
    687    }
    688
    689    @Override
    690    public boolean supportsAlterTableWithDropColumn() throws SQLException {
    691        return getB(databaseMetaData::supportsAlterTableWithDropColumn);
    692    }
    693
    694    @Override
    695    public boolean supportsANSI92EntryLevelSQL() throws SQLException {
    696        return getB(databaseMetaData::supportsANSI92EntryLevelSQL);
    697    }
    698
    699    @Override
    700    public boolean supportsANSI92FullSQL() throws SQLException {
    701        return getB(databaseMetaData::supportsANSI92FullSQL);
    702    }
    703
    704    @Override
    705    public boolean supportsANSI92IntermediateSQL() throws SQLException {
    706        return getB(databaseMetaData::supportsANSI92IntermediateSQL);
    707    }
    708
    709    @Override
    710    public boolean supportsBatchUpdates() throws SQLException {
    711        return getB(databaseMetaData::supportsBatchUpdates);
    712    }
    713
    714    @Override
    715    public boolean supportsCatalogsInDataManipulation() throws SQLException {
    716        return getB(databaseMetaData::supportsCatalogsInDataManipulation);
    717    }
    718
    719    @Override
    720    public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
    721        return getB(databaseMetaData::supportsCatalogsInIndexDefinitions);
    722    }
    723
    724    @Override
    725    public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
    726        return getB(databaseMetaData::supportsCatalogsInPrivilegeDefinitions);
    727    }
    728
    729    @Override
    730    public boolean supportsCatalogsInProcedureCalls() throws SQLException {
    731        return getB(databaseMetaData::supportsCatalogsInProcedureCalls);
    732    }
    733
    734    @Override
    735    public boolean supportsCatalogsInTableDefinitions() throws SQLException {
    736        return getB(databaseMetaData::supportsCatalogsInTableDefinitions);
    737    }
    738
    739    @Override
    740    public boolean supportsColumnAliasing() throws SQLException {
    741        return getB(databaseMetaData::supportsColumnAliasing);
    742    }
    743
    744    @Override
    745    public boolean supportsConvert() throws SQLException {
    746        return getB(databaseMetaData::supportsConvert);
    747    }
    748
    749    @Override
    750    public boolean supportsConvert(final int fromType, final int toType) throws SQLException {
    751        return getB(() -> databaseMetaData.supportsConvert(fromType, toType));
    752    }
    753
    754    @Override
    755    public boolean supportsCoreSQLGrammar() throws SQLException {
    756        return getB(databaseMetaData::supportsCoreSQLGrammar);
    757    }
    758
    759    @Override
    760    public boolean supportsCorrelatedSubqueries() throws SQLException {
    761        return getB(databaseMetaData::supportsCorrelatedSubqueries);
    762    }
    763
    764    @Override
    765    public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException {
    766        return getB(databaseMetaData::supportsDataDefinitionAndDataManipulationTransactions);
    767    }
    768
    769    @Override
    770    public boolean supportsDataManipulationTransactionsOnly() throws SQLException {
    771        return getB(databaseMetaData::supportsDataManipulationTransactionsOnly);
    772    }
    773
    774    @Override
    775    public boolean supportsDifferentTableCorrelationNames() throws SQLException {
    776        return getB(databaseMetaData::supportsDifferentTableCorrelationNames);
    777    }
    778
    779    @Override
    780    public boolean supportsExpressionsInOrderBy() throws SQLException {
    781        return getB(databaseMetaData::supportsExpressionsInOrderBy);
    782    }
    783
    784    @Override
    785    public boolean supportsExtendedSQLGrammar() throws SQLException {
    786        return getB(databaseMetaData::supportsExtendedSQLGrammar);
    787    }
    788
    789    @Override
    790    public boolean supportsFullOuterJoins() throws SQLException {
    791        return getB(databaseMetaData::supportsFullOuterJoins);
    792    }
    793
    794    @Override
    795    public boolean supportsGetGeneratedKeys() throws SQLException {
    796        return getB(databaseMetaData::supportsGetGeneratedKeys);
    797    }
    798
    799    @Override
    800    public boolean supportsGroupBy() throws SQLException {
    801        return getB(databaseMetaData::supportsGroupBy);
    802    }
    803
    804    @Override
    805    public boolean supportsGroupByBeyondSelect() throws SQLException {
    806        return getB(databaseMetaData::supportsGroupByBeyondSelect);
    807    }
    808
    809    @Override
    810    public boolean supportsGroupByUnrelated() throws SQLException {
    811        return getB(databaseMetaData::supportsGroupByUnrelated);
    812    }
    813
    814    @Override
    815    public boolean supportsIntegrityEnhancementFacility() throws SQLException {
    816        return getB(databaseMetaData::supportsIntegrityEnhancementFacility);
    817    }
    818
    819    @Override
    820    public boolean supportsLikeEscapeClause() throws SQLException {
    821        return getB(databaseMetaData::supportsLikeEscapeClause);
    822    }
    823
    824    @Override
    825    public boolean supportsLimitedOuterJoins() throws SQLException {
    826        return getB(databaseMetaData::supportsLimitedOuterJoins);
    827    }
    828
    829    @Override
    830    public boolean supportsMinimumSQLGrammar() throws SQLException {
    831        return getB(databaseMetaData::supportsMinimumSQLGrammar);
    832    }
    833
    834    @Override
    835    public boolean supportsMixedCaseIdentifiers() throws SQLException {
    836        return getB(databaseMetaData::supportsMixedCaseIdentifiers);
    837    }
    838
    839    @Override
    840    public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
    841        return getB(databaseMetaData::supportsMixedCaseQuotedIdentifiers);
    842    }
    843
    844    @Override
    845    public boolean supportsMultipleOpenResults() throws SQLException {
    846        return getB(databaseMetaData::supportsMultipleOpenResults);
    847    }
    848
    849    @Override
    850    public boolean supportsMultipleResultSets() throws SQLException {
    851        return getB(databaseMetaData::supportsMultipleResultSets);
    852    }
    853
    854    @Override
    855    public boolean supportsMultipleTransactions() throws SQLException {
    856        return getB(databaseMetaData::supportsMultipleTransactions);
    857    }
    858
    859    @Override
    860    public boolean supportsNamedParameters() throws SQLException {
    861        return getB(databaseMetaData::supportsNamedParameters);
    862    }
    863
    864    @Override
    865    public boolean supportsNonNullableColumns() throws SQLException {
    866        return getB(databaseMetaData::supportsNonNullableColumns);
    867    }
    868
    869    @Override
    870    public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
    871        return getB(databaseMetaData::supportsOpenCursorsAcrossCommit);
    872    }
    873
    874    @Override
    875    public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
    876        return getB(databaseMetaData::supportsOpenCursorsAcrossRollback);
    877    }
    878
    879    @Override
    880    public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
    881        return getB(databaseMetaData::supportsOpenStatementsAcrossCommit);
    882    }
    883
    884    @Override
    885    public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
    886        return getB(databaseMetaData::supportsOpenStatementsAcrossRollback);
    887    }
    888
    889    @Override
    890    public boolean supportsOrderByUnrelated() throws SQLException {
    891        return getB(databaseMetaData::supportsOrderByUnrelated);
    892    }
    893
    894    @Override
    895    public boolean supportsOuterJoins() throws SQLException {
    896        return getB(databaseMetaData::supportsOuterJoins);
    897    }
    898
    899    @Override
    900    public boolean supportsPositionedDelete() throws SQLException {
    901        return getB(databaseMetaData::supportsPositionedDelete);
    902    }
    903
    904    @Override
    905    public boolean supportsPositionedUpdate() throws SQLException {
    906        return getB(databaseMetaData::supportsPositionedUpdate);
    907    }
    908
    909    /**
    910     * @since 2.5.0
    911     */
    912    @Override
    913    public boolean supportsRefCursors() throws SQLException {
    914        return getB(databaseMetaData::supportsRefCursors);
    915    }
    916
    917    @Override
    918    public boolean supportsResultSetConcurrency(final int type, final int concurrency) throws SQLException {
    919        return getB(() -> databaseMetaData.supportsResultSetConcurrency(type, concurrency));
    920    }
    921
    922    @Override
    923    public boolean supportsResultSetHoldability(final int holdability) throws SQLException {
    924        return getB(() -> databaseMetaData.supportsResultSetHoldability(holdability));
    925    }
    926
    927    @Override
    928    public boolean supportsResultSetType(final int type) throws SQLException {
    929        return getB(() -> databaseMetaData.supportsResultSetType(type));
    930    }
    931
    932    @Override
    933    public boolean supportsSavepoints() throws SQLException {
    934        return getB(databaseMetaData::supportsSavepoints);
    935    }
    936
    937    @Override
    938    public boolean supportsSchemasInDataManipulation() throws SQLException {
    939        return getB(databaseMetaData::supportsSchemasInDataManipulation);
    940    }
    941
    942    @Override
    943    public boolean supportsSchemasInIndexDefinitions() throws SQLException {
    944        return getB(databaseMetaData::supportsSchemasInIndexDefinitions);
    945    }
    946
    947    @Override
    948    public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
    949        return getB(databaseMetaData::supportsSchemasInPrivilegeDefinitions);
    950    }
    951
    952    @Override
    953    public boolean supportsSchemasInProcedureCalls() throws SQLException {
    954        return getB(databaseMetaData::supportsSchemasInProcedureCalls);
    955    }
    956
    957    @Override
    958    public boolean supportsSchemasInTableDefinitions() throws SQLException {
    959        return getB(databaseMetaData::supportsSchemasInTableDefinitions);
    960    }
    961
    962    @Override
    963    public boolean supportsSelectForUpdate() throws SQLException {
    964        return getB(databaseMetaData::supportsSelectForUpdate);
    965    }
    966
    967    @Override
    968    public boolean supportsStatementPooling() throws SQLException {
    969        return getB(databaseMetaData::supportsStatementPooling);
    970    }
    971
    972    @Override
    973    public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
    974        return getB(databaseMetaData::supportsStoredFunctionsUsingCallSyntax);
    975    }
    976
    977    @Override
    978    public boolean supportsStoredProcedures() throws SQLException {
    979        return getB(databaseMetaData::supportsStoredProcedures);
    980    }
    981
    982    @Override
    983    public boolean supportsSubqueriesInComparisons() throws SQLException {
    984        return getB(databaseMetaData::supportsSubqueriesInComparisons);
    985    }
    986
    987    @Override
    988    public boolean supportsSubqueriesInExists() throws SQLException {
    989        return getB(databaseMetaData::supportsSubqueriesInExists);
    990    }
    991
    992    @Override
    993    public boolean supportsSubqueriesInIns() throws SQLException {
    994        return getB(databaseMetaData::supportsSubqueriesInIns);
    995    }
    996
    997    @Override
    998    public boolean supportsSubqueriesInQuantifieds() throws SQLException {
    999        return getB(databaseMetaData::supportsSubqueriesInQuantifieds);
    1000    }
    1001
    1002    @Override
    1003    public boolean supportsTableCorrelationNames() throws SQLException {
    1004        return getB(databaseMetaData::supportsTableCorrelationNames);
    1005    }
    1006
    1007    @Override
    1008    public boolean supportsTransactionIsolationLevel(final int level) throws SQLException {
    1009        return getB(() -> databaseMetaData.supportsTransactionIsolationLevel(level));
    1010    }
    1011
    1012    @Override
    1013    public boolean supportsTransactions() throws SQLException {
    1014        return getB(databaseMetaData::supportsTransactions);
    1015    }
    1016
    1017    @Override
    1018    public boolean supportsUnion() throws SQLException {
    1019        return getB(databaseMetaData::supportsUnion);
    1020    }
    1021
    1022    @Override
    1023    public boolean supportsUnionAll() throws SQLException {
    1024        return getB(databaseMetaData::supportsUnionAll);
    1025    }
    1026
    1027    @Override
    1028    public <T> T unwrap(final Class<T> iface) throws SQLException {
    1029        if (iface.isAssignableFrom(getClass())) {
    1030            return iface.cast(this);
    1031        }
    1032        if (iface.isAssignableFrom(databaseMetaData.getClass())) {
    1033            return iface.cast(databaseMetaData);
    1034        }
    1035        return databaseMetaData.unwrap(iface);
    1036    }
    1037
    1038    @Override
    1039    public boolean updatesAreDetected(final int type) throws SQLException {
    1040        return getB(() -> databaseMetaData.updatesAreDetected(type));
    1041    }
    1042
    1043    @Override
    1044    public boolean usesLocalFilePerTable() throws SQLException {
    1045        return getB(databaseMetaData::usesLocalFilePerTable);
    1046    }
    1047
    1048    @Override
    1049    public boolean usesLocalFiles() throws SQLException {
    1050        return getB(databaseMetaData::usesLocalFiles);
    1051    }
    1052}