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;
024
025/**
026 * <p>A base delegating implementation of {@link DatabaseMetaData}.</p>
027 *
028 * <p>Methods that create {@link ResultSet} objects are wrapped to
029 * create {@link DelegatingResultSet} objects and the remaining methods
030 * simply call the corresponding method on the "delegate"
031 * provided in the constructor.</p>
032 * @since 2.0
033 */
034public class DelegatingDatabaseMetaData implements DatabaseMetaData {
035
036    /** My delegate {@link DatabaseMetaData} */
037    private final DatabaseMetaData _meta;
038
039    /** The connection that created me. **/
040    private final DelegatingConnection<?> _conn;
041
042    public DelegatingDatabaseMetaData(final DelegatingConnection<?> c,
043            final DatabaseMetaData m) {
044        super();
045        _conn = c;
046        _meta = m;
047    }
048
049    public DatabaseMetaData getDelegate() {
050        return _meta;
051    }
052
053    /**
054     * If my underlying {@link ResultSet} is not a
055     * {@code DelegatingResultSet}, returns it,
056     * otherwise recursively invokes this method on
057     * my delegate.
058     * <p>
059     * Hence this method will return the first
060     * delegate that is not a {@code DelegatingResultSet},
061     * or {@code null} when no non-{@code DelegatingResultSet}
062     * delegate can be found by traversing this chain.
063     * <p>
064     * This method is useful when you may have nested
065     * {@code DelegatingResultSet}s, and you want to make
066     * sure to obtain a "genuine" {@link ResultSet}.
067     */
068    public DatabaseMetaData getInnermostDelegate() {
069        DatabaseMetaData m = _meta;
070        while(m != null && m instanceof DelegatingDatabaseMetaData) {
071            m = ((DelegatingDatabaseMetaData)m).getDelegate();
072            if(this == m) {
073                return null;
074            }
075        }
076        return m;
077    }
078
079    protected void handleException(final SQLException e) throws SQLException {
080        if (_conn != null) {
081            _conn.handleException(e);
082        }
083        else {
084            throw e;
085        }
086    }
087
088    @Override
089    public boolean allProceduresAreCallable() throws SQLException {
090        try { return _meta.allProceduresAreCallable(); }
091          catch (final SQLException e) { handleException(e); return false; }
092    }
093
094    @Override
095    public boolean allTablesAreSelectable() throws SQLException {
096        try { return _meta.allTablesAreSelectable(); }
097        catch (final SQLException e) { handleException(e); return false; }
098    }
099
100    @Override
101    public boolean dataDefinitionCausesTransactionCommit() throws SQLException {
102        try { return _meta.dataDefinitionCausesTransactionCommit(); }
103        catch (final SQLException e) { handleException(e); return false; }
104    }
105
106    @Override
107    public boolean dataDefinitionIgnoredInTransactions() throws SQLException {
108        try { return _meta.dataDefinitionIgnoredInTransactions(); }
109        catch (final SQLException e) { handleException(e); return false; }
110    }
111
112    @Override
113    public boolean deletesAreDetected(final int type) throws SQLException {
114        try { return _meta.deletesAreDetected(type); }
115        catch (final SQLException e) { handleException(e); return false; }
116    }
117
118    @Override
119    public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {
120        try { return _meta.doesMaxRowSizeIncludeBlobs(); }
121        catch (final SQLException e) { handleException(e); return false; }
122    }
123
124    @Override
125    public ResultSet getAttributes(final String catalog, final String schemaPattern,
126            final String typeNamePattern, final String attributeNamePattern)
127            throws SQLException {
128        _conn.checkOpen();
129        try {
130            return DelegatingResultSet.wrapResultSet(_conn,_meta.getAttributes(
131                    catalog, schemaPattern, typeNamePattern,
132                    attributeNamePattern));
133        }
134        catch (final SQLException e) {
135            handleException(e);
136            throw new AssertionError();
137        }
138    }
139
140    @Override
141    public ResultSet getBestRowIdentifier(final String catalog, final String schema,
142            final String table, final int scope, final boolean nullable) throws SQLException {
143        _conn.checkOpen();
144        try {
145            return DelegatingResultSet.wrapResultSet(_conn,
146                    _meta.getBestRowIdentifier(catalog, schema, table, scope,
147                            nullable));
148        }
149        catch (final SQLException e) {
150            handleException(e);
151            throw new AssertionError();
152        }
153    }
154
155    @Override
156    public String getCatalogSeparator() throws SQLException {
157        try { return _meta.getCatalogSeparator(); }
158        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
159    }
160
161    @Override
162    public String getCatalogTerm() throws SQLException {
163        try { return _meta.getCatalogTerm(); }
164        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
165    }
166
167    @Override
168    public ResultSet getCatalogs() throws SQLException {
169        _conn.checkOpen();
170        try {
171            return DelegatingResultSet.wrapResultSet(_conn,
172                    _meta.getCatalogs());
173        }
174        catch (final SQLException e) {
175            handleException(e);
176            throw new AssertionError();
177        }
178    }
179
180    @Override
181    public ResultSet getColumnPrivileges(final String catalog, final String schema,
182            final String table, final String columnNamePattern) throws SQLException {
183        _conn.checkOpen();
184        try {
185            return DelegatingResultSet.wrapResultSet(_conn,
186                    _meta.getColumnPrivileges(catalog, schema, table,
187                            columnNamePattern));
188        }
189        catch (final SQLException e) {
190            handleException(e);
191            throw new AssertionError();
192        }
193    }
194
195    @Override
196    public ResultSet getColumns(final String catalog, final String schemaPattern,
197            final String tableNamePattern, final String columnNamePattern)
198            throws SQLException {
199        _conn.checkOpen();
200        try {
201            return DelegatingResultSet.wrapResultSet(_conn,
202                    _meta.getColumns(catalog, schemaPattern, tableNamePattern,
203                            columnNamePattern));
204        }
205        catch (final SQLException e) {
206            handleException(e);
207            throw new AssertionError();
208        }
209    }
210
211    @Override
212    public Connection getConnection() throws SQLException {
213        return _conn;
214    }
215
216    @Override
217    public ResultSet getCrossReference(final String parentCatalog,
218            final String parentSchema, final String parentTable, final String foreignCatalog,
219            final String foreignSchema, final String foreignTable) throws SQLException {
220        _conn.checkOpen();
221        try {
222            return DelegatingResultSet.wrapResultSet(_conn,
223                    _meta.getCrossReference(parentCatalog, parentSchema,
224                            parentTable, foreignCatalog, foreignSchema,
225                            foreignTable));
226        }
227        catch (final SQLException e) {
228            handleException(e);
229            throw new AssertionError();
230        }
231    }
232
233    @Override
234    public int getDatabaseMajorVersion() throws SQLException {
235        try { return _meta.getDatabaseMajorVersion(); }
236        catch (final SQLException e) { handleException(e); return 0; }
237    }
238
239    @Override
240    public int getDatabaseMinorVersion() throws SQLException {
241        try { return _meta.getDatabaseMinorVersion(); }
242        catch (final SQLException e) { handleException(e); return 0; }
243    }
244
245    @Override
246    public String getDatabaseProductName() throws SQLException {
247        try { return _meta.getDatabaseProductName(); }
248        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
249    }
250
251    @Override
252    public String getDatabaseProductVersion() throws SQLException {
253        try { return _meta.getDatabaseProductVersion(); }
254        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
255    }
256
257    @Override
258    public int getDefaultTransactionIsolation() throws SQLException {
259        try { return _meta.getDefaultTransactionIsolation(); }
260        catch (final SQLException e) { handleException(e); return 0; }
261    }
262
263    @Override
264    public int getDriverMajorVersion() {return _meta.getDriverMajorVersion();}
265
266    @Override
267    public int getDriverMinorVersion() {return _meta.getDriverMinorVersion();}
268
269    @Override
270    public String getDriverName() throws SQLException {
271        try { return _meta.getDriverName(); }
272        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
273    }
274
275    @Override
276    public String getDriverVersion() throws SQLException {
277        try { return _meta.getDriverVersion(); }
278        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
279    }
280
281    @Override
282    public ResultSet getExportedKeys(final String catalog, final String schema, final String table)
283            throws SQLException {
284        _conn.checkOpen();
285        try {
286            return DelegatingResultSet.wrapResultSet(_conn,
287                    _meta.getExportedKeys(catalog, schema, table));
288        }
289        catch (final SQLException e) {
290            handleException(e);
291            throw new AssertionError();
292        }
293    }
294
295    @Override
296    public String getExtraNameCharacters() throws SQLException {
297        try { return _meta.getExtraNameCharacters(); }
298        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
299    }
300
301    @Override
302    public String getIdentifierQuoteString() throws SQLException {
303        try { return _meta.getIdentifierQuoteString(); }
304        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
305    }
306
307    @Override
308    public ResultSet getImportedKeys(final String catalog, final String schema, final String table)
309            throws SQLException {
310        _conn.checkOpen();
311        try {
312            return DelegatingResultSet.wrapResultSet(_conn,
313                    _meta.getImportedKeys(catalog, schema, table));
314        }
315        catch (final SQLException e) {
316            handleException(e);
317            throw new AssertionError();
318        }
319    }
320
321    @Override
322    public ResultSet getIndexInfo(final String catalog, final String schema, final String table,
323            final boolean unique, final boolean approximate) throws SQLException {
324        _conn.checkOpen();
325        try {
326            return DelegatingResultSet.wrapResultSet(_conn,
327                    _meta.getIndexInfo(catalog, schema, table, unique,
328                            approximate));
329        }
330        catch (final SQLException e) {
331            handleException(e);
332            throw new AssertionError();
333        }
334    }
335
336    @Override
337    public int getJDBCMajorVersion() throws SQLException {
338        try { return _meta.getJDBCMajorVersion(); }
339        catch (final SQLException e) { handleException(e); return 0; }
340    }
341
342    @Override
343    public int getJDBCMinorVersion() throws SQLException {
344        try { return _meta.getJDBCMinorVersion(); }
345        catch (final SQLException e) { handleException(e); return 0; }
346    }
347
348    @Override
349    public int getMaxBinaryLiteralLength() throws SQLException {
350        try { return _meta.getMaxBinaryLiteralLength(); }
351        catch (final SQLException e) { handleException(e); return 0; }
352    }
353
354    @Override
355    public int getMaxCatalogNameLength() throws SQLException {
356        try { return _meta.getMaxCatalogNameLength(); }
357        catch (final SQLException e) { handleException(e); return 0; }
358    }
359
360    @Override
361    public int getMaxCharLiteralLength() throws SQLException {
362        try { return _meta.getMaxCharLiteralLength(); }
363        catch (final SQLException e) { handleException(e); return 0; }
364    }
365
366    @Override
367    public int getMaxColumnNameLength() throws SQLException {
368        try { return _meta.getMaxColumnNameLength(); }
369        catch (final SQLException e) { handleException(e); return 0; }
370    }
371
372    @Override
373    public int getMaxColumnsInGroupBy() throws SQLException {
374        try { return _meta.getMaxColumnsInGroupBy(); }
375        catch (final SQLException e) { handleException(e); return 0; }
376    }
377
378    @Override
379    public int getMaxColumnsInIndex() throws SQLException {
380        try { return _meta.getMaxColumnsInIndex(); }
381        catch (final SQLException e) { handleException(e); return 0; }
382    }
383
384    @Override
385    public int getMaxColumnsInOrderBy() throws SQLException {
386        try { return _meta.getMaxColumnsInOrderBy(); }
387        catch (final SQLException e) { handleException(e); return 0; }
388    }
389
390    @Override
391    public int getMaxColumnsInSelect() throws SQLException {
392        try { return _meta.getMaxColumnsInSelect(); }
393        catch (final SQLException e) { handleException(e); return 0; }
394    }
395
396    @Override
397    public int getMaxColumnsInTable() throws SQLException {
398        try { return _meta.getMaxColumnsInTable(); }
399        catch (final SQLException e) { handleException(e); return 0; }
400    }
401
402    @Override
403    public int getMaxConnections() throws SQLException {
404        try { return _meta.getMaxConnections(); }
405        catch (final SQLException e) { handleException(e); return 0; }
406    }
407
408    @Override
409    public int getMaxCursorNameLength() throws SQLException {
410        try { return _meta.getMaxCursorNameLength(); }
411        catch (final SQLException e) { handleException(e); return 0; }
412    }
413
414    @Override
415    public int getMaxIndexLength() throws SQLException {
416        try { return _meta.getMaxIndexLength(); }
417        catch (final SQLException e) { handleException(e); return 0; }
418    }
419
420    @Override
421    public int getMaxProcedureNameLength() throws SQLException {
422        try { return _meta.getMaxProcedureNameLength(); }
423        catch (final SQLException e) { handleException(e); return 0; }
424    }
425
426    @Override
427    public int getMaxRowSize() throws SQLException {
428        try { return _meta.getMaxRowSize(); }
429        catch (final SQLException e) { handleException(e); return 0; }
430    }
431
432    @Override
433    public int getMaxSchemaNameLength() throws SQLException {
434        try { return _meta.getMaxSchemaNameLength(); }
435        catch (final SQLException e) { handleException(e); return 0; }
436    }
437
438    @Override
439    public int getMaxStatementLength() throws SQLException {
440        try { return _meta.getMaxStatementLength(); }
441        catch (final SQLException e) { handleException(e); return 0; }
442    }
443
444    @Override
445    public int getMaxStatements() throws SQLException {
446        try { return _meta.getMaxStatements(); }
447        catch (final SQLException e) { handleException(e); return 0; }
448    }
449
450    @Override
451    public int getMaxTableNameLength() throws SQLException {
452        try { return _meta.getMaxTableNameLength(); }
453        catch (final SQLException e) { handleException(e); return 0; }
454    }
455
456    @Override
457    public int getMaxTablesInSelect() throws SQLException {
458        try { return _meta.getMaxTablesInSelect(); }
459        catch (final SQLException e) { handleException(e); return 0; }
460    }
461
462    @Override
463    public int getMaxUserNameLength() throws SQLException {
464        try { return _meta.getMaxUserNameLength(); }
465        catch (final SQLException e) { handleException(e); return 0; }
466    }
467
468    @Override
469    public String getNumericFunctions() throws SQLException {
470        try { return _meta.getNumericFunctions(); }
471        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
472    }
473
474    @Override
475    public ResultSet getPrimaryKeys(final String catalog, final String schema, final String table)
476            throws SQLException {
477        _conn.checkOpen();
478        try {
479            return DelegatingResultSet.wrapResultSet(_conn,
480                    _meta.getPrimaryKeys(catalog, schema, table));
481        }
482        catch (final SQLException e) {
483            handleException(e);
484            throw new AssertionError();
485        }
486    }
487
488    @Override
489    public ResultSet getProcedureColumns(final String catalog, final String schemaPattern,
490            final String procedureNamePattern, final String columnNamePattern)
491            throws SQLException {
492        _conn.checkOpen();
493        try {
494            return DelegatingResultSet.wrapResultSet(_conn,
495                    _meta.getProcedureColumns(catalog, schemaPattern,
496                            procedureNamePattern, columnNamePattern));
497        }
498        catch (final SQLException e) {
499            handleException(e);
500            throw new AssertionError();
501        }
502    }
503
504    @Override
505    public String getProcedureTerm() throws SQLException {
506        try { return _meta.getProcedureTerm(); }
507        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
508    }
509
510    @Override
511    public ResultSet getProcedures(final String catalog, final String schemaPattern,
512            final String procedureNamePattern) throws SQLException {
513        _conn.checkOpen();
514        try {
515            return DelegatingResultSet.wrapResultSet(_conn,
516                    _meta.getProcedures(catalog, schemaPattern,
517                            procedureNamePattern));
518        }
519        catch (final SQLException e) {
520            handleException(e);
521            throw new AssertionError();
522        }
523    }
524
525    @Override
526    public int getResultSetHoldability() throws SQLException {
527        try { return _meta.getResultSetHoldability(); }
528        catch (final SQLException e) { handleException(e); return 0; }
529    }
530
531    @Override
532    public String getSQLKeywords() throws SQLException {
533        try { return _meta.getSQLKeywords(); }
534        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
535    }
536
537    @Override
538    public int getSQLStateType() throws SQLException {
539        try { return _meta.getSQLStateType(); }
540        catch (final SQLException e) { handleException(e); return 0; }
541    }
542
543    @Override
544    public String getSchemaTerm() throws SQLException {
545        try { return _meta.getSchemaTerm(); }
546        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
547    }
548
549    @Override
550    public ResultSet getSchemas() throws SQLException {
551        _conn.checkOpen();
552        try {
553            return DelegatingResultSet.wrapResultSet(_conn,
554                    _meta.getSchemas());
555        }
556        catch (final SQLException e) {
557            handleException(e);
558            throw new AssertionError();
559        }
560    }
561
562    @Override
563    public String getSearchStringEscape() throws SQLException {
564        try { return _meta.getSearchStringEscape(); }
565        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
566    }
567
568    @Override
569    public String getStringFunctions() throws SQLException {
570        try { return _meta.getStringFunctions(); }
571        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
572    }
573
574    @Override
575    public ResultSet getSuperTables(final String catalog, final String schemaPattern,
576            final String tableNamePattern) throws SQLException {
577        _conn.checkOpen();
578        try {
579            return DelegatingResultSet.wrapResultSet(_conn,
580                    _meta.getSuperTables(catalog, schemaPattern,
581                            tableNamePattern));
582        }
583        catch (final SQLException e) {
584            handleException(e);
585            throw new AssertionError();
586        }
587    }
588
589    @Override
590    public ResultSet getSuperTypes(final String catalog, final String schemaPattern,
591            final String typeNamePattern) throws SQLException {
592        _conn.checkOpen();
593        try {
594            return DelegatingResultSet.wrapResultSet(_conn,
595                    _meta.getSuperTypes(catalog, schemaPattern,
596                            typeNamePattern));
597        }
598        catch (final SQLException e) {
599            handleException(e);
600            throw new AssertionError();
601        }
602    }
603
604    @Override
605    public String getSystemFunctions() throws SQLException {
606        try { return _meta.getSystemFunctions(); }
607        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
608    }
609
610    @Override
611    public ResultSet getTablePrivileges(final String catalog, final String schemaPattern,
612            final String tableNamePattern) throws SQLException {
613        _conn.checkOpen();
614        try {
615            return DelegatingResultSet.wrapResultSet(_conn,
616                    _meta.getTablePrivileges(catalog, schemaPattern,
617                            tableNamePattern));
618        }
619        catch (final SQLException e) {
620            handleException(e);
621            throw new AssertionError();
622        }
623    }
624
625    @Override
626    public ResultSet getTableTypes() throws SQLException {
627        _conn.checkOpen();
628        try {
629            return DelegatingResultSet.wrapResultSet(_conn,
630                    _meta.getTableTypes());
631        }
632        catch (final SQLException e) {
633            handleException(e);
634            throw new AssertionError();
635        }
636    }
637
638    @Override
639    public ResultSet getTables(final String catalog, final String schemaPattern,
640            final String tableNamePattern, final String[] types) throws SQLException {
641        _conn.checkOpen();
642        try {
643            return DelegatingResultSet.wrapResultSet(_conn,
644                    _meta.getTables(catalog, schemaPattern, tableNamePattern,
645                            types));
646        }
647        catch (final SQLException e) {
648            handleException(e);
649            throw new AssertionError();
650        }
651    }
652
653    @Override
654    public String getTimeDateFunctions() throws SQLException {
655        try { return _meta.getTimeDateFunctions(); }
656        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
657    }
658
659    @Override
660    public ResultSet getTypeInfo() throws SQLException {
661        _conn.checkOpen();
662        try {
663            return DelegatingResultSet.wrapResultSet(_conn,
664                    _meta.getTypeInfo());
665        }
666        catch (final SQLException e) {
667            handleException(e);
668            throw new AssertionError();
669        }
670    }
671
672    @Override
673    public ResultSet getUDTs(final String catalog, final String schemaPattern,
674            final String typeNamePattern, final int[] types) throws SQLException {
675        _conn.checkOpen();
676        try {
677            return DelegatingResultSet.wrapResultSet(_conn,
678                    _meta.getUDTs(catalog, schemaPattern, typeNamePattern,
679                            types));
680        }
681        catch (final SQLException e) {
682            handleException(e);
683            throw new AssertionError();
684        }
685    }
686
687    @Override
688    public String getURL() throws SQLException {
689        try { return _meta.getURL(); }
690        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
691    }
692
693    @Override
694    public String getUserName() throws SQLException {
695        try { return _meta.getUserName(); }
696        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
697    }
698
699    @Override
700    public ResultSet getVersionColumns(final String catalog, final String schema,
701            final String table) throws SQLException {
702        _conn.checkOpen();
703        try {
704            return DelegatingResultSet.wrapResultSet(_conn,
705                    _meta.getVersionColumns(catalog, schema, table));
706        }
707        catch (final SQLException e) {
708            handleException(e);
709            throw new AssertionError();
710        }
711    }
712
713    @Override
714    public boolean insertsAreDetected(final int type) throws SQLException {
715        try { return _meta.insertsAreDetected(type); }
716        catch (final SQLException e) { handleException(e); return false; }
717    }
718
719    @Override
720    public boolean isCatalogAtStart() throws SQLException {
721        try { return _meta.isCatalogAtStart(); }
722        catch (final SQLException e) { handleException(e); return false; }
723    }
724
725    @Override
726    public boolean isReadOnly() throws SQLException {
727        try { return _meta.isReadOnly(); }
728        catch (final SQLException e) { handleException(e); return false; }
729    }
730
731    @Override
732    public boolean locatorsUpdateCopy() throws SQLException {
733        try { return _meta.locatorsUpdateCopy(); }
734        catch (final SQLException e) { handleException(e); return false; }
735    }
736
737    @Override
738    public boolean nullPlusNonNullIsNull() throws SQLException {
739        try { return _meta.nullPlusNonNullIsNull(); }
740        catch (final SQLException e) { handleException(e); return false; }
741    }
742
743    @Override
744    public boolean nullsAreSortedAtEnd() throws SQLException {
745        try { return _meta.nullsAreSortedAtEnd(); }
746        catch (final SQLException e) { handleException(e); return false; }
747    }
748
749    @Override
750    public boolean nullsAreSortedAtStart() throws SQLException {
751        try { return _meta.nullsAreSortedAtStart(); }
752        catch (final SQLException e) { handleException(e); return false; }
753    }
754
755    @Override
756    public boolean nullsAreSortedHigh() throws SQLException {
757        try { return _meta.nullsAreSortedHigh(); }
758        catch (final SQLException e) { handleException(e); return false; }
759    }
760
761    @Override
762    public boolean nullsAreSortedLow() throws SQLException {
763        try { return _meta.nullsAreSortedLow(); }
764        catch (final SQLException e) { handleException(e); return false; }
765    }
766
767    @Override
768    public boolean othersDeletesAreVisible(final int type) throws SQLException {
769        try { return _meta.othersDeletesAreVisible(type); }
770        catch (final SQLException e) { handleException(e); return false; }
771    }
772
773    @Override
774    public boolean othersInsertsAreVisible(final int type) throws SQLException {
775        try { return _meta.othersInsertsAreVisible(type); }
776        catch (final SQLException e) { handleException(e); return false; }
777    }
778
779    @Override
780    public boolean othersUpdatesAreVisible(final int type) throws SQLException {
781        try { return _meta.othersUpdatesAreVisible(type); }
782        catch (final SQLException e) { handleException(e); return false; }
783    }
784
785    @Override
786    public boolean ownDeletesAreVisible(final int type) throws SQLException {
787        try { return _meta.ownDeletesAreVisible(type); }
788        catch (final SQLException e) { handleException(e); return false; }
789    }
790
791    @Override
792    public boolean ownInsertsAreVisible(final int type) throws SQLException {
793        try { return _meta.ownInsertsAreVisible(type); }
794        catch (final SQLException e) { handleException(e); return false; }
795    }
796
797    @Override
798    public boolean ownUpdatesAreVisible(final int type) throws SQLException {
799        try { return _meta.ownUpdatesAreVisible(type); }
800        catch (final SQLException e) { handleException(e); return false; }
801    }
802
803    @Override
804    public boolean storesLowerCaseIdentifiers() throws SQLException {
805        try { return _meta.storesLowerCaseIdentifiers(); }
806        catch (final SQLException e) { handleException(e); return false; }
807    }
808
809    @Override
810    public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
811        try { return _meta.storesLowerCaseQuotedIdentifiers(); }
812        catch (final SQLException e) { handleException(e); return false; }
813    }
814
815    @Override
816    public boolean storesMixedCaseIdentifiers() throws SQLException {
817        try { return _meta.storesMixedCaseIdentifiers(); }
818        catch (final SQLException e) { handleException(e); return false; }
819    }
820
821    @Override
822    public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
823        try { return _meta.storesMixedCaseQuotedIdentifiers(); }
824        catch (final SQLException e) { handleException(e); return false; }
825    }
826
827    @Override
828    public boolean storesUpperCaseIdentifiers() throws SQLException {
829        try { return _meta.storesUpperCaseIdentifiers(); }
830        catch (final SQLException e) { handleException(e); return false; }
831    }
832
833    @Override
834    public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
835        try { return _meta.storesUpperCaseQuotedIdentifiers(); }
836        catch (final SQLException e) { handleException(e); return false; }
837    }
838
839    @Override
840    public boolean supportsANSI92EntryLevelSQL() throws SQLException {
841        try { return _meta.supportsANSI92EntryLevelSQL(); }
842        catch (final SQLException e) { handleException(e); return false; }
843    }
844
845    @Override
846    public boolean supportsANSI92FullSQL() throws SQLException {
847        try { return _meta.supportsANSI92FullSQL(); }
848        catch (final SQLException e) { handleException(e); return false; }
849    }
850
851    @Override
852    public boolean supportsANSI92IntermediateSQL() throws SQLException {
853        try { return _meta.supportsANSI92IntermediateSQL(); }
854        catch (final SQLException e) { handleException(e); return false; }
855    }
856
857    @Override
858    public boolean supportsAlterTableWithAddColumn() throws SQLException {
859        try { return _meta.supportsAlterTableWithAddColumn(); }
860        catch (final SQLException e) { handleException(e); return false; }
861    }
862
863    @Override
864    public boolean supportsAlterTableWithDropColumn() throws SQLException {
865        try { return _meta.supportsAlterTableWithDropColumn(); }
866        catch (final SQLException e) { handleException(e); return false; }
867    }
868
869    @Override
870    public boolean supportsBatchUpdates() throws SQLException {
871        try { return _meta.supportsBatchUpdates(); }
872        catch (final SQLException e) { handleException(e); return false; }
873    }
874
875    @Override
876    public boolean supportsCatalogsInDataManipulation() throws SQLException {
877        try { return _meta.supportsCatalogsInDataManipulation(); }
878        catch (final SQLException e) { handleException(e); return false; }
879    }
880
881    @Override
882    public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
883        try { return _meta.supportsCatalogsInIndexDefinitions(); }
884        catch (final SQLException e) { handleException(e); return false; }
885    }
886
887    @Override
888    public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
889        try { return _meta.supportsCatalogsInPrivilegeDefinitions(); }
890        catch (final SQLException e) { handleException(e); return false; }
891    }
892
893    @Override
894    public boolean supportsCatalogsInProcedureCalls() throws SQLException {
895        try { return _meta.supportsCatalogsInProcedureCalls(); }
896        catch (final SQLException e) { handleException(e); return false; }
897    }
898
899    @Override
900    public boolean supportsCatalogsInTableDefinitions() throws SQLException {
901        try { return _meta.supportsCatalogsInTableDefinitions(); }
902        catch (final SQLException e) { handleException(e); return false; }
903    }
904
905    @Override
906    public boolean supportsColumnAliasing() throws SQLException {
907        try { return _meta.supportsColumnAliasing(); }
908        catch (final SQLException e) { handleException(e); return false; }
909    }
910
911    @Override
912    public boolean supportsConvert() throws SQLException {
913        try { return _meta.supportsConvert(); }
914        catch (final SQLException e) { handleException(e); return false; }
915    }
916
917    @Override
918    public boolean supportsConvert(final int fromType, final int toType)
919            throws SQLException {
920        try { return _meta.supportsConvert(fromType, toType); }
921        catch (final SQLException e) { handleException(e); return false; }
922    }
923
924    @Override
925    public boolean supportsCoreSQLGrammar() throws SQLException {
926        try { return _meta.supportsCoreSQLGrammar(); }
927        catch (final SQLException e) { handleException(e); return false; }
928    }
929
930    @Override
931    public boolean supportsCorrelatedSubqueries() throws SQLException {
932        try { return _meta.supportsCorrelatedSubqueries(); }
933        catch (final SQLException e) { handleException(e); return false; }
934    }
935
936    @Override
937    public boolean supportsDataDefinitionAndDataManipulationTransactions()
938            throws SQLException {
939        try { return _meta.supportsDataDefinitionAndDataManipulationTransactions(); }
940        catch (final SQLException e) { handleException(e); return false; }
941    }
942
943    @Override
944    public boolean supportsDataManipulationTransactionsOnly()
945            throws SQLException {
946        try { return _meta.supportsDataManipulationTransactionsOnly(); }
947        catch (final SQLException e) { handleException(e); return false; }
948    }
949
950    @Override
951    public boolean supportsDifferentTableCorrelationNames() throws SQLException {
952        try { return _meta.supportsDifferentTableCorrelationNames(); }
953        catch (final SQLException e) { handleException(e); return false; }
954    }
955
956    @Override
957    public boolean supportsExpressionsInOrderBy() throws SQLException {
958        try { return _meta.supportsExpressionsInOrderBy(); }
959        catch (final SQLException e) { handleException(e); return false; }
960    }
961
962    @Override
963    public boolean supportsExtendedSQLGrammar() throws SQLException {
964        try { return _meta.supportsExtendedSQLGrammar(); }
965        catch (final SQLException e) { handleException(e); return false; }
966    }
967
968    @Override
969    public boolean supportsFullOuterJoins() throws SQLException {
970        try { return _meta.supportsFullOuterJoins(); }
971        catch (final SQLException e) { handleException(e); return false; }
972    }
973
974    @Override
975    public boolean supportsGetGeneratedKeys() throws SQLException {
976        try { return _meta.supportsGetGeneratedKeys(); }
977        catch (final SQLException e) { handleException(e); return false; }
978    }
979
980    @Override
981    public boolean supportsGroupBy() throws SQLException {
982        try { return _meta.supportsGroupBy(); }
983        catch (final SQLException e) { handleException(e); return false; }
984    }
985
986    @Override
987    public boolean supportsGroupByBeyondSelect() throws SQLException {
988        try { return _meta.supportsGroupByBeyondSelect(); }
989        catch (final SQLException e) { handleException(e); return false; }
990    }
991
992    @Override
993    public boolean supportsGroupByUnrelated() throws SQLException {
994        try { return _meta.supportsGroupByUnrelated(); }
995        catch (final SQLException e) { handleException(e); return false; }
996    }
997
998    @Override
999    public boolean supportsIntegrityEnhancementFacility() throws SQLException {
1000        try { return _meta.supportsIntegrityEnhancementFacility(); }
1001        catch (final SQLException e) { handleException(e); return false; }
1002    }
1003
1004    @Override
1005    public boolean supportsLikeEscapeClause() throws SQLException {
1006        try { return _meta.supportsLikeEscapeClause(); }
1007        catch (final SQLException e) { handleException(e); return false; }
1008    }
1009
1010    @Override
1011    public boolean supportsLimitedOuterJoins() throws SQLException {
1012        try { return _meta.supportsLimitedOuterJoins(); }
1013        catch (final SQLException e) { handleException(e); return false; }
1014    }
1015
1016    @Override
1017    public boolean supportsMinimumSQLGrammar() throws SQLException {
1018        try { return _meta.supportsMinimumSQLGrammar(); }
1019        catch (final SQLException e) { handleException(e); return false; }
1020    }
1021
1022    @Override
1023    public boolean supportsMixedCaseIdentifiers() throws SQLException {
1024        try { return _meta.supportsMixedCaseIdentifiers(); }
1025        catch (final SQLException e) { handleException(e); return false; }
1026    }
1027
1028    @Override
1029    public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
1030        try { return _meta.supportsMixedCaseQuotedIdentifiers(); }
1031        catch (final SQLException e) { handleException(e); return false; }
1032    }
1033
1034    @Override
1035    public boolean supportsMultipleOpenResults() throws SQLException {
1036        try { return _meta.supportsMultipleOpenResults(); }
1037        catch (final SQLException e) { handleException(e); return false; }
1038    }
1039
1040    @Override
1041    public boolean supportsMultipleResultSets() throws SQLException {
1042        try { return _meta.supportsMultipleResultSets(); }
1043        catch (final SQLException e) { handleException(e); return false; }
1044    }
1045
1046    @Override
1047    public boolean supportsMultipleTransactions() throws SQLException {
1048        try { return _meta.supportsMultipleTransactions(); }
1049        catch (final SQLException e) { handleException(e); return false; }
1050    }
1051
1052    @Override
1053    public boolean supportsNamedParameters() throws SQLException {
1054        try { return _meta.supportsNamedParameters(); }
1055        catch (final SQLException e) { handleException(e); return false; }
1056    }
1057
1058    @Override
1059    public boolean supportsNonNullableColumns() throws SQLException {
1060        try { return _meta.supportsNonNullableColumns(); }
1061        catch (final SQLException e) { handleException(e); return false; }
1062    }
1063
1064    @Override
1065    public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
1066        try { return _meta.supportsOpenCursorsAcrossCommit(); }
1067        catch (final SQLException e) { handleException(e); return false; }
1068    }
1069
1070    @Override
1071    public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
1072        try { return _meta.supportsOpenCursorsAcrossRollback(); }
1073        catch (final SQLException e) { handleException(e); return false; }
1074    }
1075
1076    @Override
1077    public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
1078        try { return _meta.supportsOpenStatementsAcrossCommit(); }
1079        catch (final SQLException e) { handleException(e); return false; }
1080    }
1081
1082    @Override
1083    public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
1084        try { return _meta.supportsOpenStatementsAcrossRollback(); }
1085        catch (final SQLException e) { handleException(e); return false; }
1086    }
1087
1088    @Override
1089    public boolean supportsOrderByUnrelated() throws SQLException {
1090        try { return _meta.supportsOrderByUnrelated(); }
1091        catch (final SQLException e) { handleException(e); return false; }
1092    }
1093
1094    @Override
1095    public boolean supportsOuterJoins() throws SQLException {
1096        try { return _meta.supportsOuterJoins(); }
1097        catch (final SQLException e) { handleException(e); return false; }
1098    }
1099
1100    @Override
1101    public boolean supportsPositionedDelete() throws SQLException {
1102        try { return _meta.supportsPositionedDelete(); }
1103        catch (final SQLException e) { handleException(e); return false; }
1104    }
1105
1106    @Override
1107    public boolean supportsPositionedUpdate() throws SQLException {
1108        try { return _meta.supportsPositionedUpdate(); }
1109        catch (final SQLException e) { handleException(e); return false; }
1110    }
1111
1112    @Override
1113    public boolean supportsResultSetConcurrency(final int type, final int concurrency)
1114            throws SQLException {
1115        try { return _meta.supportsResultSetConcurrency(type, concurrency); }
1116        catch (final SQLException e) { handleException(e); return false; }
1117    }
1118
1119    @Override
1120    public boolean supportsResultSetHoldability(final int holdability)
1121            throws SQLException {
1122        try { return _meta.supportsResultSetHoldability(holdability); }
1123        catch (final SQLException e) { handleException(e); return false; }
1124    }
1125
1126    @Override
1127    public boolean supportsResultSetType(final int type) throws SQLException {
1128        try { return _meta.supportsResultSetType(type); }
1129        catch (final SQLException e) { handleException(e); return false; }
1130    }
1131
1132    @Override
1133    public boolean supportsSavepoints() throws SQLException {
1134        try { return _meta.supportsSavepoints(); }
1135        catch (final SQLException e) { handleException(e); return false; }
1136    }
1137
1138    @Override
1139    public boolean supportsSchemasInDataManipulation() throws SQLException {
1140        try { return _meta.supportsSchemasInDataManipulation(); }
1141        catch (final SQLException e) { handleException(e); return false; }
1142    }
1143
1144    @Override
1145    public boolean supportsSchemasInIndexDefinitions() throws SQLException {
1146        try { return _meta.supportsSchemasInIndexDefinitions(); }
1147        catch (final SQLException e) { handleException(e); return false; }
1148    }
1149
1150    @Override
1151    public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
1152        try { return _meta.supportsSchemasInPrivilegeDefinitions(); }
1153        catch (final SQLException e) { handleException(e); return false; }
1154    }
1155
1156    @Override
1157    public boolean supportsSchemasInProcedureCalls() throws SQLException {
1158        try { return _meta.supportsSchemasInProcedureCalls(); }
1159        catch (final SQLException e) { handleException(e); return false; }
1160    }
1161
1162    @Override
1163    public boolean supportsSchemasInTableDefinitions() throws SQLException {
1164        try { return _meta.supportsSchemasInTableDefinitions(); }
1165        catch (final SQLException e) { handleException(e); return false; }
1166    }
1167
1168    @Override
1169    public boolean supportsSelectForUpdate() throws SQLException {
1170        try { return _meta.supportsSelectForUpdate(); }
1171        catch (final SQLException e) { handleException(e); return false; }
1172    }
1173
1174    @Override
1175    public boolean supportsStatementPooling() throws SQLException {
1176        try { return _meta.supportsStatementPooling(); }
1177        catch (final SQLException e) { handleException(e); return false; }
1178    }
1179
1180    @Override
1181    public boolean supportsStoredProcedures() throws SQLException {
1182        try { return _meta.supportsStoredProcedures(); }
1183        catch (final SQLException e) { handleException(e); return false; }
1184    }
1185
1186    @Override
1187    public boolean supportsSubqueriesInComparisons() throws SQLException {
1188        try { return _meta.supportsSubqueriesInComparisons(); }
1189        catch (final SQLException e) { handleException(e); return false; }
1190    }
1191
1192    @Override
1193    public boolean supportsSubqueriesInExists() throws SQLException {
1194        try { return _meta.supportsSubqueriesInExists(); }
1195        catch (final SQLException e) { handleException(e); return false; }
1196    }
1197
1198    @Override
1199    public boolean supportsSubqueriesInIns() throws SQLException {
1200        try { return _meta.supportsSubqueriesInIns(); }
1201        catch (final SQLException e) { handleException(e); return false; }
1202    }
1203
1204    @Override
1205    public boolean supportsSubqueriesInQuantifieds() throws SQLException {
1206        try { return _meta.supportsSubqueriesInQuantifieds(); }
1207        catch (final SQLException e) { handleException(e); return false; }
1208    }
1209
1210    @Override
1211    public boolean supportsTableCorrelationNames() throws SQLException {
1212        try { return _meta.supportsTableCorrelationNames(); }
1213        catch (final SQLException e) { handleException(e); return false; }
1214    }
1215
1216    @Override
1217    public boolean supportsTransactionIsolationLevel(final int level)
1218            throws SQLException {
1219        try { return _meta.supportsTransactionIsolationLevel(level); }
1220        catch (final SQLException e) { handleException(e); return false; }
1221    }
1222
1223    @Override
1224    public boolean supportsTransactions() throws SQLException {
1225        try { return _meta.supportsTransactions(); }
1226        catch (final SQLException e) { handleException(e); return false; }
1227    }
1228
1229    @Override
1230    public boolean supportsUnion() throws SQLException {
1231        try { return _meta.supportsUnion(); }
1232        catch (final SQLException e) { handleException(e); return false; }
1233    }
1234
1235    @Override
1236    public boolean supportsUnionAll() throws SQLException {
1237        try { return _meta.supportsUnionAll(); }
1238        catch (final SQLException e) { handleException(e); return false; }
1239    }
1240
1241    @Override
1242    public boolean updatesAreDetected(final int type) throws SQLException {
1243        try { return _meta.updatesAreDetected(type); }
1244        catch (final SQLException e) { handleException(e); return false; }
1245    }
1246
1247    @Override
1248    public boolean usesLocalFilePerTable() throws SQLException {
1249        try { return _meta.usesLocalFilePerTable(); }
1250        catch (final SQLException e) { handleException(e); return false; }
1251    }
1252
1253    @Override
1254    public boolean usesLocalFiles() throws SQLException {
1255        try { return _meta.usesLocalFiles(); }
1256        catch (final SQLException e) { handleException(e); return false; }
1257    }
1258
1259    /* JDBC_4_ANT_KEY_BEGIN */
1260
1261    @Override
1262    public boolean isWrapperFor(final Class<?> iface) throws SQLException {
1263        if (iface.isAssignableFrom(getClass())) {
1264            return true;
1265        } else if (iface.isAssignableFrom(_meta.getClass())) {
1266            return true;
1267        } else {
1268            return _meta.isWrapperFor(iface);
1269        }
1270    }
1271
1272    @Override
1273    public <T> T unwrap(final Class<T> iface) throws SQLException {
1274        if (iface.isAssignableFrom(getClass())) {
1275            return iface.cast(this);
1276        } else if (iface.isAssignableFrom(_meta.getClass())) {
1277            return iface.cast(_meta);
1278        } else {
1279            return _meta.unwrap(iface);
1280        }
1281    }
1282
1283    @Override
1284    public RowIdLifetime getRowIdLifetime() throws SQLException {
1285        try { return _meta.getRowIdLifetime(); }
1286        catch (final SQLException e) { handleException(e); throw new AssertionError(); }
1287    }
1288
1289    @Override
1290    public ResultSet getSchemas(final String catalog, final String schemaPattern)
1291    throws SQLException {
1292        _conn.checkOpen();
1293        try {
1294            return DelegatingResultSet.wrapResultSet(_conn,
1295                    _meta.getSchemas(catalog, schemaPattern));
1296        }
1297        catch (final SQLException e) {
1298            handleException(e);
1299            throw new AssertionError();
1300        }
1301    }
1302
1303    @Override
1304    public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
1305        try { return _meta.autoCommitFailureClosesAllResultSets(); }
1306        catch (final SQLException e) { handleException(e); return false; }
1307    }
1308
1309    @Override
1310    public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
1311        try { return _meta.supportsStoredFunctionsUsingCallSyntax(); }
1312        catch (final SQLException e) { handleException(e); return false; }
1313    }
1314
1315    @Override
1316    public ResultSet getClientInfoProperties() throws SQLException {
1317        _conn.checkOpen();
1318        try {
1319            return DelegatingResultSet.wrapResultSet(_conn,
1320                    _meta.getClientInfoProperties());
1321        }
1322        catch (final SQLException e) {
1323            handleException(e);
1324            throw new AssertionError();
1325        }
1326    }
1327
1328    @Override
1329    public ResultSet getFunctions(final String catalog, final String schemaPattern,
1330            final String functionNamePattern) throws SQLException {
1331        _conn.checkOpen();
1332        try {
1333            return DelegatingResultSet.wrapResultSet(_conn,
1334                    _meta.getFunctions(catalog, schemaPattern,
1335                            functionNamePattern));
1336        }
1337        catch (final SQLException e) {
1338            handleException(e);
1339            throw new AssertionError();
1340        }
1341    }
1342
1343    @Override
1344    public ResultSet getFunctionColumns(final String catalog, final String schemaPattern,
1345            final String functionNamePattern, final String columnNamePattern)
1346            throws SQLException {
1347        _conn.checkOpen();
1348        try {
1349            return DelegatingResultSet.wrapResultSet(_conn,
1350                    _meta.getFunctionColumns(catalog, schemaPattern,
1351                            functionNamePattern, columnNamePattern));
1352        }
1353        catch (final SQLException e) {
1354            handleException(e);
1355            throw new AssertionError();
1356        }
1357    }
1358
1359    /* JDBC_4_ANT_KEY_END */
1360
1361    @Override
1362    public ResultSet getPseudoColumns(final String catalog, final String schemaPattern,
1363            final String tableNamePattern, final String columnNamePattern)
1364            throws SQLException {
1365        _conn.checkOpen();
1366        try {
1367            return DelegatingResultSet.wrapResultSet(_conn,
1368                    _meta.getPseudoColumns(catalog, schemaPattern,
1369                            tableNamePattern, columnNamePattern));
1370}
1371        catch (final SQLException e) {
1372            handleException(e);
1373            throw new AssertionError();
1374        }
1375    }
1376
1377    @Override
1378    public boolean generatedKeyAlwaysReturned() throws SQLException {
1379        _conn.checkOpen();
1380        try {
1381            return _meta.generatedKeyAlwaysReturned();
1382        }
1383        catch (final SQLException e) {
1384            handleException(e);
1385            return false;
1386        }
1387    }
1388}