Source Code Cross Referenced for jdbcDatabaseMetaData.java in  » Database-DBMS » hsql » org » hsqldb » jdbc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » hsql » org.hsqldb.jdbc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /* Copyright (c) 2001-2005, The HSQL Development Group
0002:         * All rights reserved.
0003:         *
0004:         * Redistribution and use in source and binary forms, with or without
0005:         * modification, are permitted provided that the following conditions are met:
0006:         *
0007:         * Redistributions of source code must retain the above copyright notice, this
0008:         * list of conditions and the following disclaimer.
0009:         *
0010:         * Redistributions in binary form must reproduce the above copyright notice,
0011:         * this list of conditions and the following disclaimer in the documentation
0012:         * and/or other materials provided with the distribution.
0013:         *
0014:         * Neither the name of the HSQL Development Group nor the names of its
0015:         * contributors may be used to endorse or promote products derived from this
0016:         * software without specific prior written permission.
0017:         *
0018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0020:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0021:         * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
0022:         * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
0023:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
0024:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
0025:         * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
0026:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0027:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
0028:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0029:         */
0030:
0031:        package org.hsqldb.jdbc;
0032:
0033:        import java.sql.Connection;
0034:        import java.sql.DatabaseMetaData;
0035:        import java.sql.ResultSet;
0036:        import java.sql.SQLException;
0037:
0038:        import org.hsqldb.Column;
0039:        import org.hsqldb.Library;
0040:        import org.hsqldb.Trace;
0041:        import org.hsqldb.lib.StringUtil;
0042:        import org.hsqldb.persist.HsqlDatabaseProperties;
0043:
0044:        // fredt@users 20020320 - patch 1.7.0 - JDBC 2 support and error trapping
0045:        // JDBC 2 methods can now be called from jdk 1.1.x - see javadoc comments
0046:        // boucherb@users 20020509 - added "throws SQLException" to all methods where
0047:        // it was missing here but specified in the java.sql.DatabaseMetaData interface,
0048:        // updated generic documentation to JDK 1.4, and added JDBC3 methods and docs
0049:        // boucherb@users and fredt@users 20020409/20020505 extensive review and update
0050:        // of docs and behaviour to comply with previous and latest java.sql
0051:        // specification
0052:        // boucherb@users 2002-20030121 - extensive rewrite to support new
0053:        // 1.7.2 metadata features.
0054:        // boucherb@users 20040422 - doc 1.7.2 - javadoc updates toward 1.7.2 final
0055:        // boucherb@users 200404xx - misc changes
0056:        // fredt@users 20050505 - patch 1.8.0 - enforced JDBC rules for non-pattern params
0057:
0058:        /** Comprehensive information about the database as a whole.
0059:         * <P>
0060:         * This interface is implemented by driver vendors to let users know the
0061:         * capabilities of a Database Management System (DBMS) in combination with
0062:         * the driver based on JDBC<sup><font size=-2>TM</font></sup> technology
0063:         * ("JDBC driver") that is used with it.  Different relational DBMSs often
0064:         * support different features, implement features in different ways, and use
0065:         * different data types.  In addition, a driver may implement a feature on
0066:         * top of what the DBMS offers.  Information returned by methods in this
0067:         * interface applies to the capabilities of a particular driver and a
0068:         * particular DBMS working together. Note that as used in this documentation,
0069:         * the term "database" is used generically to refer to both the driver and DBMS.
0070:         * <P>
0071:         * A user for this interface is commonly a tool that needs to discover how to
0072:         * deal with the underlying DBMS.  This is especially true for applications
0073:         * that are intended to be used with more than one DBMS. For example, a tool
0074:         * might use the method <code>getTypeInfo</code> to find out what data types
0075:         * can be used in a <code>CREATE TABLE</code> statement.  Or a user might call
0076:         * the method <code>supportsCorrelatedSubqueries</code> to see if it is possible
0077:         * to use a correlated subquery or <code>supportsBatchUpdates</code> to see if
0078:         * it is possible to use batch updates.
0079:         * <P>
0080:         * Some <code>DatabaseMetaData</code> methods return lists of information
0081:         * in the form of <code>ResultSet</code> objects. Regular <code>ResultSet</code>
0082:         * methods, such as <code>getString</code> and <code>getInt</code>, can be used
0083:         * to retrieve the data from these <code>ResultSet</code> objects.  If a given
0084:         * form of metadata is not available, the <code>ResultSet</code> getter methods
0085:         * throw an <code>SQLException</code>.
0086:         * <P>
0087:         * Some <code>DatabaseMetaData</code> methods take arguments that are
0088:         * String patterns.  These arguments all have names such as fooPattern.
0089:         * Within a pattern String, "%" means match any substring of 0 or more
0090:         * characters, and "_" means match any one character. Only metadata
0091:         * entries matching the search pattern are returned. If a search pattern
0092:         * argument is set to <code>null</code>, that argument's criterion will
0093:         * be dropped from the search.
0094:         * <P>
0095:         * A method that gets information about a feature that the driver does not
0096:         * support will throw an <code>SQLException</code>.
0097:         * In the case of methods that return a <code>ResultSet</code>
0098:         * object, either a <code>ResultSet</code> object (which may be empty) is
0099:         * returned or an <code>SQLException</code> is thrown.<p>
0100:         *
0101:         * <!-- start release-specific documentation -->
0102:         * <div class="ReleaseSpecificDocumentation">
0103:         * <h3>HSQLDB-Specific Information:</h3> <p>
0104:         *
0105:         * Starting with HSQLDB 1.7.2, an option is provided to allow alternate
0106:         * system table production implementations.  In this distribution, there are
0107:         * three implementations whose behaviour ranges from producing no system
0108:         * tables at all to producing a richer and more complete body of information
0109:         * about an HSQLDB database than was previously available. The information
0110:         * provided through the default implementation is, unlike previous
0111:         * versions, accessible to all database users, regardless of admin status.
0112:         * This is now possible because the table content it produces for each
0113:         * user is pre-filtered, based on the user's access rights. That is, each
0114:         * system table now acts like a security-aware View.<p>
0115:         *
0116:         * The process of installing a system table production class is transparent and
0117:         * occurs dynamically at runtime during the opening sequence of a
0118:         * <code>Database</code> instance, in the newDatabaseInformation() factory
0119:         * method of the revised DatabaseInformation class, using the following
0120:         * steps: <p>
0121:         *
0122:         * <div class="GeneralExample">
0123:         * <ol>
0124:         * <li>If a class whose fully qualified name is org.hsqldb.DatabaseInformationFull
0125:         *     can be found and it has an accesible constructor that takes an
0126:         *     org.hsqldb.Database object as its single parameter, then an instance of
0127:         *     that class is reflectively instantiated and is used by the database
0128:         *     instance to produce its system tables. <p>
0129:         *
0130:         * <li>If 1.) fails, then the process is repeated, attempting to create an
0131:         *     instance of org.hsqldb.DatabaseInformationMain (which provides just the
0132:         *     core set of system tables required to service this class, but now does
0133:         *     so in a more security aware and comprehensive fashion). <p>
0134:         *
0135:         * <li>If 2.) fails, then an instance of org.hsqldb.DatabaseInformation is
0136:         *     installed (that, by default, produces no system tables, meaning that
0137:         *     calls to all related methods in this class will fail, throwing an
0138:         *     SQLException stating that a required system table is not found). <p>
0139:         *
0140:         * </ol>
0141:         * </div> <p>
0142:         *
0143:         * The process of searching for alternate implementations of database
0144:         * support classes, ending with the installation of a minimal but functional
0145:         * default will be refered to henceforth as <i>graceful degradation</i>.
0146:         * This process is advantageous in that it allows developers and administrators
0147:         * to easily choose packaging options, simply by adding to or deleting concerned
0148:         * classes from an  HSQLDB installation, without worry over providing complex
0149:         * initialization properties or disrupting the core operation of the engine.
0150:         * In this particular context, <i>graceful degradation</i> allows easy choices
0151:         * regarding database metadata, spanning the range of full (design-time),
0152:         * custom-written, minimal (production-time) or <CODE>null</CODE>
0153:         * (space-constrained) system table production implementations. <p>
0154:         *
0155:         * In the default full implementation, a number of new system tables are
0156:         * provided that, although not used directly by this class, present previously
0157:         * unavailable information about the database, such as about its triggers and
0158:         * aliases. <p>
0159:         *
0160:         * In order to better support graphical database exploration tools and as an
0161:         * experimental intermediate step toward more fully supporting SQL9n and
0162:         * SQL200n, the default installed DatabaseInformation implementation
0163:         * is also capable of reporting pseudo name space information, such as
0164:         * the catalog (database URI) of database objects. <p>
0165:         *
0166:         * The catalog reporting feature is turned off by default but
0167:         * can be turned on by providing the appropriate entries in the database
0168:         * properties file (see the advanced topics section of the product
0169:         * documentation). <p>
0170:         *
0171:         * When the feature is turned on, catalog is reported using
0172:         * the following conventions: <p>
0173:         *
0174:         * <ol>
0175:         * <li>All objects are reported as having a catalog equal to the URI of the
0176:         *     database, which is equivalent to the catenation of the
0177:         *     <b>&lt;type&gt;</b> and <b>&lt;path&gt;</b> portions of the HSQLDB
0178:         *     internal JDBC connection URL.<p>
0179:         *
0180:         *     Examples: <p>
0181:         *
0182:         *     <pre class="JavaCodeExample">
0183:         *     <span class="JavaStringLiteral">&quot;jdbc:hsqldb:file:test&quot;</span>      => <span class="JavaStringLiteral">&quot;file:test&quot;</span>
0184:         *     <span class="JavaStringLiteral">&quot;jdbc:hsqldb:mem:.&quot;</span>          => <span class="JavaStringLiteral">&quot;mem:.&quot;</span>
0185:         *     <span class="JavaStringLiteral">&quot;jdbc:hsqldb:hsql:/host/<alias>...&quot;</span> => URI of aliased database
0186:         *     <span class="JavaStringLiteral">&quot;jdbc:hsqldb:http:/host/<alias>...&quot;</span> => URI of aliased database
0187:         *     </pre>
0188:         *
0189:         *     <b>Note:</b> No provision is made for qualifying database objects
0190:         *     by catalog in DML or DDL SQL.  This feature is functional only with
0191:         *     respect to browsing the database through the DatabaseMetaData and system
0192:         *     table interfaces. <p>
0193:         *
0194:         * </ol>
0195:         *
0196:         * Again, it should be well understood that this feature provide an
0197:         * <i>emulation</i> of catalog support and is intended only
0198:         * as an experimental implementation to enhance the browsing experience
0199:         * when using graphical database explorers and to make a first foray
0200:         * into tackling the issue of implementing true catalog support
0201:         * in the future. <p>
0202:         *
0203:         * Due the nature of the new database system table production process, fewer
0204:         * assumptions can be made by this class about what information is made
0205:         * available in the system tables supporting <code>DatabaseMetaData</code>
0206:         * methods. Because of this, the SQL queries behind the <code>ResultSet</code>
0207:         * producing methods have been cleaned up and made to adhere more strictly to
0208:         * the JDBC contracts specified in relation to the method parameters. <p>
0209:         *
0210:         * One of the remaining assumptions concerns the <code>approximate</code>
0211:         * argument of {@link #getIndexInfo getIndexInfo()}. This parameter is still
0212:         * ignored since there is not yet any process in place to internally gather
0213:         * and persist table and index statistics.  A primitive version of a statistics
0214:         * gathering and reporting subsystem <em>may</em> be introduced some time in the
0215:         * 1.7.x series of releases, but no hard decision has yet been made. <p>
0216:         *
0217:         * Another assumption is that simple select queries against certain system
0218:         * tables will return rows in JDBC contract order in the absence of an
0219:         * &quot;ORDER BY&quot; clause.  The reason for this is that results
0220:         * come back much faster when no &quot;ORDER BY&quot; clause is used.
0221:         * Developers wishing to extend or replace an existing system table production
0222:         * class should be aware of this, either adding the contract
0223:         * &quot;ORDER BY&quot; clause to the SQL in corresponding methods in this class,
0224:         * or, better, by maintaing rows in the correct order in the underlying
0225:         * system tables, prefereably by creating appropriate primary indices. <p>
0226:         *
0227:         * <hr>
0228:         *
0229:         * <b>JRE 1.1.x Notes:</b> <p>
0230:         *
0231:         * In general, JDBC 2 support requires Java 1.2 and above, and JDBC3 requires
0232:         * Java 1.4 and above. In HSQLDB, support for methods introduced in different
0233:         * versions of JDBC depends on the JDK version used for compiling and building
0234:         * HSQLDB.<p>
0235:         *
0236:         * Since 1.7.0, it is possible to build the product so that
0237:         * all JDBC 2 methods can be called while executing under the version 1.1.x
0238:         * <em>Java Runtime Environment</em><sup><font size="-2">TM</font></sup>.
0239:         * However, some of these method calls require <code>int</code> values that
0240:         * are defined only in the JDBC 2 or greater version of the
0241:         * {@link java.sql.ResultSet ResultSet} interface.  For this reason, when the
0242:         * product is compiled under JDK 1.1.x, these values are defined in
0243:         * {@link jdbcResultSet jdbcResultSet}.<p>
0244:         *
0245:         * In a JRE 1.1.x environment, calling JDBC 2 methods that take or return the
0246:         * JDBC2-only <code>ResultSet</code> values can be achieved by referring
0247:         * to them in parameter specifications and return value comparisons,
0248:         * respectively, as follows: <p>
0249:         *
0250:         * <pre class="JavaCodeExample">
0251:         * jdbcResultSet.FETCH_FORWARD
0252:         * jdbcResultSet.TYPE_FORWARD_ONLY
0253:         * jdbcResultSet.TYPE_SCROLL_INSENSITIVE
0254:         * jdbcResultSet.CONCUR_READ_ONLY
0255:         * // etc
0256:         * </pre>
0257:         *
0258:         * However, please note that code written in such a manner will not be
0259:         * compatible for use with other JDBC 2 drivers, since they expect and use
0260:         * <code>ResultSet</code>, rather than <code>jdbcResultSet</code>.  Also
0261:         * note, this feature is offered solely as a convenience to developers
0262:         * who must work under JDK 1.1.x due to operating constraints, yet wish to
0263:         * use some of the more advanced features available under the JDBC 2
0264:         * specification.<p>
0265:         *
0266:         * (fredt@users)<br>
0267:         * (boucherb@users)
0268:         * </div>
0269:         * <!-- end release-specific documentation -->
0270:         *
0271:         * @author boucherb@users
0272:         * @author fredt@users
0273:         * @version 1.7.2
0274:         * @see org.hsqldb.DatabaseInformation
0275:         * @see org.hsqldb.DatabaseInformationMain
0276:         * @see org.hsqldb.DatabaseInformationFull
0277:         */
0278:        public class jdbcDatabaseMetaData implements  DatabaseMetaData {
0279:
0280:            /** Used by getBestRowIdentifier to avoid extra object construction */
0281:            static final Integer INT_COLUMNS_NO_NULLS = new Integer(
0282:                    columnNoNulls);
0283:
0284:            // -----------------------------------------------------------------------
0285:            // private attributes
0286:            // -----------------------------------------------------------------------
0287:
0288:            /**
0289:             * The connection this object uses to retrieve database instance-specific
0290:             * metadata.
0291:             */
0292:            private jdbcConnection connection;
0293:
0294:            /**
0295:             * Connection property for schema reporting.
0296:             */
0297:            private boolean useSchemaDefault;
0298:
0299:            /**
0300:             * A CSV list representing the SQL IN list to use when generating
0301:             * queries for <code>getBestRowIdentifier</code> when the
0302:             * <code>scope</code> argument is <code>bestRowSession</code>.
0303:             * @since HSQLDB 1.7.2
0304:             */
0305:            private static final String BRI_SESSION_SCOPE_IN_LIST = "("
0306:                    + bestRowSession + ")";
0307:
0308:            /**
0309:             * A CSV list representing the SQL IN list to use when generating
0310:             * queries for <code>getBestRowIdentifier</code> when the
0311:             * <code>scope</code> argument is <code>bestRowTemporary</code>.
0312:             * @since HSQLDB 1.7.2
0313:             */
0314:            private static final String BRI_TEMPORARY_SCOPE_IN_LIST = "("
0315:                    + bestRowTemporary + "," + bestRowTransaction + ","
0316:                    + bestRowSession + ")";
0317:
0318:            /**
0319:             * A CSV list representing the SQL IN list to use when generating
0320:             * queries for <code>getBestRowIdentifier</code> when the
0321:             * <code>scope</code> argument is <code>bestRowTransaction</code>.
0322:             * @since HSQLDB 1.7.2
0323:             */
0324:            private static final String BRI_TRANSACTION_SCOPE_IN_LIST = "("
0325:                    + bestRowTransaction + "," + bestRowSession + ")";
0326:
0327:            /**
0328:             * "SELECT * FROM ". <p>
0329:             *
0330:             * This attribute is in support of methods that use SQL SELECT statements to
0331:             * generate returned <code>ResultSet</code> objects. <p>
0332:             *
0333:             * @since HSQLDB 1.7.2
0334:             */
0335:            private static final String selstar = "SELECT * FROM INFORMATION_SCHEMA.";
0336:
0337:            /**
0338:             * " WHERE 1=1 ". <p>
0339:             *
0340:             * This attribute is in support of methods that use SQL SELECT statements to
0341:             * generate returned <code>ResultSet</code> objects. <p>
0342:             *
0343:             * A good optimizer will simply drop this when parsing a condition
0344:             * expression. And it makes our code much easier to write, since we don't
0345:             * have to check our "WHERE" clause productions as strictly for proper
0346:             * conjunction:  we just stick additional conjunctive predicates on the
0347:             * end of this and Presto! Everything works :-) <p>
0348:             * @since HSQLDB 1.7.2
0349:             */
0350:            private static final String whereTrue = " WHERE 1=1";
0351:
0352:            //----------------------------------------------------------------------
0353:            // First, a variety of minor information about the target database.
0354:
0355:            /**
0356:             * Retrieves whether the current user can call all the procedures
0357:             * returned by the method <code>getProcedures</code>.  <p>
0358:             *
0359:             * <!-- start release-specific documentation -->
0360:             * <div class="ReleaseSpecificDocumentation">
0361:             * <h3>HSQLDB-Specific Information:</h3> <p>
0362:             *
0363:             * This method still <em>always</em> returns
0364:             * <code>true</code>. <p>
0365:             *
0366:             * In a future release, the plugin interface may be modified to allow
0367:             * implementors to report different values here, based on their
0368:             * implementations.
0369:             * </div>
0370:             * <!-- end release-specific documentation -->
0371:             *
0372:             * @return <code>true</code> if so; <code>false</code> otherwise
0373:             * @exception SQLException if a database access error occurs
0374:             */
0375:            public boolean allProceduresAreCallable() throws SQLException {
0376:                return true;
0377:            }
0378:
0379:            /**
0380:             * Retrieves whether the current user can use all the tables returned
0381:             * by the method <code>getTables</code> in a <code>SELECT</code>
0382:             * statement.  <p>
0383:             *
0384:             * <!-- start release-specific documentation -->
0385:             * <div class="ReleaseSpecificDocumentation">
0386:             * <h3>HSQLDB-Specific Information:</h3> <p>
0387:             *
0388:             * HSQLDB always reports <code>true</code>.<p>
0389:             *
0390:             * Please note that the default 1.7.2 <code>getTables</code> behaviour is
0391:             * omit from the list of <em>requested</em> tables only those to which the
0392:             * invoking user has <em>no</em> access of any kind. <p>
0393:             *
0394:             * </div>
0395:             * <!-- end release-specific documentation -->
0396:             *
0397:             * @return <code>true</code> if so; <code>false</code> otherwise
0398:             * @exception SQLException if a database access error occurs
0399:             */
0400:            public boolean allTablesAreSelectable() throws SQLException {
0401:                return true;
0402:            }
0403:
0404:            /**
0405:             * Retrieves the URL for this DBMS.
0406:             *
0407:             *
0408:             * @return the URL for this DBMS or <code>null</code> if it cannot be
0409:             *         generated
0410:             * @exception SQLException if a database access error occurs
0411:             */
0412:            public String getURL() throws SQLException {
0413:                return connection.getURL();
0414:            }
0415:
0416:            /**
0417:             * Retrieves the user name as known to this database.
0418:             *
0419:             *
0420:             * @return the database user name
0421:             * @exception SQLException if a database access error occurs
0422:             */
0423:            public String getUserName() throws SQLException {
0424:
0425:                ResultSet rs = execute("CALL USER()");
0426:
0427:                rs.next();
0428:
0429:                String result = rs.getString(1);
0430:
0431:                rs.close();
0432:
0433:                return result;
0434:            }
0435:
0436:            /**
0437:             * Retrieves whether this database is in read-only mode. <p>
0438:             *
0439:             * <!-- start release-specific documentation -->
0440:             * <div class="ReleaseSpecificDocumentation">
0441:             * <h3>HSQLDB-Specific Information:</h3> <p>
0442:             *
0443:             * Starting with 1.7.2, this makes
0444:             * an SQL call to the new {@link Library#isReadOnlyDatabase} method
0445:             * which provides correct determination of the read-only status for
0446:             * both local and remote database instances.
0447:             * </div>
0448:             * <!-- end release-specific documentation -->
0449:             * @return <code>true</code> if so; <code>false</code> otherwise
0450:             * @exception SQLException if a database access error occurs
0451:             */
0452:            public boolean isReadOnly() throws SQLException {
0453:
0454:                ResultSet rs = execute("CALL \"org.hsqldb.Library.isReadOnlyDatabase\"()");
0455:
0456:                rs.next();
0457:
0458:                boolean result = rs.getBoolean(1);
0459:
0460:                rs.close();
0461:
0462:                return result;
0463:            }
0464:
0465:            /**
0466:             * Retrieves whether <code>NULL</code> values are sorted high.
0467:             * Sorted high means that <code>NULL</code> values
0468:             * sort higher than any other value in a domain.  In an ascending order,
0469:             * if this method returns <code>true</code>,  <code>NULL</code> values
0470:             * will appear at the end. By contrast, the method
0471:             * <code>nullsAreSortedAtEnd</code> indicates whether <code>NULL</code> values
0472:             * are sorted at the end regardless of sort order. <p>
0473:             *
0474:             * <!-- start release-specific documentation -->
0475:             * <div class="ReleaseSpecificDocumentation">
0476:             * <h3>HSQLDB-Specific Information:</h3> <p>
0477:             *
0478:             * HSQLDB sorts null low; this method always returns <code>false</code>.
0479:             * </div>
0480:             * <!-- end release-specific documentation -->
0481:             *
0482:             *
0483:             * @return <code>true</code> if so; <code>false</code> otherwise
0484:             * @exception SQLException if a database access error occurs
0485:             */
0486:            public boolean nullsAreSortedHigh() throws SQLException {
0487:                return false;
0488:            }
0489:
0490:            /**
0491:             * Retrieves whether <code>NULL</code> values are sorted low.
0492:             * Sorted low means that <code>NULL</code> values
0493:             * sort lower than any other value in a domain.  In an ascending order,
0494:             * if this method returns <code>true</code>,  <code>NULL</code> values
0495:             * will appear at the beginning. By contrast, the method
0496:             * <code>nullsAreSortedAtStart</code> indicates whether <code>NULL</code> values
0497:             * are sorted at the beginning regardless of sort order. <p>
0498:             *
0499:             * <!-- start release-specific documentation -->
0500:             * <div class="ReleaseSpecificDocumentation">
0501:             * <h3>HSQLDB-Specific Information:</h3> <p>
0502:             *
0503:             * HSQLDB sorts null low; this method always returns <code>true</code>.
0504:             * </div>
0505:             * <!-- end release-specific documentation -->
0506:             *
0507:             *
0508:             * @return <code>true</code> if so; <code>false</code> otherwise
0509:             * @exception SQLException if a database access error occurs
0510:             */
0511:            public boolean nullsAreSortedLow() throws SQLException {
0512:                return true;
0513:            }
0514:
0515:            /**
0516:             * Retrieves whether <code>NULL</code> values are sorted at the start regardless
0517:             * of sort order. <p>
0518:             *
0519:             * <!-- start release-specific documentation -->
0520:             * <div class="ReleaseSpecificDocumentation">
0521:             * <h3>HSQLDB-Specific Information:</h3> <p>
0522:             *
0523:             * HSQLDB sorts null low; this method always returns <code>false</code>.
0524:             * </div>
0525:             * <!-- end release-specific documentation -->
0526:             *
0527:             *
0528:             * @return <code>true</code> if so; <code>false</code> otherwise
0529:             * @exception SQLException if a database access error occurs
0530:             */
0531:            public boolean nullsAreSortedAtStart() throws SQLException {
0532:                return false;
0533:            }
0534:
0535:            /**
0536:             * Retrieves whether <code>NULL</code> values are sorted at the end regardless of
0537:             * sort order. <p>
0538:             *
0539:             * <!-- start release-specific documentation -->
0540:             * <div class="ReleaseSpecificDocumentation">
0541:             * <h3>HSQLDB-Specific Information:</h3> <p>
0542:             *
0543:             * HSQLDB sorts null low; this method always returns <code>false</code>.
0544:             * </div>
0545:             * <!-- end release-specific documentation -->
0546:             *
0547:             *
0548:             * @return <code>true</code> if so; <code>false</code> otherwise
0549:             * @exception SQLException if a database access error occurs
0550:             */
0551:            public boolean nullsAreSortedAtEnd() throws SQLException {
0552:                return false;
0553:            }
0554:
0555:            /**
0556:             * Retrieves the name of this database product. <p>
0557:             *
0558:             * <div class="ReleaseSpecificDocumentation">
0559:             * <h3>HSQLDB-Specific Information:</h3> <p>
0560:             *
0561:             * Starting with HSQLDB 1.7.2, this value is retrieved through an
0562:             * SQL call to the new {@link Library#getDatabaseProductName} method
0563:             * which allows correct determination of the database product name
0564:             * for both local and remote database instances.
0565:             * </div> <p>
0566:             *
0567:             * @return database product name
0568:             * @exception SQLException if a database access error occurs
0569:             */
0570:            public String getDatabaseProductName() throws SQLException {
0571:
0572:                ResultSet rs = execute("call \"org.hsqldb.Library.getDatabaseProductName\"()");
0573:
0574:                rs.next();
0575:
0576:                String result = rs.getString(1);
0577:
0578:                rs.close();
0579:
0580:                return result;
0581:            }
0582:
0583:            /**
0584:             * Retrieves the version number of this database product. <p>
0585:             *
0586:             * <div class="ReleaseSpecificDocumentation">
0587:             * <h3>HSQLDB-Specific Information:</h3> <p>
0588:             *
0589:             * Starting with HSQLDB 1.7.2, this value is retrieved through an
0590:             * SQL call to the new {@link Library#getDatabaseProductVersion} method
0591:             * which allows correct determination of the database product name
0592:             * for both local and remote database instances.
0593:             * </div> <p>
0594:             *
0595:             * @return database version number
0596:             * @exception SQLException if a database access error occurs
0597:             */
0598:            public String getDatabaseProductVersion() throws SQLException {
0599:
0600:                ResultSet rs = execute("call \"org.hsqldb.Library.getDatabaseProductVersion\"()");
0601:
0602:                rs.next();
0603:
0604:                String result = rs.getString(1);
0605:
0606:                rs.close();
0607:
0608:                return result;
0609:            }
0610:
0611:            /**
0612:             * Retrieves the name of this JDBC driver.
0613:             *
0614:             * @return JDBC driver name
0615:             * @exception SQLException if a database access error occurs
0616:             */
0617:            public String getDriverName() throws SQLException {
0618:                return HsqlDatabaseProperties.PRODUCT_NAME + " Driver";
0619:            }
0620:
0621:            /**
0622:             * Retrieves the version number of this JDBC driver as a <code>String</code>.
0623:             *
0624:             * @return JDBC driver version
0625:             * @exception SQLException if a database access error occurs
0626:             */
0627:            public String getDriverVersion() throws SQLException {
0628:                return HsqlDatabaseProperties.THIS_VERSION;
0629:            }
0630:
0631:            /**
0632:             * Retrieves this JDBC driver's major version number.
0633:             *
0634:             * @return JDBC driver major version
0635:             */
0636:            public int getDriverMajorVersion() {
0637:                return HsqlDatabaseProperties.MAJOR;
0638:            }
0639:
0640:            /**
0641:             * Retrieves this JDBC driver's minor version number.
0642:             *
0643:             * @return JDBC driver minor version number
0644:             */
0645:            public int getDriverMinorVersion() {
0646:                return HsqlDatabaseProperties.MINOR;
0647:            }
0648:
0649:            /**
0650:             * Retrieves whether this database stores tables in a local file. <p>
0651:             *
0652:             * <!-- start release-specific documentation -->
0653:             * <div class="ReleaseSpecificDocumentation">
0654:             * <h3>HSQLDB-Specific Information:</h3> <p>
0655:             *
0656:             * From HSQLDB 1.7.2 it is assumed that this refers to data being stored
0657:             * by the JDBC client. This method always returns false.
0658:             * </div>
0659:             * <!-- end release-specific documentation -->
0660:             * @return <code>true</code> if so; <code>false</code> otherwise
0661:             * @exception SQLException if a database access error occurs
0662:             */
0663:            public boolean usesLocalFiles() throws SQLException {
0664:                return false;
0665:            }
0666:
0667:            /**
0668:             * Retrieves whether this database uses a file for each table. <p>
0669:             *
0670:             * <!-- start release-specific documentation -->
0671:             * <div class="ReleaseSpecificDocumentation">
0672:             * <h3>HSQLDB-Specific Information:</h3> <p>
0673:             *
0674:             * Up to and including 1.7.2, HSQLDB does not use a file for each table.
0675:             * This method always returns <code>false</code>.
0676:             * </div>
0677:             * <!-- end release-specific documentation -->
0678:             * @return <code>true</code> if this database uses a local file for each table;
0679:             *      <code>false</code> otherwise
0680:             * @exception SQLException if a database access error occurs
0681:             */
0682:            public boolean usesLocalFilePerTable() throws SQLException {
0683:                return false;
0684:            }
0685:
0686:            /**
0687:             * Retrieves whether this database treats mixed case unquoted SQL identifiers as
0688:             * case sensitive and as a result stores them in mixed case. <p>
0689:             *
0690:             * <!-- start release-specific documentation -->
0691:             * <div class="ReleaseSpecificDocumentation">
0692:             * <h3>HSQLDB-Specific Information:</h3> <p>
0693:             *
0694:             * HSQLDB treats unquoted identifiers as case insensitive and stores
0695:             * them in upper case. It treats quoted identifiers as case sensitive and
0696:             * stores them verbatim; this method always returns <code>false</code>.
0697:             * </div>
0698:             * <!-- end release-specific documentation -->
0699:             *
0700:             *
0701:             * @return <code>true</code> if so; <code>false</code> otherwise
0702:             * @exception SQLException if a database access error occurs
0703:             */
0704:            public boolean supportsMixedCaseIdentifiers() throws SQLException {
0705:                return false;
0706:            }
0707:
0708:            /**
0709:             * Retrieves whether this database treats mixed case unquoted SQL identifiers as
0710:             * case insensitive and stores them in upper case. <p>
0711:             *
0712:             * <!-- start release-specific documentation -->
0713:             * <div class="ReleaseSpecificDocumentation">
0714:             * <h3>HSQLDB-Specific Information:</h3> <p>
0715:             *
0716:             * HSQLDB treats unquoted identifiers as case insensitive and stores
0717:             * them in upper case. It treats quoted identifiers as case sensitive and
0718:             * stores them verbatim; this method always returns <code>true</code>.
0719:             * </div>
0720:             * <!-- end release-specific documentation -->
0721:             *
0722:             *
0723:             * @return <code>true</code> if so; <code>false</code> otherwise
0724:             * @exception SQLException if a database access error occurs
0725:             */
0726:            public boolean storesUpperCaseIdentifiers() throws SQLException {
0727:                return true;
0728:            }
0729:
0730:            /**
0731:             * Retrieves whether this database treats mixed case unquoted SQL identifiers as
0732:             * case insensitive and stores them in lower case. <p>
0733:             *
0734:             * <!-- start release-specific documentation -->
0735:             * <div class="ReleaseSpecificDocumentation">
0736:             * <h3>HSQLDB-Specific Information:</h3> <p>
0737:             *
0738:             * HSQLDB treats unquoted identifiers as case insensitive and stores
0739:             * them in upper case. It treats quoted identifiers as case sensitive and
0740:             * stores them verbatim; this method always returns <code>false</code>.
0741:             * </div>
0742:             * <!-- end release-specific documentation -->
0743:             *
0744:             *
0745:             * @return <code>true</code> if so; <code>false</code> otherwise
0746:             * @exception SQLException if a database access error occurs
0747:             */
0748:            public boolean storesLowerCaseIdentifiers() throws SQLException {
0749:                return false;
0750:            }
0751:
0752:            /**
0753:             * Retrieves whether this database treats mixed case unquoted SQL identifiers as
0754:             * case insensitive and stores them in mixed case. <p>
0755:             *
0756:             * <!-- start release-specific documentation -->
0757:             * <div class="ReleaseSpecificDocumentation">
0758:             * <h3>HSQLDB-Specific Information:</h3> <p>
0759:             *
0760:             * HSQLDB treats unquoted identifiers as case insensitive and stores
0761:             * them in upper case. It treats quoted identifiers as case sensitive and
0762:             * stores them verbatim; this method always returns <code>false</code>.
0763:             * </div>
0764:             * <!-- end release-specific documentation -->
0765:             *
0766:             *
0767:             * @return <code>true</code> if so; <code>false</code> otherwise
0768:             * @exception SQLException if a database access error occurs
0769:             */
0770:            public boolean storesMixedCaseIdentifiers() throws SQLException {
0771:                return false;
0772:            }
0773:
0774:            /**
0775:             * Retrieves whether this database treats mixed case quoted SQL identifiers as
0776:             * case sensitive and as a result stores them in mixed case. <p>
0777:             *
0778:             * <!-- start release-specific documentation -->
0779:             * <div class="ReleaseSpecificDocumentation">
0780:             * <h3>HSQLDB-Specific Information:</h3> <p>
0781:             *
0782:             * HSQLDB treats unquoted identifiers as case insensitive and stores
0783:             * them in upper case. It treats quoted identifiers as case sensitive and
0784:             * stores them verbatim; this method always returns <code>true</code>.
0785:             * </div>
0786:             * <!-- end release-specific documentation -->
0787:             *
0788:             *
0789:             * @return <code>true</code> if so; <code>false</code> otherwise
0790:             * @exception SQLException if a database access error occurs
0791:             */
0792:            public boolean supportsMixedCaseQuotedIdentifiers()
0793:                    throws SQLException {
0794:                return true;
0795:            }
0796:
0797:            /**
0798:             * Retrieves whether this database treats mixed case quoted SQL identifiers as
0799:             * case insensitive and stores them in upper case. <p>
0800:             *
0801:             * <!-- start release-specific documentation -->
0802:             * <div class="ReleaseSpecificDocumentation">
0803:             * <h3>HSQLDB-Specific Information:</h3> <p>
0804:             *
0805:             * HSQLDB treats unquoted identifiers as case insensitive and stores
0806:             * them in upper case. It treats quoted identifiers as case sensitive and
0807:             * stores them verbatim; this method always returns <code>false</code>.
0808:             * </div>
0809:             * <!-- end release-specific documentation -->
0810:             *
0811:             *
0812:             * @return <code>true</code> if so; <code>false</code> otherwise
0813:             * @exception SQLException if a database access error occurs
0814:             */
0815:            public boolean storesUpperCaseQuotedIdentifiers()
0816:                    throws SQLException {
0817:                return false;
0818:            }
0819:
0820:            /**
0821:             * Retrieves whether this database treats mixed case quoted SQL identifiers as
0822:             * case insensitive and stores them in lower case. <p>
0823:             *
0824:             * <!-- start release-specific documentation -->
0825:             * <div class="ReleaseSpecificDocumentation">
0826:             * <h3>HSQLDB-Specific Information:</h3> <p>
0827:             *
0828:             * HSQLDB treats unquoted identifiers as case insensitive and stores
0829:             * them in upper case. It treats quoted identifiers as case sensitive and
0830:             * stores them verbatim; this method always returns <code>false</code>.
0831:             * </div>
0832:             * <!-- end release-specific documentation -->
0833:             * @return <code>true</code> if so; <code>false</code> otherwise
0834:             * @exception SQLException if a database access error occurs
0835:             */
0836:            public boolean storesLowerCaseQuotedIdentifiers()
0837:                    throws SQLException {
0838:                return false;
0839:            }
0840:
0841:            /**
0842:             * Retrieves whether this database treats mixed case quoted SQL identifiers as
0843:             * case insensitive and stores them in mixed case. <p>
0844:             *
0845:             * <!-- start release-specific documentation -->
0846:             * <div class="ReleaseSpecificDocumentation">
0847:             * <h3>HSQLDB-Specific Information:</h3> <p>
0848:             *
0849:             * HSQLDB treats unquoted identifiers as case insensitive and stores
0850:             * them in upper case. It treats quoted identifiers as case sensitive and
0851:             * stores them verbatim; this method always returns <code>false</code>.
0852:             * </div>
0853:             * <!-- end release-specific documentation -->
0854:             *
0855:             *
0856:             * @return <code>true</code> if so; <code>false</code> otherwise
0857:             * @exception SQLException if a database access error occurs
0858:             */
0859:            public boolean storesMixedCaseQuotedIdentifiers()
0860:                    throws SQLException {
0861:                return false;
0862:            }
0863:
0864:            /**
0865:             * Retrieves the string used to quote SQL identifiers.
0866:             * This method returns a space " " if identifier quoting is not supported. <p>
0867:             *
0868:             * <!-- start release-specific documentation -->
0869:             * <div class="ReleaseSpecificDocumentation">
0870:             * <h3>HSQLDB-Specific Information:</h3> <p>
0871:             *
0872:             * HSQLDB uses the standard SQL identifier quote character
0873:             * (the double quote character); this method always returns <b>"</b>.
0874:             * </div>
0875:             * <!-- end release-specific documentation -->
0876:             * @return the quoting string or a space if quoting is not supported
0877:             * @exception SQLException if a database access error occurs
0878:             */
0879:            public String getIdentifierQuoteString() throws SQLException {
0880:                return "\"";
0881:            }
0882:
0883:            //fredt@users 20020429 - JavaDoc comment - in 1.7.1 there are keywords such
0884:            // as TEMP, TEXT, CACHED that are not SQL 92 keywords
0885:
0886:            /**
0887:             * Retrieves a comma-separated list of all of this database's SQL keywords
0888:             * that are NOT also SQL92 keywords. <p>
0889:             *
0890:             * <!-- start release-specific documentation -->
0891:             * <div class="ReleaseSpecificDocumentation">
0892:             * <h3>HSQLDB-Specific Information:</h3> <p>
0893:             *
0894:             * The list returned contains HSQLDB keywords that are not in the list
0895:             * of reserved words. Some of these are in the list reserved
0896:             * words for SQL 2003 but are not SQL92 keywords.
0897:             * </div>
0898:             * <!-- end release-specific documentation -->
0899:             *
0900:             *
0901:             * @return the list of this database's keywords that are not also
0902:             *       SQL92 keywords
0903:             * @exception SQLException if a database access error occurs
0904:             */
0905:            public String getSQLKeywords() throws SQLException {
0906:
0907:                return "BEFORE,BIGINT,BINARY,CACHED,DATETIME,"
0908:                        + "LIMIT,LONGVARBINARY,LONGVARCHAR,OBJECT,OTHER,SAVEPOINT,"
0909:                        + "TEMP,TEXT,TOP,TRIGGER,TINYINT,VARBINARY,VARCHAR_IGNORECASE";
0910:            }
0911:
0912:            /**
0913:             * Retrieves a comma-separated list of math functions available with
0914:             * this database.  These are the Open Group CLI math function names used in
0915:             * the JDBC function escape clause.
0916:             * @return the list of math functions supported by this database
0917:             * @exception SQLException if a database access error occurs
0918:             */
0919:            public String getNumericFunctions() throws SQLException {
0920:                return StringUtil.getList(Library.sNumeric, ",", "");
0921:            }
0922:
0923:            /**
0924:             * Retrieves a comma-separated list of string functions available with
0925:             * this database.  These are the  Open Group CLI string function names used
0926:             * in the JDBC function escape clause.
0927:             * @return the list of string functions supported by this database
0928:             * @exception SQLException if a database access error occurs
0929:             */
0930:            public String getStringFunctions() throws SQLException {
0931:                return StringUtil.getList(Library.sString, ",", "");
0932:            }
0933:
0934:            /**
0935:             * Retrieves a comma-separated list of system functions available with
0936:             * this database.  These are the  Open Group CLI system function names used
0937:             * in the JDBC function escape clause.
0938:             * @return a list of system functions supported by this database
0939:             * @exception SQLException if a database access error occurs
0940:             */
0941:            public String getSystemFunctions() throws SQLException {
0942:                return StringUtil.getList(Library.sSystem, ",", "");
0943:            }
0944:
0945:            /**
0946:             * Retrieves a comma-separated list of the time and date functions available
0947:             * with this database.
0948:             * @return the list of time and date functions supported by this database
0949:             * @exception SQLException if a database access error occurs
0950:             */
0951:            public String getTimeDateFunctions() throws SQLException {
0952:                return StringUtil.getList(Library.sTimeDate, ",", "");
0953:            }
0954:
0955:            /**
0956:             * Retrieves the string that can be used to escape wildcard characters.
0957:             * This is the string that can be used to escape '_' or '%' in
0958:             * the catalog search parameters that are a pattern (and therefore use one
0959:             * of the wildcard characters).
0960:             *
0961:             * <P>The '_' character represents any single character;
0962:             * the '%' character represents any sequence of zero or
0963:             * more characters. <p>
0964:             *
0965:             * <!-- start release-specific documentation -->
0966:             * <div class="ReleaseSpecificDocumentation">
0967:             * <h3>HSQLDB-Specific Information:</h3> <p>
0968:             *
0969:             * HSQLDB uses the "\" character to escape wildcard characters.
0970:             * </div>
0971:             * <!-- end release-specific documentation -->
0972:             *
0973:             *
0974:             * @return the string used to escape wildcard characters
0975:             * @exception SQLException if a database access error occurs
0976:             */
0977:            public String getSearchStringEscape() throws SQLException {
0978:                return "\\";
0979:            }
0980:
0981:            /**
0982:             * Retrieves all the "extra" characters that can be used in unquoted
0983:             * identifier names (those beyond a-z, A-Z, 0-9 and _). <p>
0984:             *
0985:             * <!-- start release-specific documentation -->
0986:             * <div class="ReleaseSpecificDocumentation">
0987:             * <h3>HSQLDB-Specific Information:</h3> <p>
0988:             *
0989:             * HSQLDB does not support using any "extra" characters in unquoted
0990:             * identifier names; this method always returns the empty String.
0991:             * </div>
0992:             * <!-- end release-specific documentation -->
0993:             *
0994:             *
0995:             * @return the string containing the extra characters
0996:             * @exception SQLException if a database access error occurs
0997:             */
0998:            public String getExtraNameCharacters() throws SQLException {
0999:                return "";
1000:            }
1001:
1002:            //--------------------------------------------------------------------
1003:            // Functions describing which features are supported.
1004:
1005:            /**
1006:             * Retrieves whether this database supports <code>ALTER TABLE</code>
1007:             * with add column. <p>
1008:             *
1009:             * <!-- start release-specific documentation -->
1010:             * <div class="ReleaseSpecificDocumentation">
1011:             * <h3>HSQLDB-Specific Information:</h3> <p>
1012:             *
1013:             * From 1.7.0, HSQLDB supports this type of
1014:             * <code>ALTER TABLE</code> statement; this method always
1015:             * returns <code>true</code>.
1016:             * </div>
1017:             * <!-- end release-specific documentation -->
1018:             * @return <code>true</code> if so; <code>false</code> otherwise
1019:             * @exception SQLException if a database access error occurs
1020:             */
1021:            public boolean supportsAlterTableWithAddColumn()
1022:                    throws SQLException {
1023:                return true;
1024:            }
1025:
1026:            /**
1027:             * Retrieves whether this database supports <code>ALTER TABLE</code>
1028:             * with drop column. <p>
1029:             *
1030:             * <!-- start release-specific documentation -->
1031:             * <div class="ReleaseSpecificDocumentation">
1032:             * <h3>HSQLDB-Specific Information:</h3> <p>
1033:             *
1034:             * From 1.7.0, HSQLDB supports this type of
1035:             * <code>ALTER TABLE</code> statement; this method always
1036:             * returns <code>true</code>.
1037:             * </div>
1038:             * <!-- end release-specific documentation -->
1039:             * @return <code>true</code> if so; <code>false</code> otherwise
1040:             * @exception SQLException if a database access error occurs
1041:             */
1042:            public boolean supportsAlterTableWithDropColumn()
1043:                    throws SQLException {
1044:                return true;
1045:            }
1046:
1047:            /**
1048:             * Retrieves whether this database supports column aliasing.
1049:             *
1050:             * <P>If so, the SQL AS clause can be used to provide names for
1051:             * computed columns or to provide alias names for columns as
1052:             * required. <p>
1053:             *
1054:             * <!-- start release-specific documentation -->
1055:             * <div class="ReleaseSpecificDocumentation">
1056:             * <h3>HSQLDB-Specific Information:</h3> <p>
1057:             *
1058:             * HSQLDB supports column aliasing; this method always
1059:             * returns <code>true</code>.
1060:             * </div>
1061:             * <!-- end release-specific documentation -->
1062:             *
1063:             *
1064:             * @return <code>true</code> if so; <code>false</code> otherwise
1065:             * @exception SQLException if a database access error occurs
1066:             */
1067:            public boolean supportsColumnAliasing() throws SQLException {
1068:                return true;
1069:            }
1070:
1071:            /**
1072:             * Retrieves whether this database supports concatenations between
1073:             * <code>NULL</code> and non-<code>NULL</code> values being
1074:             * <code>NULL</code>. <p>
1075:             *
1076:             * <!-- start release-specific documentation -->
1077:             * <div class="ReleaseSpecificDocumentation">
1078:             * <h3>HSQLDB-Specific Information:</h3> <p>
1079:             *
1080:             * HSQLDB supports this; this method always
1081:             * returns <code>true</code>.
1082:             * </div>
1083:             * <!-- end release-specific documentation -->
1084:             *
1085:             *
1086:             * @return <code>true</code> if so; <code>false</code> otherwise
1087:             * @exception SQLException if a database access error occurs
1088:             */
1089:            public boolean nullPlusNonNullIsNull() throws SQLException {
1090:                return true;
1091:            }
1092:
1093:            /**
1094:             * Retrieves whether this database supports the <code>CONVERT</code>
1095:             * function between SQL types. <p>
1096:             *
1097:             * <!-- start release-specific documentation -->
1098:             * <div class="ReleaseSpecificDocumentation">
1099:             * <h3>HSQLDB-Specific Information:</h3> <p>
1100:             *
1101:             * HSQLDB supports conversions; this method always
1102:             * returns <code>true</code>.
1103:             * </div>
1104:             * <!-- end release-specific documentation -->
1105:             *
1106:             *
1107:             * @return <code>true</code> if so; <code>false</code> otherwise
1108:             * @exception SQLException if a database access error occurs
1109:             */
1110:            public boolean supportsConvert() throws SQLException {
1111:                return true;
1112:            }
1113:
1114:            // fredt@users - JD comment - I think this is unsupported at the moment
1115:            // because SQL92 says conversion is implementation dependent, so if
1116:            // conversion from DOUBLE to INTEGER were possbible we would return the
1117:            // whole number part, but we currently throw. I'm not so sure about
1118:            // conversions between string and numeric where it is logically possible
1119:            // only if the string represents a numeric value
1120:
1121:            /**
1122:             * Retrieves whether this database supports the <code>CONVERT</code>
1123:             * for two given SQL types. <p>
1124:             *
1125:             * <!-- start release-specific documentation -->
1126:             * <div class="ReleaseSpecificDocumentation">
1127:             * <h3>HSQLDB-Specific Information:</h3> <p>
1128:             *
1129:             * HSQLDB supports conversion though String intermediates, so everything
1130:             * should be possible, short of number format errors (all Java objects
1131:             * have a toString method); this method always returns <code>true</code>.
1132:             * </div>
1133:             * <!-- end release-specific documentation -->
1134:             *
1135:             *
1136:             * @param fromType the type to convert from; one of the type codes from
1137:             *       the class <code>java.sql.Types</code>
1138:             * @param toType the type to convert to; one of the type codes from
1139:             *       the class <code>java.sql.Types</code>
1140:             * @return <code>true</code> if so; <code>false</code> otherwise
1141:             * @exception SQLException if a database access error occurs
1142:             * @see java.sql.Types
1143:             */
1144:            public boolean supportsConvert(int fromType, int toType)
1145:                    throws SQLException {
1146:                return true;
1147:            }
1148:
1149:            /**
1150:             * Retrieves whether this database supports table correlation names. <p>
1151:             *
1152:             * <!-- start release-specific documentation -->
1153:             * <div class="ReleaseSpecificDocumentation">
1154:             * <h3>HSQLDB-Specific Information:</h3> <p>
1155:             *
1156:             * HSQLDB supports table correlation names; this method always
1157:             * returns <code>true</code>.
1158:             * </div>
1159:             * <!-- end release-specific documentation -->
1160:             *
1161:             *
1162:             * @return <code>true</code> if so; <code>false</code> otherwise
1163:             * @exception SQLException if a database access error occurs
1164:             */
1165:            public boolean supportsTableCorrelationNames() throws SQLException {
1166:                return true;
1167:            }
1168:
1169:            /**
1170:             * Retrieves whether, when table correlation names are supported, they
1171:             * are restricted to being different from the names of the tables. <p>
1172:             *
1173:             * <!-- start release-specific documentation -->
1174:             * <div class="ReleaseSpecificDocumentation">
1175:             * <h3>HSQLDB-Specific Information:</h3> <p>
1176:             *
1177:             * HSQLDB requires that table correlation names are different from the
1178:             * names of the tables; this method always returns <code>true</code>.
1179:             * </div>
1180:             * <!-- end release-specific documentation -->
1181:             *
1182:             *
1183:             * @return <code>true</code> if so; <code>false</code> otherwise
1184:             * @exception SQLException if a database access error occurs
1185:             */
1186:            public boolean supportsDifferentTableCorrelationNames()
1187:                    throws SQLException {
1188:                return true;
1189:            }
1190:
1191:            /**
1192:             * Retrieves whether this database supports expressions in
1193:             * <code>ORDER BY</code> lists. <p>
1194:             *
1195:             * <!-- start release-specific documentation -->
1196:             * <div class="ReleaseSpecificDocumentation">
1197:             * <h3>HSQLDB-Specific Information:</h3> <p>
1198:             *
1199:             * HSQLDB supports expressions in <code>ORDER BY</code> lists; this
1200:             * method always returns <code>true</code>.
1201:             * </div>
1202:             * <!-- end release-specific documentation -->
1203:             *
1204:             *
1205:             * @return <code>true</code> if so; <code>false</code> otherwise
1206:             * @exception SQLException if a database access error occurs
1207:             */
1208:            public boolean supportsExpressionsInOrderBy() throws SQLException {
1209:                return true;
1210:            }
1211:
1212:            /**
1213:             * Retrieves whether this database supports using a column that is
1214:             * not in the <code>SELECT</code> statement in an
1215:             * <code>ORDER BY</code> clause. <p>
1216:             *
1217:             * <!-- start release-specific documentation -->
1218:             * <div class="ReleaseSpecificDocumentation">
1219:             * <h3>HSQLDB-Specific Information:</h3> <p>
1220:             *
1221:             * HSQLDB supports using a column that is not in the <code>SELECT</code>
1222:             * statement in an <code>ORDER BY</code> clause; this method always
1223:             * returns <code>true</code>.
1224:             * </div>
1225:             * <!-- end release-specific documentation -->
1226:             *
1227:             *
1228:             * @return <code>true</code> if so; <code>false</code> otherwise
1229:             * @exception SQLException if a database access error occurs
1230:             */
1231:            public boolean supportsOrderByUnrelated() throws SQLException {
1232:                return true;
1233:            }
1234:
1235:            /**
1236:             * Retrieves whether this database supports some form of
1237:             * <code>GROUP BY</code> clause. <p>
1238:             *
1239:             * <!-- start release-specific documentation -->
1240:             * <div class="ReleaseSpecificDocumentation">
1241:             * <h3>HSQLDB-Specific Information:</h3> <p>
1242:             *
1243:             * HSQLDB supports using the <code>GROUP BY</code> clause; this method
1244:             * always returns <code>true</code>.
1245:             * </div>
1246:             * <!-- end release-specific documentation -->
1247:             *
1248:             *
1249:             * @return <code>true</code> if so; <code>false</code> otherwise
1250:             * @exception SQLException if a database access error occurs
1251:             */
1252:            public boolean supportsGroupBy() throws SQLException {
1253:                return true;
1254:            }
1255:
1256:            /**
1257:             * Retrieves whether this database supports using a column that is
1258:             * not in the <code>SELECT</code> statement in a
1259:             * <code>GROUP BY</code> clause. <p>
1260:             *
1261:             * <!-- start release-specific documentation -->
1262:             * <div class="ReleaseSpecificDocumentation">
1263:             * <h3>HSQLDB-Specific Information:</h3> <p>
1264:             *
1265:             * HSQLDB supports using a column that is
1266:             * not in the <code>SELECT</code> statement in a
1267:             * <code>GROUP BY</code> clause; this method
1268:             * always returns <code>true</code>.
1269:             * </div>
1270:             * <!-- end release-specific documentation -->
1271:             *
1272:             *
1273:             * @return <code>true</code> if so; <code>false</code> otherwise
1274:             * @exception SQLException if a database access error occurs
1275:             */
1276:            public boolean supportsGroupByUnrelated() throws SQLException {
1277:                return true;
1278:            }
1279:
1280:            /**
1281:             * Retrieves whether this database supports using columns not included in
1282:             * the <code>SELECT</code> statement in a <code>GROUP BY</code> clause
1283:             * provided that all of the columns in the <code>SELECT</code> statement
1284:             * are included in the <code>GROUP BY</code> clause. <p>
1285:             *
1286:             * <!-- start release-specific documentation -->
1287:             * <div class="ReleaseSpecificDocumentation">
1288:             * <h3>HSQLDB-Specific Information:</h3> <p>
1289:             *
1290:             * HSQLDB supports using columns not included in
1291:             * the <code>SELECT</code> statement in a <code>GROUP BY</code> clause
1292:             * provided that all of the columns in the <code>SELECT</code> statement
1293:             * are included in the <code>GROUP BY</code> clause; this method
1294:             * always returns <code>true</code>.
1295:             * </div>
1296:             * <!-- end release-specific documentation -->
1297:             *
1298:             *
1299:             * @return <code>true</code> if so; <code>false</code> otherwise
1300:             * @exception SQLException if a database access error occurs
1301:             */
1302:            public boolean supportsGroupByBeyondSelect() throws SQLException {
1303:                return true;
1304:            }
1305:
1306:            /**
1307:             * Retrieves whether this database supports specifying a
1308:             * <code>LIKE</code> escape clause. <p>
1309:             *
1310:             * <!-- start release-specific documentation -->
1311:             * <div class="ReleaseSpecificDocumentation">
1312:             * <h3>HSQLDB-Specific Information:</h3> <p>
1313:             *
1314:             * HSQLDB supports specifying a
1315:             * <code>LIKE</code> escape clause; this method
1316:             * always returns <code>true</code>.
1317:             * </div>
1318:             * <!-- end release-specific documentation -->
1319:             *
1320:             *
1321:             * @return <code>true</code> if so; <code>false</code> otherwise
1322:             * @exception SQLException if a database access error occurs
1323:             */
1324:            public boolean supportsLikeEscapeClause() throws SQLException {
1325:                return true;
1326:            }
1327:
1328:            /**
1329:             * Retrieves whether this database supports getting multiple
1330:             * <code>ResultSet</code> objects from a single call to the
1331:             * method <code>execute</code>. <p>
1332:             *
1333:             * <!-- start release-specific documentation -->
1334:             * <div class="ReleaseSpecificDocumentation">
1335:             * <h3>HSQLDB-Specific Information:</h3> <p>
1336:             *
1337:             * Up to and including 1.7.2, HSQLDB does not support getting multiple
1338:             * <code>ResultSet</code> objects from a single call to the
1339:             * method <code>execute</code>; this method
1340:             * always returns <code>false</code>. <p>
1341:             *
1342:             * This behaviour <i>may</i> change in a future release.
1343:             * </div>
1344:             * <!-- end release-specific documentation -->
1345:             * @return <code>true</code> if so; <code>false</code> otherwise
1346:             * @exception SQLException if a database access error occurs
1347:             */
1348:            public boolean supportsMultipleResultSets() throws SQLException {
1349:                return false;
1350:            }
1351:
1352:            /**
1353:             * Retrieves whether this database allows having multiple
1354:             * transactions open at once (on different connections). <p>
1355:             *
1356:             * <!-- start release-specific documentation -->
1357:             * <div class="ReleaseSpecificDocumentation">
1358:             * <h3>HSQLDB-Specific Information:</h3> <p>
1359:             *
1360:             * HSQLDB allows having multiple
1361:             * transactions open at once (on different connections); this method
1362:             * always returns <code>true</code>.
1363:             * </div>
1364:             * <!-- end release-specific documentation -->
1365:             *
1366:             *
1367:             * @return <code>true</code> if so; <code>false</code> otherwise
1368:             * @exception SQLException if a database access error occurs
1369:             */
1370:            public boolean supportsMultipleTransactions() throws SQLException {
1371:                return true;
1372:            }
1373:
1374:            /**
1375:             * Retrieves whether columns in this database may be defined as
1376:             * non-nullable. <p>
1377:             *
1378:             * <!-- start release-specific documentation -->
1379:             * <div class="ReleaseSpecificDocumentation">
1380:             * <h3>HSQLDB-Specific Information:</h3> <p>
1381:             *
1382:             * HSQLDB supports the specification of non-nullable columns; this method
1383:             * always returns <code>true</code>.
1384:             * </div>
1385:             * <!-- end release-specific documentation -->
1386:             *
1387:             *
1388:             * @return <code>true</code> if so; <code>false</code> otherwise
1389:             * @exception SQLException if a database access error occurs
1390:             */
1391:            public boolean supportsNonNullableColumns() throws SQLException {
1392:                return true;
1393:            }
1394:
1395:            /**
1396:             * Retrieves whether this database supports the ODBC Minimum SQL grammar. <p>
1397:             *
1398:             * <!-- start release-specific documentation -->
1399:             * <div class="ReleaseSpecificDocumentation">
1400:             * <h3>HSQLDB-Specific Information:</h3> <p>
1401:             *
1402:             * Up to and including 1.7.2, HSQLDB does not support the ODBC
1403:             * Minimum SQL grammar; this method
1404:             * always returns <code>false</code>.
1405:             * </div>
1406:             * <!-- end release-specific documentation -->
1407:             * @return <code>true</code> if so; <code>false</code> otherwise
1408:             * @exception SQLException if a database access error occurs
1409:             */
1410:            public boolean supportsMinimumSQLGrammar() throws SQLException {
1411:                return false;
1412:            }
1413:
1414:            /**
1415:             * Retrieves whether this database supports the ODBC Core SQL grammar. <p>
1416:             *
1417:             * <!-- start release-specific documentation -->
1418:             * <div class="ReleaseSpecificDocumentation">
1419:             * <h3>HSQLDB-Specific Information:</h3> <p>
1420:             *
1421:             * From 1.7.2 this method always returns <code>true</code>.
1422:             * </div>
1423:             * <!-- end release-specific documentation -->
1424:             * @return <code>true</code> if so; <code>false</code> otherwise
1425:             * @exception SQLException if a database access error occurs
1426:             */
1427:            public boolean supportsCoreSQLGrammar() throws SQLException {
1428:                return true;
1429:            }
1430:
1431:            /**
1432:             * Retrieves whether this database supports the ODBC Extended SQL grammar. <p>
1433:             *
1434:             * <!-- start release-specific documentation -->
1435:             * <div class="ReleaseSpecificDocumentation">
1436:             * <h3>HSQLDB-Specific Information:</h3> <p>
1437:             *
1438:             * Up to and including 1.7.2, HSQLDB does not support the ODBC
1439:             * Extended SQL grammar; this method
1440:             * always returns <code>false</code>.
1441:             * </div>
1442:             * <!-- end release-specific documentation -->
1443:             * @return <code>true</code> if so; <code>false</code> otherwise
1444:             * @exception SQLException if a database access error occurs
1445:             */
1446:            public boolean supportsExtendedSQLGrammar() throws SQLException {
1447:                return false;
1448:            }
1449:
1450:            /**
1451:             * Retrieves whether this database supports the ANSI92 entry level SQL
1452:             * grammar. <p>
1453:             *
1454:             * <!-- start release-specific documentation -->
1455:             * <div class="ReleaseSpecificDocumentation">
1456:             * <h3>HSQLDB-Specific Information:</h3> <p>
1457:             *
1458:             * Up to and including 1.7.2, HSQLDB does not support the ANSI92 entry
1459:             * level SQL grammar; this method
1460:             * always returns <code>false</code>.
1461:             * </div>
1462:             * <!-- end release-specific documentation -->
1463:             * @return <code>true</code> if so; <code>false</code> otherwise
1464:             * @exception SQLException if a database access error occurs
1465:             */
1466:            public boolean supportsANSI92EntryLevelSQL() throws SQLException {
1467:                return false;
1468:            }
1469:
1470:            /**
1471:             * Retrieves whether this database supports the ANSI92 intermediate SQL
1472:             * grammar supported. <p>
1473:             *
1474:             * <!-- start release-specific documentation -->
1475:             * <div class="ReleaseSpecificDocumentation">
1476:             * <h3>HSQLDB-Specific Information:</h3> <p>
1477:             *
1478:             * Up to and including 1.7.2, HSQLDB does not support the ANSI92
1479:             * intermediate SQL grammar; this method always returns
1480:             * <code>false</code>.
1481:             * </div>
1482:             * <!-- end release-specific documentation -->
1483:             * @return <code>true</code> if so; <code>false</code> otherwise
1484:             * @exception SQLException if a database access error occurs
1485:             */
1486:            public boolean supportsANSI92IntermediateSQL() throws SQLException {
1487:                return false;
1488:            }
1489:
1490:            /**
1491:             * Retrieves whether this database supports the ANSI92 full SQL
1492:             * grammar supported. <p>
1493:             *
1494:             * <!-- start release-specific documentation -->
1495:             * <div class="ReleaseSpecificDocumentation">
1496:             * <h3>HSQLDB-Specific Information:</h3> <p>
1497:             *
1498:             * Up to and including 1.7.2, HSQLDB does not support the ANSI92
1499:             * full SQL grammar; this method always returns
1500:             * <code>false</code>.
1501:             * </div>
1502:             * <!-- end release-specific documentation -->
1503:             * @return <code>true</code> if so; <code>false</code> otherwise
1504:             * @exception SQLException if a database access error occurs
1505:             */
1506:            public boolean supportsANSI92FullSQL() throws SQLException {
1507:                return false;
1508:            }
1509:
1510:            // fredt@users 20030413 - return value change to support OpenOffice.org
1511:
1512:            /**
1513:             * Retrieves whether this database supports the SQL Integrity
1514:             * Enhancement Facility. <p>
1515:             *
1516:             * <!-- start release-specific documentation -->
1517:             * <div class="ReleaseSpecificDocumentation">
1518:             * <h3>HSQLDB-Specific Information:</h3> <p>
1519:             *
1520:             * From 1.7.2, this method always returns
1521:             * <code>true</code>.
1522:             * </div>
1523:             * <!-- end release-specific documentation -->
1524:             * @return <code>true</code> if so; <code>false</code> otherwise
1525:             * @exception SQLException if a database access error occurs
1526:             */
1527:            public boolean supportsIntegrityEnhancementFacility()
1528:                    throws SQLException {
1529:                return true;
1530:            }
1531:
1532:            /**
1533:             * Retrieves whether this database supports some form of outer join. <p>
1534:             *
1535:             * <!-- start release-specific documentation -->
1536:             * <div class="ReleaseSpecificDocumentation">
1537:             * <h3>HSQLDB-Specific Information:</h3> <p>
1538:             *
1539:             * HSQLDB supports outer joins; this method always returns
1540:             * <code>true</code>.
1541:             * </div>
1542:             * <!-- end release-specific documentation -->
1543:             *
1544:             *
1545:             * @return <code>true</code> if so; <code>false</code> otherwise
1546:             * @exception SQLException if a database access error occurs
1547:             */
1548:            public boolean supportsOuterJoins() throws SQLException {
1549:                return true;
1550:            }
1551:
1552:            /**
1553:             * Retrieves whether this database supports full nested outer joins. <p>
1554:             *
1555:             * <!-- start release-specific documentation -->
1556:             * <div class="ReleaseSpecificDocumentation">
1557:             * <h3>HSQLDB-Specific Information:</h3> <p>
1558:             *
1559:             * Up to and including 1.7.2, HSQLDB  does not support full nested outer
1560:             * joins; this method always returns <code>false</code>. <p>
1561:             *
1562:             * This behaviour may change in a future release.
1563:             * </div>
1564:             * <!-- end release-specific documentation -->
1565:             * @return <code>true</code> if so; <code>false</code> otherwise
1566:             * @exception SQLException if a database access error occurs
1567:             */
1568:            public boolean supportsFullOuterJoins() throws SQLException {
1569:                return false;
1570:            }
1571:
1572:            /**
1573:             * Retrieves whether this database provides limited support for outer
1574:             * joins.  (This will be <code>true</code> if the method
1575:             * <code>supportsFullOuterJoins</code> returns <code>true</code>). <p>
1576:             *
1577:             * <!-- start release-specific documentation -->
1578:             * <div class="ReleaseSpecificDocumentation">
1579:             * <h3>HSQLDB-Specific Information:</h3> <p>
1580:             *
1581:             * Up to and including 1.7.2, HSQLDB support the LEFT OUTER join syntax;
1582:             * this method always returns <code>true</code>.
1583:             * </div>
1584:             * <!-- end release-specific documentation -->
1585:             * @return <code>true</code> if so; <code>false</code> otherwise
1586:             * @exception SQLException if a database access error occurs
1587:             */
1588:            public boolean supportsLimitedOuterJoins() throws SQLException {
1589:                return true;
1590:            }
1591:
1592:            /**
1593:             * Retrieves the database vendor's preferred term for "schema". <p>
1594:             *
1595:             * <!-- start release-specific documentation -->
1596:             * <div class="ReleaseSpecificDocumentation">
1597:             * <h3>HSQLDB-Specific Information:</h3> <p>
1598:             *
1599:             * Starting with 1.8.0, HSQLDB provides support for schemas.
1600:             * </div>
1601:             * <!-- end release-specific documentation -->
1602:             * @return the vendor term for "schema"
1603:             * @exception SQLException if a database access error occurs
1604:             */
1605:            public String getSchemaTerm() throws SQLException {
1606:                return "SCHEMA";
1607:            }
1608:
1609:            /**
1610:             * Retrieves the database vendor's preferred term for "procedure". <p>
1611:             *
1612:             * <!-- start release-specific documentation -->
1613:             * <div class="ReleaseSpecificDocumentation">
1614:             * <h3>HSQLDB-Specific Information:</h3> <p>
1615:             *
1616:             * Up to and including 1.7.2, HSQLDB does not support declaration of
1617:             * functions or procedures directly in SQL but instead relies on the
1618:             * HSQLDB-specific CLASS grant mechanism to make public static
1619:             * Java methods available as SQL routines; this method always returns
1620:             * an empty <code>String</code>.
1621:             * </div>
1622:             * <!-- end release-specific documentation -->
1623:             * @return the vendor term for "procedure"
1624:             * @exception SQLException if a database access error occurs
1625:             */
1626:            public String getProcedureTerm() throws SQLException {
1627:                return "";
1628:            }
1629:
1630:            /**
1631:             * Retrieves the database vendor's preferred term for "catalog". <p>
1632:             *
1633:             * <!-- start release-specific documentation -->
1634:             * <div class="ReleaseSpecificDocumentation">
1635:             * <h3>HSQLDB-Specific Information:</h3> <p>
1636:             *
1637:             * Including 1.7.2, HSQLDB does not support catalogs in DDL or DML;
1638:             * this method <ewm>always</em> returns the empty String.
1639:             * </div>
1640:             * <!-- end release-specific documentation -->
1641:             *
1642:             * @return the vendor term for "catalog"
1643:             * @exception SQLException if a database access error occurs
1644:             */
1645:            public String getCatalogTerm() throws SQLException {
1646:                return "";
1647:            }
1648:
1649:            /**
1650:             * Retrieves whether a catalog appears at the start of a fully qualified
1651:             * table name.  If not, the catalog appears at the end. <p>
1652:             *
1653:             * <!-- start release-specific documentation -->
1654:             * <div class="ReleaseSpecificDocumentation">
1655:             * <h3>HSQLDB-Specific Information:</h3> <p>
1656:             *
1657:             * Up to and including 1.7.2, HSQLDB does not support catalogs in DDL or DML;
1658:             * this method always returns <code>false</code>.
1659:             * </div>
1660:             * <!-- end release-specific documentation -->
1661:             * @return <code>true</code> if the catalog name appears at the beginning
1662:             *        of a fully qualified table name; <code>false</code> otherwise
1663:             * @exception SQLException if a database access error occurs
1664:             */
1665:            public boolean isCatalogAtStart() throws SQLException {
1666:                return false;
1667:            }
1668:
1669:            /**
1670:             * Retrieves the <code>String</code> that this database uses as the
1671:             * separator between a catalog and table name. <p>
1672:             *
1673:             * <!-- start release-specific documentation -->
1674:             * <div class="ReleaseSpecificDocumentation">
1675:             * <h3>HSQLDB-Specific Information:</h3> <p>
1676:             *
1677:             * Including 1.7.2, HSQLDB does not support catalogs in DDL or DML;
1678:             * this method <em>always</em> returns an empty <code>String</code>.
1679:             * </div>
1680:             * <!-- end release-specific documentation -->
1681:             *
1682:             * @return the separator string
1683:             * @exception SQLException if a database access error occurs
1684:             */
1685:            public String getCatalogSeparator() throws SQLException {
1686:                return "";
1687:            }
1688:
1689:            /**
1690:             * Retrieves whether a schema name can be used in a data
1691:             * manipulation statement. <p>
1692:             *
1693:             * <!-- start release-specific documentation -->
1694:             * <div class="ReleaseSpecificDocumentation">
1695:             * <h3>HSQLDB-Specific Information:</h3> <p>
1696:             *
1697:             * In 1.8.0, HSQLDB supports schemas in table names but not in column names;
1698:             * this method always returns <code>false</code>.
1699:             *
1700:             * </div>
1701:             * <!-- end release-specific documentation -->
1702:             * @return <code>true</code> if so; <code>false</code> otherwise
1703:             * @exception SQLException if a database access error occurs
1704:             */
1705:            public boolean supportsSchemasInDataManipulation()
1706:                    throws SQLException {
1707:
1708:                // false for OOo client server compatibility
1709:                // otherwise schema name is used by OOo in column references
1710:                return false;
1711:            }
1712:
1713:            /**
1714:             * Retrieves whether a schema name can be used in a procedure call
1715:             * statement. <p>
1716:             *
1717:             * <!-- start release-specific documentation -->
1718:             * <div class="ReleaseSpecificDocumentation">
1719:             * <h3>HSQLDB-Specific Information:</h3> <p>
1720:             *
1721:             * Up to and including 1.7.2, HSQLDB does not support schema-qualified
1722:             * procedure identifiers; this method always returns <code>false</code>.
1723:             * </div>
1724:             * <!-- end release-specific documentation -->
1725:             * @return <code>true</code> if so; <code>false</code> otherwise
1726:             * @exception SQLException if a database access error occurs
1727:             */
1728:            public boolean supportsSchemasInProcedureCalls()
1729:                    throws SQLException {
1730:                return false;
1731:            }
1732:
1733:            /**
1734:             * Retrieves whether a schema name can be used in a table
1735:             * definition statement. <p>
1736:             *
1737:             * <!-- start release-specific documentation -->
1738:             * <div class="ReleaseSpecificDocumentation">
1739:             * <h3>HSQLDB-Specific Information:</h3> <p>
1740:             *
1741:             * In 1.8.0, HSQLDB supports schemas;
1742:             * By default, this method returns <code>true</code>.
1743:             *
1744:             * </div>
1745:             * <!-- end release-specific documentation -->
1746:             * @return <code>true</code> if so; <code>false</code> otherwise
1747:             * @exception SQLException if a database access error occurs
1748:             */
1749:            public boolean supportsSchemasInTableDefinitions()
1750:                    throws SQLException {
1751:                return !useSchemaDefault;
1752:            }
1753:
1754:            /**
1755:             * Retrieves whether a schema name can be used in an index
1756:             * definition statement. <p>
1757:             *
1758:             * <!-- start release-specific documentation -->
1759:             * <div class="ReleaseSpecificDocumentation">
1760:             * <h3>HSQLDB-Specific Information:</h3> <p>
1761:             *
1762:             * In 1.8.0, HSQLDB supports schemas;
1763:             * By default, this method returns <code>true</code>.
1764:             *
1765:             * </div>
1766:             * <!-- end release-specific documentation -->
1767:             * @return <code>true</code> if so; <code>false</code> otherwise
1768:             * @exception SQLException if a database access error occurs
1769:             */
1770:            public boolean supportsSchemasInIndexDefinitions()
1771:                    throws SQLException {
1772:                return !useSchemaDefault;
1773:            }
1774:
1775:            /**
1776:             * Retrieves whether a schema name can be used in a privilege
1777:             * definition statement. <p>
1778:             *
1779:             * <!-- start release-specific documentation -->
1780:             * <div class="ReleaseSpecificDocumentation">
1781:             * <h3>HSQLDB-Specific Information:</h3> <p>
1782:             *
1783:             * In 1.8.0, HSQLDB supports schemas;
1784:             * By default, this method returns <code>true</code>.
1785:             *
1786:             * </div>
1787:             * <!-- end release-specific documentation -->
1788:             * @return <code>true</code> if so; <code>false</code> otherwise
1789:             * @exception SQLException if a database access error occurs
1790:             */
1791:            public boolean supportsSchemasInPrivilegeDefinitions()
1792:                    throws SQLException {
1793:                return !useSchemaDefault;
1794:            }
1795:
1796:            /**
1797:             * Retrieves whether a catalog name can be used in a data
1798:             * manipulation statement. <p>
1799:             *
1800:             * <!-- start release-specific documentation -->
1801:             * <div class="ReleaseSpecificDocumentation">
1802:             * <h3>HSQLDB-Specific Information:</h3> <p>
1803:             *
1804:             * Up to and including 1.7.2, HSQLDB does not support catalog-qualified;
1805:             * data manipulation; this method always returns <code>false</code>.
1806:             * </div>
1807:             * <!-- end release-specific documentation -->
1808:             * @return <code>true</code> if so; <code>false</code> otherwise
1809:             * @exception SQLException if a database access error occurs
1810:             */
1811:            public boolean supportsCatalogsInDataManipulation()
1812:                    throws SQLException {
1813:                return false;
1814:            }
1815:
1816:            /**
1817:             * Retrieves whether a catalog name can be used in a
1818:             * procedure call statement. <p>
1819:             *
1820:             * <!-- start release-specific documentation -->
1821:             * <div class="ReleaseSpecificDocumentation">
1822:             * <h3>HSQLDB-Specific Information:</h3> <p>
1823:             *
1824:             * Up to and including 1.7.2, HSQLDB does not support catalog-qualified
1825:             * procedure calls; this method always returns <code>false</code>.
1826:             * </div>
1827:             * <!-- end release-specific documentation -->
1828:             * @return <code>true</code> if so; <code>false</code> otherwise
1829:             * @exception SQLException if a database access error occurs
1830:             */
1831:            public boolean supportsCatalogsInProcedureCalls()
1832:                    throws SQLException {
1833:                return false;
1834:            }
1835:
1836:            /**
1837:             * Retrieves whether a catalog name can be used in a
1838:             * table definition statement. <p>
1839:             *
1840:             * <!-- start release-specific documentation -->
1841:             * <div class="ReleaseSpecificDocumentation">
1842:             * <h3>HSQLDB-Specific Information:</h3> <p>
1843:             *
1844:             * Up to and including 1.7.2, HSQLDB does not support catalog-qualified
1845:             * table definitions; this method always returns <code>false</code>.
1846:             * </div>
1847:             * <!-- end release-specific documentation -->
1848:             * @return <code>true</code> if so; <code>false</code> otherwise
1849:             * @exception SQLException if a database access error occurs
1850:             */
1851:            public boolean supportsCatalogsInTableDefinitions()
1852:                    throws SQLException {
1853:                return false;
1854:            }
1855:
1856:            /**
1857:             * Retrieves whether a catalog name can be used in an
1858:             * index definition statement. <p>
1859:             *
1860:             * <!-- start release-specific documentation -->
1861:             * <div class="ReleaseSpecificDocumentation">
1862:             * <h3>HSQLDB-Specific Information:</h3> <p>
1863:             *
1864:             * Up to and including 1.7.2, HSQLDB does not support catalog-qualified
1865:             * index definitions; this method always returns <code>false</code>.
1866:             * </div>
1867:             * <!-- end release-specific documentation -->
1868:             * @return <code>true</code> if so; <code>false</code> otherwise
1869:             * @exception SQLException if a database access error occurs
1870:             */
1871:            public boolean supportsCatalogsInIndexDefinitions()
1872:                    throws SQLException {
1873:                return false;
1874:            }
1875:
1876:            /**
1877:             * Retrieves whether a catalog name can be used in a
1878:             * privilege definition statement.  <p>
1879:             *
1880:             * <!-- start release-specific documentation -->
1881:             * <div class="ReleaseSpecificDocumentation">
1882:             * <h3>HSQLDB-Specific Information:</h3> <p>
1883:             *
1884:             * Up to and including 1.7.2, HSQLDB does not support catalog-qualified
1885:             * privilege definitions; this method always returns <code>false</code>.
1886:             * </div>
1887:             * <!-- end release-specific documentation -->
1888:             * @return <code>true</code> if so; <code>false</code> otherwise
1889:             * @exception SQLException if a database access error occurs
1890:             */
1891:            public boolean supportsCatalogsInPrivilegeDefinitions()
1892:                    throws SQLException {
1893:                return false;
1894:            }
1895:
1896:            /**
1897:             * Retrieves whether this database supports positioned <code>DELETE</code>
1898:             * statements. <p>
1899:             *
1900:             * <!-- start release-specific documentation -->
1901:             * <div class="ReleaseSpecificDocumentation">
1902:             * <h3>HSQLDB-Specific Information:</h3> <p>
1903:             *
1904:             * Up to and including 1.7.2, HSQLDB does not support updateable
1905:             * result sets; this method always returns <code>false</code>.
1906:             * </div>
1907:             * <!-- end release-specific documentation -->
1908:             * @return <code>true</code> if so; <code>false</code> otherwise
1909:             * @exception SQLException if a database access error occurs
1910:             */
1911:            public boolean supportsPositionedDelete() throws SQLException {
1912:                return false;
1913:            }
1914:
1915:            /**
1916:             * Retrieves whether this database supports positioned <code>UPDATE</code>
1917:             * statements. <p>
1918:             *
1919:             * <!-- start release-specific documentation -->
1920:             * <div class="ReleaseSpecificDocumentation">
1921:             * <h3>HSQLDB-Specific Information:</h3> <p>
1922:             *
1923:             * Up to and including 1.7.2, HSQLDB does not support updateable
1924:             * result sets; this method always returns <code>false</code>.
1925:             * </div>
1926:             * <!-- end release-specific documentation -->
1927:             * @return <code>true</code> if so; <code>false</code> otherwise
1928:             * @exception SQLException if a database access error occurs
1929:             */
1930:            public boolean supportsPositionedUpdate() throws SQLException {
1931:                return false;
1932:            }
1933:
1934:            /**
1935:             * Retrieves whether this database supports <code>SELECT FOR UPDATE</code>
1936:             * statements. <p>
1937:             *
1938:             * <!-- start release-specific documentation -->
1939:             * <div class="ReleaseSpecificDocumentation">
1940:             * <h3>HSQLDB-Specific Information:</h3> <p>
1941:             *
1942:             * Up to and including 1.7.2, HSQLDB does not support explicit locking;
1943:             * this method always returns <code>false</code>.
1944:             * </div>
1945:             * <!-- end release-specific documentation -->
1946:             * @return <code>true</code> if so; <code>false</code> otherwise
1947:             * @exception SQLException if a database access error occurs
1948:             */
1949:            public boolean supportsSelectForUpdate() throws SQLException {
1950:                return false;
1951:            }
1952:
1953:            /**
1954:             * Retrieves whether this database supports stored procedure calls
1955:             * that use the stored procedure escape syntax. <p>
1956:             *
1957:             * <!-- start release-specific documentation -->
1958:             * <div class="ReleaseSpecificDocumentation">
1959:             * <h3>HSQLDB-Specific Information:</h3> <p>
1960:             *
1961:             * Up to and including 1.7.2, HSQLDB supports calling public static
1962:             * Java methods in the context of SQL Stored Procedures; this method
1963:             * always returns <code>true</code>.
1964:             * </div>
1965:             * <!-- end release-specific documentation -->
1966:             * @return <code>true</code> if so; <code>false</code> otherwise
1967:             * @exception SQLException if a database access error occurs
1968:             * @see jdbcPreparedStatement
1969:             * @see jdbcConnection#prepareCall
1970:             */
1971:            public boolean supportsStoredProcedures() throws SQLException {
1972:                return true;
1973:            }
1974:
1975:            /**
1976:             * Retrieves whether this database supports subqueries in comparison
1977:             * expressions. <p>
1978:             *
1979:             * <!-- start release-specific documentation -->
1980:             * <div class="ReleaseSpecificDocumentation">
1981:             * <h3>HSQLDB-Specific Information:</h3> <p>
1982:             *
1983:             * HSQLDB has always supported subqueries in comparison expressions;
1984:             * this method always returns <code>true</code>.
1985:             * </div>
1986:             * <!-- end release-specific documentation -->
1987:             *
1988:             *
1989:             * @return <code>true</code> if so; <code>false</code> otherwise
1990:             * @exception SQLException if a database access error occurs
1991:             */
1992:            public boolean supportsSubqueriesInComparisons()
1993:                    throws SQLException {
1994:                return true;
1995:            }
1996:
1997:            /**
1998:             * Retrieves whether this database supports subqueries in
1999:             * <code>EXISTS</code> expressions. <p>
2000:             *
2001:             * <!-- start release-specific documentation -->
2002:             * <div class="ReleaseSpecificDocumentation">
2003:             * <h3>HSQLDB-Specific Information:</h3> <p>
2004:             *
2005:             * HSQLDB has always supported subqueries in <code>EXISTS</code>
2006:             * expressions; this method always returns <code>true</code>.
2007:             * </div>
2008:             * <!-- end release-specific documentation -->
2009:             *
2010:             *
2011:             * @return <code>true</code> if so; <code>false</code> otherwise
2012:             * @exception SQLException if a database access error occurs
2013:             */
2014:            public boolean supportsSubqueriesInExists() throws SQLException {
2015:                return true;
2016:            }
2017:
2018:            /**
2019:             * JDBC4 correction: Retrieves whether this database supports subqueries in
2020:             * <code>IN</code> expressions. <p>
2021:             *
2022:             * <!-- start release-specific documentation -->
2023:             * <div class="ReleaseSpecificDocumentation">
2024:             * <h3>HSQLDB-Specific Information:</h3> <p>
2025:             *
2026:             * HSQLDB has always supported subqueries in <code>IN</code>
2027:             * statements; this method always returns <code>true</code>.
2028:             * </div>
2029:             * <!-- end release-specific documentation -->
2030:             *
2031:             *
2032:             * @return <code>true</code> if so; <code>false</code> otherwise
2033:             * @exception SQLException if a database access error occurs
2034:             */
2035:            public boolean supportsSubqueriesInIns() throws SQLException {
2036:                return true;
2037:            }
2038:
2039:            /**
2040:             * Retrieves whether this database supports subqueries in quantified
2041:             * expressions. <p>
2042:             *
2043:             * <!-- start release-specific documentation -->
2044:             * <div class="ReleaseSpecificDocumentation">
2045:             * <h3>HSQLDB-Specific Information:</h3> <p>
2046:             *
2047:             * HSQLDB has always supported subqueries in quantified
2048:             * expressions; this method always returns <code>true</code>.
2049:             * </div>
2050:             * <!-- end release-specific documentation -->
2051:             *
2052:             *
2053:             * @return <code>true</code> if so; <code>false</code> otherwise
2054:             * @exception SQLException if a database access error occurs
2055:             */
2056:            public boolean supportsSubqueriesInQuantifieds()
2057:                    throws SQLException {
2058:                return true;
2059:            }
2060:
2061:            /**
2062:             * Retrieves whether this database supports correlated subqueries. <p>
2063:             *
2064:             * <!-- start release-specific documentation -->
2065:             * <div class="ReleaseSpecificDocumentation">
2066:             * <h3>HSQLDB-Specific Information:</h3> <p>
2067:             *
2068:             * HSQLDB has always supported correlated subqueries;
2069:             * this method always returns <code>true</code>.
2070:             * </div>
2071:             * <!-- end release-specific documentation -->
2072:             *
2073:             *
2074:             * @return <code>true</code> if so; <code>false</code> otherwise
2075:             * @exception SQLException if a database access error occurs
2076:             */
2077:            public boolean supportsCorrelatedSubqueries() throws SQLException {
2078:                return true;
2079:            }
2080:
2081:            /**
2082:             * Retrieves whether this database supports SQL <code>UNION</code>. <p>
2083:             *
2084:             * <!-- start release-specific documentation -->
2085:             * <div class="ReleaseSpecificDocumentation">
2086:             * <h3>HSQLDB-Specific Information:</h3> <p>
2087:             *
2088:             * HSQLDB supports SQL <code>UNION</code>;
2089:             * this method always returns <code>true</code>.
2090:             * </div>
2091:             * <!-- end release-specific documentation -->
2092:             *
2093:             *
2094:             * @return <code>true</code> if so; <code>false</code> otherwise
2095:             * @exception SQLException if a database access error occurs
2096:             */
2097:            public boolean supportsUnion() throws SQLException {
2098:                return true;
2099:            }
2100:
2101:            /**
2102:             * Retrieves whether this database supports SQL <code>UNION ALL</code>. <p>
2103:             *
2104:             * <!-- start release-specific documentation -->
2105:             * <div class="ReleaseSpecificDocumentation">
2106:             * <h3>HSQLDB-Specific Information:</h3> <p>
2107:             *
2108:             * HSQLDB supports SQL <code>UNION ALL</code>;
2109:             * this method always returns <code>true</code>.
2110:             * </div>
2111:             * <!-- end release-specific documentation -->
2112:             *
2113:             *
2114:             * @return <code>true</code> if so; <code>false</code> otherwise
2115:             * @exception SQLException if a database access error occurs
2116:             */
2117:            public boolean supportsUnionAll() throws SQLException {
2118:                return true;
2119:            }
2120:
2121:            /**
2122:             * Retrieves whether this database supports keeping cursors open
2123:             * across commits. <p>
2124:             *
2125:             * <!-- start release-specific documentation -->
2126:             * <div class="ReleaseSpecificDocumentation">
2127:             * <h3>HSQLDB-Specific Information:</h3> <p>
2128:             *
2129:             * Up to and including 1.7.2, HSQLDB does not support keeping
2130:             * cursors open across commits; this method always returns
2131:             * <code>false</code>.
2132:             * </div>
2133:             * <!-- end release-specific documentation -->
2134:             * @return <code>true</code> if cursors always remain open;
2135:             *      <code>false</code> if they might not remain open
2136:             * @exception SQLException if a database access error occurs
2137:             */
2138:            public boolean supportsOpenCursorsAcrossCommit()
2139:                    throws SQLException {
2140:                return false;
2141:            }
2142:
2143:            /**
2144:             * Retrieves whether this database supports keeping cursors open
2145:             * across rollbacks. <p>
2146:             *
2147:             * <!-- start release-specific documentation -->
2148:             * <div class="ReleaseSpecificDocumentation">
2149:             * <h3>HSQLDB-Specific Information:</h3> <p>
2150:             *
2151:             * Up to and including 1.7.2, HSQLDB does not support keeping
2152:             * cursors open across rollbacks;
2153:             * this method always returns <code>false</code>.
2154:             * </div>
2155:             * <!-- end release-specific documentation -->
2156:             * @return <code>true</code> if cursors always remain open;
2157:             *      <code>false</code> if they might not remain open
2158:             * @exception SQLException if a database access error occurs
2159:             */
2160:            public boolean supportsOpenCursorsAcrossRollback()
2161:                    throws SQLException {
2162:                return false;
2163:            }
2164:
2165:            /**
2166:             * Retrieves whether this database supports keeping statements open
2167:             * across commits. <p>
2168:             *
2169:             * <!-- start release-specific documentation -->
2170:             * <div class="ReleaseSpecificDocumentation">
2171:             * <h3>HSQLDB-Specific Information:</h3> <p>
2172:             *
2173:             * HSQLDB supports keeping statements open
2174:             * across commits;
2175:             * this method always returns <code>true</code>.
2176:             * </div>
2177:             * <!-- end release-specific documentation -->
2178:             *
2179:             *
2180:             * @return <code>true</code> if statements always remain open;
2181:             *      <code>false</code> if they might not remain open
2182:             * @exception SQLException if a database access error occurs
2183:             */
2184:            public boolean supportsOpenStatementsAcrossCommit()
2185:                    throws SQLException {
2186:                return true;
2187:            }
2188:
2189:            /**
2190:             * Retrieves whether this database supports keeping statements open
2191:             * across rollbacks. <p>
2192:             *
2193:             * <!-- start release-specific documentation -->
2194:             * <div class="ReleaseSpecificDocumentation">
2195:             * <h3>HSQLDB-Specific Information:</h3> <p>
2196:             *
2197:             * HSQLDB supports keeping statements open
2198:             * across commits;
2199:             * this method always returns <code>true</code>.
2200:             * </div>
2201:             * <!-- end release-specific documentation -->
2202:             *
2203:             *
2204:             * @return <code>true</code> if statements always remain open;
2205:             *      <code>false</code> if they might not remain open
2206:             * @exception SQLException if a database access error occurs
2207:             */
2208:            public boolean supportsOpenStatementsAcrossRollback()
2209:                    throws SQLException {
2210:                return true;
2211:            }
2212:
2213:            //----------------------------------------------------------------------
2214:            // The following group of methods exposes various limitations
2215:            // based on the target database with the current driver.
2216:            // Unless otherwise specified, a result of zero means there is no
2217:            // limit, or the limit is not known.
2218:
2219:            /**
2220:             * Retrieves the maximum number of hex characters this database allows in an
2221:             * inline binary literal. <p>
2222:             *
2223:             * <!-- start release-specific documentation -->
2224:             * <div class="ReleaseSpecificDocumentation">
2225:             * <h3>HSQLDB-Specific Information:</h3> <p>
2226:             *
2227:             * HSQLDB does not impose a "known" limit.  The hard limit is the maximum
2228:             * length of a java.lang.String (java.lang.Integer.MAX_VALUE);
2229:             * this method always returns <code>0</code>.
2230:             * </div>
2231:             * <!-- end release-specific documentation -->
2232:             *
2233:             *
2234:             * @return max the maximum length (in hex characters) for a binary literal;
2235:             *     a result of zero means that there is no limit or the limit
2236:             *     is not known
2237:             * @exception SQLException if a database access error occurs
2238:             */
2239:            public int getMaxBinaryLiteralLength() throws SQLException {
2240:
2241:                // hard limit is Integer.MAX_VALUE
2242:                return 0;
2243:            }
2244:
2245:            /**
2246:             * Retrieves the maximum number of characters this database allows
2247:             * for a character literal. <p>
2248:             *
2249:             * <!-- start release-specific documentation -->
2250:             * <div class="ReleaseSpecificDocumentation">
2251:             * <h3>HSQLDB-Specific Information:</h3> <p>
2252:             *
2253:             * HSQLDB does not impose a "known" limit.  The hard limit is the maximum
2254:             * length of a java.lang.String (java.lang.Integer.MAX_VALUE);
2255:             * this method always returns <code>0</code>.
2256:             * </div>
2257:             * <!-- end release-specific documentation -->
2258:             *
2259:             * @return the maximum number of characters allowed for a character literal;
2260:             *     a result of zero means that there is no limit or the limit is
2261:             *     not known
2262:             * @exception SQLException if a database access error occurs
2263:             */
2264:            public int getMaxCharLiteralLength() throws SQLException {
2265:
2266:                // hard limit is Integer.MAX_VALUE
2267:                return 0;
2268:            }
2269:
2270:            /**
2271:             * Retrieves the maximum number of characters this database allows
2272:             * for a column name. <p>
2273:             *
2274:             * <!-- start release-specific documentation -->
2275:             * <div class="ReleaseSpecificDocumentation">
2276:             * <h3>HSQLDB-Specific Information:</h3> <p>
2277:             *
2278:             * HSQLDB does not impose a "known" limit.  The hard limit is the maximum
2279:             * length of a java.lang.String (java.lang.Integer.MAX_VALUE);
2280:             * this method always returns <code>0</code>.
2281:             * </div>
2282:             * <!-- end release-specific documentation -->
2283:             *
2284:             * @return the maximum number of characters allowed for a column name;
2285:             *     a result of zero means that there is no limit or the limit
2286:             *     is not known
2287:             * @exception SQLException if a database access error occurs
2288:             */
2289:            public int getMaxColumnNameLength() throws SQLException {
2290:
2291:                // hard limit is Integer.MAX_VALUE
2292:                return 0;
2293:            }
2294:
2295:            /**
2296:             * Retrieves the maximum number of columns this database allows in a
2297:             * <code>GROUP BY</code> clause. <p>
2298:             *
2299:             * <!-- start release-specific documentation -->
2300:             * <div class="ReleaseSpecificDocumentation">
2301:             * <h3>HSQLDB-Specific Information:</h3> <p>
2302:             *
2303:             * HSQLDB does not impose a "known" limit.  The hard limit is the maximum
2304:             * length of a Java array (java.lang.Integer.MAX_VALUE);
2305:             * this method always returns <code>0</code>.
2306:             * </div>
2307:             * <!-- end release-specific documentation -->
2308:             *
2309:             * @return the maximum number of columns allowed;
2310:             *     a result of zero means that there is no limit or the limit
2311:             *     is not known
2312:             * @exception SQLException if a database access error occurs
2313:             */
2314:            public int getMaxColumnsInGroupBy() throws SQLException {
2315:
2316:                // hard limit is Integer.MAX_VALUE
2317:                return 0;
2318:            }
2319:
2320:            /**
2321:             * Retrieves the maximum number of columns this database allows in
2322:             * an index. <p>
2323:             *
2324:             * <!-- start release-specific documentation -->
2325:             * <div class="ReleaseSpecificDocumentation">
2326:             * <h3>HSQLDB-Specific Information:</h3> <p>
2327:             *
2328:             * HSQLDB does not impose a "known" limit.  The hard limit is the maximum
2329:             * length of a Java array (java.lang.Integer.MAX_VALUE);
2330:             * this method always returns <code>0</code>.
2331:             * </div>
2332:             * <!-- end release-specific documentation -->
2333:             *
2334:             * @return the maximum number of columns allowed;
2335:             *     a result of zero means that there is no limit or the limit
2336:             *     is not known
2337:             * @exception SQLException if a database access error occurs
2338:             */
2339:            public int getMaxColumnsInIndex() throws SQLException {
2340:
2341:                // hard limit is Integer.MAX_VALUE
2342:                return 0;
2343:            }
2344:
2345:            /**
2346:             * Retrieves the maximum number of columns this database allows in an
2347:             * <code>ORDER BY</code> clause. <p>
2348:             *
2349:             * <!-- start release-specific documentation -->
2350:             * <div class="ReleaseSpecificDocumentation">
2351:             * <h3>HSQLDB-Specific Information:</h3> <p>
2352:             *
2353:             * HSQLDB does not impose a "known" limit.  The hard limit is the maximum
2354:             * length of a Java array (java.lang.Integer.MAX_VALUE);
2355:             * this method always returns <code>0</code>.
2356:             * </div>
2357:             * <!-- end release-specific documentation -->
2358:             *
2359:             * @return the maximum number of columns allowed;
2360:             *     a result of zero means that there is no limit or the limit
2361:             *     is not known
2362:             * @exception SQLException if a database access error occurs
2363:             */
2364:            public int getMaxColumnsInOrderBy() throws SQLException {
2365:
2366:                // hard limit is Integer.MAX_VALUE
2367:                return 0;
2368:            }
2369:
2370:            /**
2371:             * Retrieves the maximum number of columns this database allows in a
2372:             * <code>SELECT</code> list. <p>
2373:             *
2374:             * <!-- start release-specific documentation -->
2375:             * <div class="ReleaseSpecificDocumentation">
2376:             * <h3>HSQLDB-Specific Information:</h3> <p>
2377:             *
2378:             * HSQLDB does not impose a "known" limit.  The hard limit is the maximum
2379:             * length of a Java array (java.lang.Integer.MAX_VALUE);
2380:             * this method always returns <code>0</code>.
2381:             * </div>
2382:             * <!-- end release-specific documentation -->
2383:             *
2384:             * @return the maximum number of columns allowed;
2385:             *     a result of zero means that there is no limit or the limit
2386:             *     is not known
2387:             * @exception SQLException if a database access error occurs
2388:             */
2389:            public int getMaxColumnsInSelect() throws SQLException {
2390:
2391:                // hard limit is Integer.MAX_VALUE
2392:                return 0;
2393:            }
2394:
2395:            /**
2396:             * Retrieves the maximum number of columns this database allows in
2397:             * a table. <p>
2398:             *
2399:             * <!-- start release-specific documentation -->
2400:             * <div class="ReleaseSpecificDocumentation">
2401:             * <h3>HSQLDB-Specific Information:</h3> <p>
2402:             *
2403:             * HSQLDB does not impose a "known" limit.  The hard limit is the maximum
2404:             * length of a Java array (java.lang.Integer.MAX_VALUE);
2405:             * this method always returns <code>0</code>.
2406:             * </div>
2407:             * <!-- end release-specific documentation -->
2408:             *
2409:             * @return the maximum number of columns allowed;
2410:             *     a result of zero means that there is no limit or the limit
2411:             *     is not known
2412:             * @exception SQLException if a database access error occurs
2413:             */
2414:            public int getMaxColumnsInTable() throws SQLException {
2415:
2416:                // hard limit is Integer.MAX_VALUE
2417:                return 0;
2418:            }
2419:
2420:            /**
2421:             * Retrieves the maximum number of concurrent connections to this
2422:             * database that are possible. <p>
2423:             *
2424:             * <!-- start release-specific documentation -->
2425:             * <div class="ReleaseSpecificDocumentation">
2426:             * <h3>HSQLDB-Specific Information:</h3> <p>
2427:             *
2428:             * HSQLDB does not impose a "known" limit.  The hard limit is the maximum
2429:             * length of a Java array (java.lang.Integer.MAX_VALUE);
2430:             * this method always returns <code>0</code>.
2431:             * </div>
2432:             * <!-- end release-specific documentation -->
2433:             *
2434:             * @return the maximum number of active connections possible at one time;
2435:             *     a result of zero means that there is no limit or the limit
2436:             *     is not known
2437:             * @exception SQLException if a database access error occurs
2438:             */
2439:            public int getMaxConnections() throws SQLException {
2440:
2441:                // hard limit is (probably) Integer.MAX_VALUE
2442:                return 0;
2443:            }
2444:
2445:            /**
2446:             * Retrieves the maximum number of characters that this database allows in a
2447:             * cursor name. <p>
2448:             *
2449:             * <!-- start release-specific documentation -->
2450:             * <div class="ReleaseSpecificDocumentation">
2451:             * <h3>HSQLDB-Specific Information:</h3> <p>
2452:             *
2453:             * HSQLDB does not impose a "known" limit.  The hard limit is the maximum
2454:             * length of a java.lang.String (java.lang.Integer.MAX_VALUE);
2455:             * this method always returns <code>0</code>.
2456:             * </div>
2457:             * <!-- end release-specific documentation -->
2458:             *
2459:             * @return the maximum number of characters allowed in a cursor name;
2460:             *     a result of zero means that there is no limit or the limit
2461:             *     is not known
2462:             * @exception SQLException if a database access error occurs
2463:             */
2464:            public int getMaxCursorNameLength() throws SQLException {
2465:                return 0;
2466:            }
2467:
2468:            /**
2469:             * Retrieves the maximum number of bytes this database allows for an
2470:             * index, including all of the parts of the index. <p>
2471:             *
2472:             * <!-- start release-specific documentation -->
2473:             * <div class="ReleaseSpecificDocumentation">
2474:             * <h3>HSQLDB-Specific Information:</h3> <p>
2475:             *
2476:             * HSQLDB does not impose a "known" limit;
2477:             * this method always returns <code>0</code>.
2478:             * </div>
2479:             * <!-- end release-specific documentation -->
2480:             *
2481:             * @return the maximum number of bytes allowed; this limit includes the
2482:             *     composite of all the constituent parts of the index;
2483:             *     a result of zero means that there is no limit or the limit
2484:             *     is not known
2485:             * @exception SQLException if a database access error occurs
2486:             */
2487:            public int getMaxIndexLength() throws SQLException {
2488:                return 0;
2489:            }
2490:
2491:            /**
2492:             * Retrieves the maximum number of characters that this database allows in a
2493:             * schema name. <p>
2494:             *
2495:             * <!-- start release-specific documentation -->
2496:             * <div class="ReleaseSpecificDocumentation">
2497:             * <h3>HSQLDB-Specific Information:</h3> <p>
2498:             *
2499:             * 1.8.0 supports schema names with no known limit imposed,
2500:             * so this method always returns <code>0</code>.
2501:             * </div>
2502:             * <!-- end release-specific documentation -->
2503:             * @return the maximum number of characters allowed in a schema name;
2504:             *    a result of zero means that there is no limit or the limit
2505:             *    is not known
2506:             * @exception SQLException if a database access error occurs
2507:             */
2508:            public int getMaxSchemaNameLength() throws SQLException {
2509:                return 0;
2510:            }
2511:
2512:            /**
2513:             * Retrieves the maximum number of characters that this database allows in a
2514:             * procedure name. <p>
2515:             *
2516:             * <!-- start release-specific documentation -->
2517:             * <div class="ReleaseSpecificDocumentation">
2518:             * <h3>HSQLDB-Specific Information:</h3> <p>
2519:             *
2520:             * HSQLDB does not impose a "known" limit.  The hard limit is the maximum
2521:             * length of a java.lang.String (java.lang.Integer.MAX_VALUE);
2522:             * this method always returns <code>0</code>.
2523:             * </div>
2524:             * <!-- end release-specific documentation -->
2525:             *
2526:             * @return the maximum number of characters allowed in a procedure name;
2527:             *     a result of zero means that there is no limit or the limit
2528:             *     is not known
2529:             * @exception SQLException if a database access error occurs
2530:             */
2531:            public int getMaxProcedureNameLength() throws SQLException {
2532:                return 0;
2533:            }
2534:
2535:            /**
2536:             * Retrieves the maximum number of characters that this database allows in a
2537:             * catalog name. <p>
2538:             *
2539:             * <!-- start release-specific documentation -->
2540:             * <div class="ReleaseSpecificDocumentation">
2541:             * <h3>HSQLDB-Specific Information:</h3> <p>
2542:             *
2543:             * Up to and including 1.7.2, HSQLDB does not support catalogs in
2544:             * DDL or DML; this method always returns <code>0</code>.
2545:             * </div>
2546:             * <!-- end release-specific documentation -->
2547:             *
2548:             * @return the maximum number of characters allowed in a catalog name;
2549:             *     a result of zero means that there is no limit or the limit
2550:             *     is not known
2551:             * @exception SQLException if a database access error occurs
2552:             */
2553:            public int getMaxCatalogNameLength() throws SQLException {
2554:                return 0;
2555:            }
2556:
2557:            /**
2558:             * Retrieves the maximum number of bytes this database allows in
2559:             * a single row. <p>
2560:             *
2561:             * <!-- start release-specific documentation -->
2562:             * <div class="ReleaseSpecificDocumentation">
2563:             * <h3>HSQLDB-Specific Information:</h3> <p>
2564:             *
2565:             * HSQLDB does not impose a "known" limit;
2566:             * this method always returns <code>0</code>.
2567:             * </div>
2568:             * <!-- end release-specific documentation -->
2569:             *
2570:             * @return the maximum number of bytes allowed for a row; a result of
2571:             *        zero means that there is no limit or the limit is not known
2572:             * @exception SQLException if a database access error occurs
2573:             */
2574:            public int getMaxRowSize() throws SQLException {
2575:                return 0;
2576:            }
2577:
2578:            /**
2579:             * Retrieves whether the return value for the method
2580:             * <code>getMaxRowSize</code> includes the SQL data types
2581:             * <code>LONGVARCHAR</code> and <code>LONGVARBINARY</code>. <p>
2582:             *
2583:             * <!-- start release-specific documentation -->
2584:             * <div class="ReleaseSpecificDocumentation">
2585:             * <h3>HSQLDB-Specific Indormation:</h3><p>
2586:             *
2587:             * Including 1.7.2, {@link #getMaxRowSize} <em>always</em> returns
2588:             * 0, indicating that the maximum row size is unknown or has no limit.
2589:             * This applies to the above types as well; this method <em>always</em>
2590:             * returns <code>true</code>.
2591:             * </div>
2592:             * <!-- end release-specific documentation -->
2593:             *
2594:             *
2595:             * @return <code>true</code> if so; <code>false</code> otherwise
2596:             * @exception SQLException if a database access error occurs
2597:             */
2598:            public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {
2599:                return true;
2600:            }
2601:
2602:            /**
2603:             * Retrieves the maximum number of characters this database allows in
2604:             * an SQL statement. <p>
2605:             *
2606:             * <!-- start release-specific documentation -->
2607:             * <div class="ReleaseSpecificDocumentation">
2608:             * <h3>HSQLDB-Specific Information:</h3> <p>
2609:             *
2610:             * HSQLDB does not impose a "known" limit.  The hard limit is the maximum
2611:             * length of a java.lang.String (java.lang.Integer.MAX_VALUE);
2612:             * this method always returns <code>0</code>.
2613:             * </div>
2614:             * <!-- end release-specific documentation -->
2615:             *
2616:             * @return the maximum number of characters allowed for an SQL statement;
2617:             *     a result of zero means that there is no limit or the limit
2618:             *     is not known
2619:             * @exception SQLException if a database access error occurs
2620:             */
2621:            public int getMaxStatementLength() throws SQLException {
2622:                return 0;
2623:            }
2624:
2625:            /**
2626:             * Retrieves the maximum number of active statements to this database
2627:             * that can be open at the same time. <p>
2628:             *
2629:             * <!-- start release-specific documentation -->
2630:             * <div class="ReleaseSpecificDocumentation">
2631:             * <h3>HSQLDB-Specific Information:</h3> <p>
2632:             *
2633:             * HSQLDB does not impose a "known" limit;
2634:             * this method always returns <code>0</code>.
2635:             * </div>
2636:             * <!-- end release-specific documentation -->
2637:             *
2638:             * @return the maximum number of statements that can be open at one time;
2639:             *     a result of zero means that there is no limit or the limit
2640:             *     is not known
2641:             * @exception SQLException if a database access error occurs
2642:             */
2643:            public int getMaxStatements() throws SQLException {
2644:                return 0;
2645:            }
2646:
2647:            /**
2648:             * Retrieves the maximum number of characters this database allows in
2649:             * a table name. <p>
2650:             *
2651:             * <!-- start release-specific documentation -->
2652:             * <div class="ReleaseSpecificDocumentation">
2653:             * <h3>HSQLDB-Specific Information:</h3> <p>
2654:             *
2655:             * HSQLDB does not impose a "known" limit.  The hard limit is the maximum
2656:             * length of a java.lang.String (java.lang.Integer.MAX_VALUE);
2657:             * this method always returns <code>0</code>.
2658:             * </div>
2659:             * <!-- end release-specific documentation -->
2660:             *
2661:             * @return the maximum number of characters allowed for a table name;
2662:             *     a result of zero means that there is no limit or the limit
2663:             *     is not known
2664:             * @exception SQLException if a database access error occurs
2665:             */
2666:            public int getMaxTableNameLength() throws SQLException {
2667:                return 0;
2668:            }
2669:
2670:            /**
2671:             * Retrieves the maximum number of tables this database allows in a
2672:             * <code>SELECT</code> statement. <p>
2673:             *
2674:             * <!-- start release-specific documentation -->
2675:             * <div class="ReleaseSpecificDocumentation">
2676:             * <h3>HSQLDB-Specific Information:</h3> <p>
2677:             *
2678:             * HSQLDB does not impose a "known" limit.  The hard limit is the maximum
2679:             * length of a Java array (java.lang.Integer.MAX_VALUE);
2680:             * this method always returns <code>0</code>.
2681:             * </div>
2682:             * <!-- end release-specific documentation -->
2683:             *
2684:             * @return the maximum number of tables allowed in a <code>SELECT</code>
2685:             *        statement; a result of zero means that there is no limit or
2686:             *        the limit is not known
2687:             * @exception SQLException if a database access error occurs
2688:             */
2689:            public int getMaxTablesInSelect() throws SQLException {
2690:
2691:                // - soft limit is >>> than will ever be seen in any real stmnt
2692:                // - exists a fixed (non statement dependent) hard limit?  No.
2693:                // - depends totally on number of table idents that can fit in
2694:                // Integer.MAX_VALUE characters, minus the rest of the stmnt
2695:                return 0;
2696:            }
2697:
2698:            /**
2699:             * Retrieves the maximum number of characters this database allows in
2700:             * a user name. <p>
2701:             *
2702:             * <!-- start release-specific documentation -->
2703:             * <div class="ReleaseSpecificDocumentation">
2704:             * <h3>HSQLDB-Specific Information:</h3> <p>
2705:             *
2706:             * HSQLDB does not impose a "known" limit.  The hard limit is the maximum
2707:             * length of a java.lang.String (java.lang.Integer.MAX_VALUE);
2708:             * this method always returns <code>0</code>.
2709:             * </div>
2710:             * <!-- end release-specific documentation -->
2711:             *
2712:             * @return the maximum number of characters allowed for a user name;
2713:             *     a result of zero means that there is no limit or the limit
2714:             *     is not known
2715:             * @exception SQLException if a database access error occurs
2716:             */
2717:            public int getMaxUserNameLength() throws SQLException {
2718:
2719:                // hard limit is Integer.MAX_VALUE
2720:                return 0;
2721:            }
2722:
2723:            //----------------------------------------------------------------------
2724:
2725:            /**
2726:             * Retrieves this database's default transaction isolation level.  The
2727:             * possible values are defined in <code>java.sql.Connection</code>. <p>
2728:             *
2729:             * <!-- start release-specific documentation -->
2730:             * <div class="ReleaseSpecificDocumentation">
2731:             * <h3>HSQLDB-Specific Information</h3>
2732:             *
2733:             * Including 1.7.2, HSQLDB supports only TRANSACTION_READ_UNCOMMITED
2734:             * and <em>always</em> returns this value here.
2735:             * </div>
2736:             * <!-- end release-specific documentation -->
2737:             *
2738:             * @return the default isolation level
2739:             * @exception SQLException if a database access error occurs
2740:             * @see jdbcConnection
2741:             */
2742:            public int getDefaultTransactionIsolation() throws SQLException {
2743:                return Connection.TRANSACTION_READ_UNCOMMITTED;
2744:            }
2745:
2746:            /**
2747:             * Retrieves whether this database supports transactions. If not, invoking the
2748:             * method <code>commit</code> is a noop, and the isolation level is
2749:             * <code>TRANSACTION_NONE</code>. <p>
2750:             *
2751:             * <!-- start release-specific documentation -->
2752:             * <div class="ReleaseSpecificDocumentation">
2753:             * <h3>HSQLDB-Specific Information:</h3> <p>
2754:             *
2755:             * HSQLDB supports transactions;
2756:             * this method always returns <code>true</code>.
2757:             * </div>
2758:             * <!-- end release-specific documentation -->
2759:             * @return <code>true</code> if transactions are supported;
2760:             *        <code>false</code> otherwise
2761:             * @exception SQLException if a database access error occurs
2762:             */
2763:            public boolean supportsTransactions() throws SQLException {
2764:                return true;
2765:            }
2766:
2767:            /**
2768:             * Retrieves whether this database supports the given transaction
2769:             * isolation level. <p>
2770:             *
2771:             * <!-- start release-specific documentation -->
2772:             * <div class="ReleaseSpecificDocumentation">
2773:             * <h3>HSQLDB-Specific Information</h3>
2774:             * HSQLDB supports <code>TRANSACTION_READ_UNCOMMITED</code> in all cases
2775:             * and the rest of the isolation levels where there is only one connection
2776:             * to the database.
2777:             * </div>
2778:             * <!-- end release-specific documentation -->
2779:             *
2780:             *
2781:             * @param level one of the transaction isolation levels defined in
2782:             *         <code>java.sql.Connection</code>
2783:             * @return <code>true</code> if so; <code>false</code> otherwise
2784:             * @exception SQLException if a database access error occurs
2785:             * @see jdbcConnection
2786:             */
2787:            public boolean supportsTransactionIsolationLevel(int level)
2788:                    throws SQLException {
2789:
2790:                return level == Connection.TRANSACTION_READ_UNCOMMITTED
2791:                        || level == Connection.TRANSACTION_READ_COMMITTED
2792:                        || level == Connection.TRANSACTION_REPEATABLE_READ
2793:                        || level == Connection.TRANSACTION_SERIALIZABLE;
2794:            }
2795:
2796:            /**
2797:             * Retrieves whether this database supports both data definition and
2798:             * data manipulation statements within a transaction. <p>
2799:             *
2800:             * <!-- start release-specific documentation -->
2801:             * <div class="ReleaseSpecificDocumentation">
2802:             * <h3>HSQLDB-Specific Information:</h3> <p>
2803:             *
2804:             * HSQLDB does not support a mix of both data definition and
2805:             * data manipulation statements within a transaction.  DDL commits the
2806:             * current transaction before proceding;
2807:             * this method always returns <code>false</code>.
2808:             * </div>
2809:             * <!-- end release-specific documentation -->
2810:             *
2811:             *
2812:             * @return <code>true</code> if so; <code>false</code> otherwise
2813:             * @exception SQLException if a database access error occurs
2814:             */
2815:            public boolean supportsDataDefinitionAndDataManipulationTransactions()
2816:                    throws SQLException {
2817:                return false;
2818:            }
2819:
2820:            /**
2821:             * Retrieves whether this database supports only data manipulation
2822:             * statements within a transaction. <p>
2823:             *
2824:             * <!-- start release-specific documentation -->
2825:             * <div class="ReleaseSpecificDocumentation">
2826:             * <h3>HSQLDB-Specific Information:</h3> <p>
2827:             *
2828:             * HSQLDB supports only data manipulation
2829:             * statements within a transaction.  DDL commits the
2830:             * current transaction before proceeding, while DML does not;
2831:             * this method always returns <code>true</code>.
2832:             * </div>
2833:             * <!-- end release-specific documentation -->
2834:             *
2835:             *
2836:             * @return <code>true</code> if so; <code>false</code> otherwise
2837:             * @exception SQLException if a database access error occurs
2838:             */
2839:            public boolean supportsDataManipulationTransactionsOnly()
2840:                    throws SQLException {
2841:                return true;
2842:            }
2843:
2844:            /**
2845:             * Retrieves whether a data definition statement within a transaction forces
2846:             * the transaction to commit. <p>
2847:             *
2848:             * <!-- start release-specific documentation -->
2849:             * <div class="ReleaseSpecificDocumentation">
2850:             * <h3>HSQLDB-Specific Information:</h3> <p>
2851:             *
2852:             * Including 1.7.2, a data definition statement within a transaction forces
2853:             * the transaction to commit; this method always returns <code>true</code>.
2854:             * </div>
2855:             * <!-- end release-specific documentation -->
2856:             *
2857:             *
2858:             * @return <code>true</code> if so; <code>false</code> otherwise
2859:             * @exception SQLException if a database access error occurs
2860:             */
2861:            public boolean dataDefinitionCausesTransactionCommit()
2862:                    throws SQLException {
2863:                return true;
2864:            }
2865:
2866:            /**
2867:             * Retrieves whether this database ignores a data definition statement
2868:             * within a transaction. <p>
2869:             *
2870:             * <!-- start release-specific documentation -->
2871:             * <div class="ReleaseSpecificDocumentation">
2872:             * <h3>HSQLDB-Specific Information:</h3> <p>
2873:             *
2874:             * Including 1.7.2, a data definition statement is not ignored within a
2875:             * transaction.  Rather, a data definition statement within a
2876:             * transaction forces the transaction to commit; this method
2877:             * <em>always</em> returns <code>false</code>.
2878:             * </div>
2879:             * <!-- end release-specific documentation -->
2880:             *
2881:             *
2882:             * @return <code>true</code> if so; <code>false</code> otherwise
2883:             * @exception SQLException if a database access error occurs
2884:             */
2885:            public boolean dataDefinitionIgnoredInTransactions()
2886:                    throws SQLException {
2887:                return false;
2888:            }
2889:
2890:            /**
2891:             * Retrieves a description of the stored procedures available in the given
2892:             * catalog.
2893:             * <P>
2894:             * Only procedure descriptions matching the schema and
2895:             * procedure name criteria are returned.  They are ordered by
2896:             * <code>PROCEDURE_SCHEM</code> and <code>PROCEDURE_NAME</code>.
2897:             *
2898:             * <P>Each procedure description has the the following columns:
2899:             * <OL>
2900:             *  <LI><B>PROCEDURE_CAT</B> String => procedure catalog (may be <code>null</code>)
2901:             *  <LI><B>PROCEDURE_SCHEM</B> String => procedure schema (may be <code>null</code>)
2902:             *  <LI><B>PROCEDURE_NAME</B> String => procedure name
2903:             * <LI> reserved for future use
2904:             * <LI> reserved for future use
2905:             * <LI> reserved for future use
2906:             *  <LI><B>REMARKS</B> String => explanatory comment on the procedure
2907:             *  <LI><B>PROCEDURE_TYPE</B> short => kind of procedure:
2908:             *    <UL>
2909:             *    <LI> procedureResultUnknown - May return a result
2910:             *    <LI> procedureNoResult - Does not return a result
2911:             *    <LI> procedureReturnsResult - Returns a result
2912:             *    </UL>
2913:             * </OL> <p>
2914:             *
2915:             * <!-- start release-specific documentation -->
2916:             * <div class="ReleaseSpecificDocumentation">
2917:             * <h3>HSQLDB-Specific Information:</h3> <p>
2918:             *
2919:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
2920:             * them in upper case; it treats quoted identifiers as case sensitive and
2921:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
2922:             * case-sensitive comparison between name (pattern) arguments and the
2923:             * corresponding identifier values as they are stored in the database.
2924:             * Therefore, care must be taken to specify name arguments precisely
2925:             * (including case) as they are stored in the database. <p>
2926:             *
2927:             * Since 1.7.2, this feature is supported by default. If the jar is
2928:             * compiled without org.hsqldb.DatabaseInformationFull or
2929:             * org.hsqldb.DatabaseInformationMain, the feature is
2930:             * not supported. The default implementation is
2931:             * {@link org.hsqldb.DatabaseInformationFull}.
2932:             * </div>
2933:             * <!-- end release-specific documentation -->
2934:             *
2935:             * @param catalog a catalog name; must match the catalog name as it
2936:             *      is stored in the database; "" retrieves those without a catalog;
2937:             *      <code>null</code> means that the catalog name should not be used
2938:             *      to narrow the search
2939:             * @param schemaPattern a schema name pattern; must match the schema name
2940:             *      as it is stored in the database; "" retrieves those without a
2941:             *      schema; <code>null</code> means that the schema name should not be
2942:             *      used to narrow the search
2943:             * @param procedureNamePattern a procedure name pattern; must match the
2944:             *      procedure name as it is stored in the database
2945:             * @return <code>ResultSet</code> - each row is a procedure description
2946:             * @exception SQLException if a database access error occurs
2947:             * @see #getSearchStringEscape
2948:             */
2949:            public ResultSet getProcedures(String catalog,
2950:                    String schemaPattern, String procedureNamePattern)
2951:                    throws SQLException {
2952:
2953:                if (wantsIsNull(procedureNamePattern)) {
2954:                    return executeSelect("SYSTEM_PROCEDURES", "0=1");
2955:                }
2956:
2957:                schemaPattern = translateSchema(schemaPattern);
2958:
2959:                StringBuffer select = toQueryPrefix("SYSTEM_PROCEDURES")
2960:                        .append(and("PROCEDURE_CAT", "=", catalog)).append(
2961:                                and("PROCEDURE_SCHEM", "LIKE", schemaPattern))
2962:                        .append(
2963:                                and("PROCEDURE_NAME", "LIKE",
2964:                                        procedureNamePattern));
2965:
2966:                // By default, query already returns the result ordered by
2967:                // PROCEDURE_SCHEM, PROCEDURE_NAME...
2968:                return execute(select.toString());
2969:            }
2970:
2971:            /**
2972:             * Retrieves a description of the given catalog's stored procedure parameter
2973:             * and result columns.
2974:             *
2975:             * <P>Only descriptions matching the schema, procedure and
2976:             * parameter name criteria are returned.  They are ordered by
2977:             * PROCEDURE_SCHEM and PROCEDURE_NAME. Within this, the return value,
2978:             * if any, is first. Next are the parameter descriptions in call
2979:             * order. The column descriptions follow in column number order.
2980:             *
2981:             * <P>Each row in the <code>ResultSet</code> is a parameter description or
2982:             * column description with the following fields:
2983:             * <OL>
2984:             *  <LI><B>PROCEDURE_CAT</B> String => procedure catalog (may be <code>null</code>)
2985:             *  <LI><B>PROCEDURE_SCHEM</B> String => procedure schema (may be <code>null</code>)
2986:             *  <LI><B>PROCEDURE_NAME</B> String => procedure name
2987:             *  <LI><B>COLUMN_NAME</B> String => column/parameter name
2988:             *  <LI><B>COLUMN_TYPE</B> Short => kind of column/parameter:
2989:             *     <UL>
2990:             *     <LI> procedureColumnUnknown - nobody knows
2991:             *     <LI> procedureColumnIn - IN parameter
2992:             *     <LI> procedureColumnInOut - INOUT parameter
2993:             *     <LI> procedureColumnOut - OUT parameter
2994:             *     <LI> procedureColumnReturn - procedure return value
2995:             *     <LI> procedureColumnResult - result column in <code>ResultSet</code>
2996:             *     </UL>
2997:             * <LI><B>DATA_TYPE</B> short => SQL type from java.sql.Types
2998:             *  <LI><B>TYPE_NAME</B> String => SQL type name, for a UDT type the
2999:             * type name is fully qualified
3000:             *  <LI><B>PRECISION</B> int => precision
3001:             *  <LI><B>LENGTH</B> int => length in bytes of data
3002:             *  <LI><B>SCALE</B> short => scale
3003:             *  <LI><B>RADIX</B> short => radix
3004:             *  <LI><B>NULLABLE</B> short => can it contain NULL.
3005:             *     <UL>
3006:             *     <LI> procedureNoNulls - does not allow NULL values
3007:             *     <LI> procedureNullable - allows NULL values
3008:             *     <LI> procedureNullableUnknown - nullability unknown
3009:             *     </UL>
3010:             *  <LI><B>REMARKS</B> String => comment describing parameter/column
3011:             * </OL>
3012:             *
3013:             * <P><B>Note:</B> Some databases may not return the column
3014:             * descriptions for a procedure. Additional columns beyond
3015:             * REMARKS can be defined by the database. <p>
3016:             *
3017:             * <!-- start release-specific documentation -->
3018:             * <div class="ReleaseSpecificDocumentation">
3019:             * <h3>HSQLDB-Specific Information:</h3> <p>
3020:             *
3021:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
3022:             * them in upper case; it treats quoted identifiers as case sensitive and
3023:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
3024:             * case-sensitive comparison between name (pattern) arguments and the
3025:             * corresponding identifier values as they are stored in the database.
3026:             * Therefore, care must be taken to specify name arguments precisely
3027:             * (including case) as they are stored in the database. <p>
3028:             *
3029:             * Since 1.7.2, this feature is supported by default. If the jar is
3030:             * compiled without org.hsqldb.DatabaseInformationFull or
3031:             * org.hsqldb.DatabaseInformationMain, the feature is
3032:             * not supported. The default implementation is
3033:             * {@link org.hsqldb.DatabaseInformationFull}.
3034:             * </div>
3035:             * <!-- end release-specific documentation -->
3036:             *
3037:             * @param catalog a catalog name; must match the catalog name as it
3038:             *       is stored in the database; "" retrieves those without a catalog;
3039:             *       <code>null</code> means that the catalog name should not be used
3040:             *       to narrow the search
3041:             * @param schemaPattern a schema name pattern; must match the schema name
3042:             *       as it is stored in the database; "" retrieves those without a
3043:             *       schema; <code>null</code> means that the schema name should not be
3044:             *       used to narrow the search
3045:             * @param procedureNamePattern a procedure name pattern; must match the
3046:             *       procedure name as it is stored in the database
3047:             * @param columnNamePattern a column name pattern; must match the column
3048:             *       name as it is stored in the database
3049:             * @return <code>ResultSet</code> - each row describes a stored procedure
3050:             *       parameter or column
3051:             * @exception SQLException if a database access error occurs
3052:             * @see #getSearchStringEscape
3053:             */
3054:            public ResultSet getProcedureColumns(String catalog,
3055:                    String schemaPattern, String procedureNamePattern,
3056:                    String columnNamePattern) throws SQLException {
3057:
3058:                if (wantsIsNull(procedureNamePattern)
3059:                        || wantsIsNull(columnNamePattern)) {
3060:                    return executeSelect("SYSTEM_PROCEDURECOLUMNS", "0=1");
3061:                }
3062:
3063:                schemaPattern = translateSchema(schemaPattern);
3064:
3065:                StringBuffer select = toQueryPrefix("SYSTEM_PROCEDURECOLUMNS")
3066:                        .append(and("PROCEDURE_CAT", "=", catalog)).append(
3067:                                and("PROCEDURE_SCHEM", "LIKE", schemaPattern))
3068:                        .append(
3069:                                and("PROCEDURE_NAME", "LIKE",
3070:                                        procedureNamePattern)).append(
3071:                                and("COLUMN_NAME", "LIKE", columnNamePattern));
3072:
3073:                // By default, query already returns result ordered by
3074:                // PROCEDURE_SCHEM and PROCEDURE_NAME...
3075:                return execute(select.toString());
3076:            }
3077:
3078:            /**
3079:             * Retrieves a description of the tables available in the given catalog.
3080:             * Only table descriptions matching the catalog, schema, table
3081:             * name and type criteria are returned.  They are ordered by
3082:             * TABLE_TYPE, TABLE_SCHEM and TABLE_NAME.
3083:             * <P>
3084:             * Each table description has the following columns:
3085:             * <OL>
3086:             *  <LI><B>TABLE_CAT</B> String => table catalog (may be <code>null</code>)
3087:             *  <LI><B>TABLE_SCHEM</B> String => table schema (may be <code>null</code>)
3088:             *  <LI><B>TABLE_NAME</B> String => table name
3089:             *  <LI><B>TABLE_TYPE</B> String => table type.  Typical types are "TABLE",
3090:             *                  "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
3091:             *                  "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
3092:             *  <LI><B>REMARKS</B> String => explanatory comment on the table
3093:             * <LI><B>TYPE_CAT</B> String => the types catalog (may be <code>null</code>)
3094:             * <LI><B>TYPE_SCHEM</B> String => the types schema (may be <code>null</code>)
3095:             * <LI><B>TYPE_NAME</B> String => type name (may be <code>null</code>)
3096:             * <LI><B>SELF_REFERENCING_COL_NAME</B> String => name of the designated
3097:             *                 "identifier" column of a typed table (may be <code>null</code>)
3098:             *  <LI><B>REF_GENERATION</B> String => specifies how values in
3099:             *                 SELF_REFERENCING_COL_NAME are created. Values are
3100:             *                 "SYSTEM", "USER", "DERIVED". (may be <code>null</code>)
3101:             * </OL>
3102:             *
3103:             * <P><B>Note:</B> Some databases may not return information for
3104:             * all tables. <p>
3105:             *
3106:             * <!-- start release-specific documentation -->
3107:             * <div class="ReleaseSpecificDocumentation">
3108:             * <h3>HSQLDB-Specific Information:</h3> <p>
3109:             *
3110:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
3111:             * them in upper case; it treats quoted identifiers as case sensitive and
3112:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
3113:             * case-sensitive comparison between name (pattern) arguments and the
3114:             * corresponding identifier values as they are stored in the database.
3115:             * Therefore, care must be taken to specify name arguments precisely
3116:             * (including case) as they are stored in the database. <p>
3117:             *
3118:             * Since 1.7.0, HSQLDB returns extra information on TEXT tables
3119:             * in the REMARKS column. <p>
3120:             *
3121:             * Since 1.7.0, HSQLDB includes the new JDBC3 columns TYPE_CAT,
3122:             * TYPE_SCHEM, TYPE_NAME and SELF_REFERENCING_COL_NAME in anticipation
3123:             * of JDBC3 compliant tools. <p>
3124:             *
3125:             * Since 1.7.2, this feature is supported by default. If the jar is
3126:             * compiled without org.hsqldb.DatabaseInformationFull or
3127:             * org.hsqldb.DatabaseInformationMain, the feature is
3128:             * not supported. The default implementation is
3129:             * {@link org.hsqldb.DatabaseInformationFull}.
3130:             * </div>
3131:             * <!-- end release-specific documentation -->
3132:             *
3133:             * @param catalog a catalog name; must match the catalog name as it
3134:             *       is stored in the database; "" retrieves those without a catalog;
3135:             *       <code>null</code> means that the catalog name should not be used
3136:             *       to narrow the search
3137:             * @param schemaPattern a schema name pattern; must match the schema name
3138:             *       as it is stored in the database; "" retrieves those without a
3139:             *       schema; <code>null</code> means that the schema name should not be
3140:             *       used to narrow the search
3141:             * @param tableNamePattern a table name pattern; must match the
3142:             *       table name as it is stored in the database
3143:             * @param types a list of table types to include; <code>null</code> returns
3144:             *       all types
3145:             * @return <code>ResultSet</code> - each row is a table description
3146:             * @exception SQLException if a database access error occurs
3147:             * @see #getSearchStringEscape
3148:             */
3149:            public ResultSet getTables(String catalog, String schemaPattern,
3150:                    String tableNamePattern, String[] types)
3151:                    throws SQLException {
3152:
3153:                if (wantsIsNull(tableNamePattern)
3154:                        || (types != null && types.length == 0)) {
3155:                    return executeSelect("SYSTEM_TABLES", "0=1");
3156:                }
3157:
3158:                schemaPattern = translateSchema(schemaPattern);
3159:
3160:                StringBuffer select = toQueryPrefix("SYSTEM_TABLES").append(
3161:                        and("TABLE_CAT", "=", catalog)).append(
3162:                        and("TABLE_SCHEM", "LIKE", schemaPattern)).append(
3163:                        and("TABLE_NAME", "LIKE", tableNamePattern));
3164:
3165:                if (types == null) {
3166:
3167:                    // do not use to narrow search
3168:                } else {
3169:                    select.append(" AND TABLE_TYPE IN (").append(
3170:                            StringUtil.getList(types, ",", "'")).append(')');
3171:                }
3172:
3173:                // By default, query already returns result ordered by
3174:                // TABLE_TYPE, TABLE_SCHEM and TABLE_NAME...
3175:                return execute(select.toString());
3176:            }
3177:
3178:            /**
3179:             * Retrieves the schema names available in this database.  The results
3180:             * are ordered by schema name.
3181:             *
3182:             * <P>The schema column is:
3183:             * <OL>
3184:             * <LI><B>TABLE_SCHEM</B> String => schema name
3185:             * <LI><B>TABLE_CATALOG</B> String => catalog name (may be <code>null</code>)
3186:             * </OL> <p>
3187:             *
3188:             * <!-- start release-specific documentation -->
3189:             * <div class="ReleaseSpecificDocumentation">
3190:             * <h3>HSQLDB-Specific Information:</h3> <p>
3191:             *
3192:             * In 1.8.0, the list of schemas is returned.
3193:             * </div>
3194:             * <!-- end release-specific documentation -->
3195:             *
3196:             * @return a <code>ResultSet</code> object in which each row is a
3197:             *        schema decription
3198:             * @exception SQLException if a database access error occurs
3199:             */
3200:            public ResultSet getSchemas() throws SQLException {
3201:
3202:                // By default, query already returns the result in contract order
3203:                return executeSelect("SYSTEM_SCHEMAS", null);
3204:            }
3205:
3206:            /**
3207:             * Retrieves the catalog names available in this database.  The results
3208:             * are ordered by catalog name.
3209:             *
3210:             * <P>The catalog column is:
3211:             * <OL>
3212:             *    <LI><B>TABLE_CAT</B> String => catalog name
3213:             * </OL> <p>
3214:             *
3215:             * <!-- start release-specific documentation -->
3216:             * <div class="ReleaseSpecificDocumentation">
3217:             * <h3>HSQLDB-Specific Information:</h3> <p>
3218:             *
3219:             * Since 1.7.2, this feature is supported by default. If the jar is
3220:             * compiled without org.hsqldb.DatabaseInformationFull or
3221:             * org.hsqldb.DatabaseInformationMain, the feature is
3222:             * not supported. The default implementation is
3223:             * {@link org.hsqldb.DatabaseInformationFull}.
3224:             * </div>
3225:             * <!-- end release-specific documentation -->
3226:             *
3227:             * @return a <code>ResultSet</code> object in which each row has a
3228:             *        single <code>String</code> column that is a catalog name
3229:             * @exception SQLException if a database access error occurs
3230:             */
3231:            public ResultSet getCatalogs() throws SQLException {
3232:                return executeSelect("SYSTEM_CATALOGS", null);
3233:            }
3234:
3235:            /**
3236:             * Retrieves the table types available in this database.  The results
3237:             * are ordered by table type.
3238:             *
3239:             * <P>The table type is:
3240:             * <OL>
3241:             *  <LI><B>TABLE_TYPE</B> String => table type.  Typical types are "TABLE",
3242:             *                  "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
3243:             *                  "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
3244:             * </OL> <p>
3245:             *
3246:             * <!-- start release-specific documentation -->
3247:             * <div class="ReleaseSpecificDocumentation">
3248:             * <h3>HSQLDB-Specific Information:</h3> <p>
3249:             *
3250:             * Since 1.7.1, HSQLDB reports: "TABLE", "VIEW" and "GLOBAL TEMPORARY"
3251:             * types.
3252:             *
3253:             * Since 1.7.2, this feature is supported by default. If the jar is
3254:             * compiled without org.hsqldb.DatabaseInformationFull or
3255:             * org.hsqldb.DatabaseInformationMain, the feature is
3256:             * not supported. The default implementation is
3257:             * {@link org.hsqldb.DatabaseInformationFull}.
3258:             * </div>
3259:             * <!-- end release-specific documentation -->
3260:             * @return a <code>ResultSet</code> object in which each row has a
3261:             *        single <code>String</code> column that is a table type
3262:             * @exception SQLException if a database access error occurs
3263:             */
3264:            public ResultSet getTableTypes() throws SQLException {
3265:
3266:                // system table producer returns rows in contract order
3267:                return executeSelect("SYSTEM_TABLETYPES", null);
3268:            }
3269:
3270:            /**
3271:             * Retrieves a description of table columns available in
3272:             * the specified catalog.
3273:             *
3274:             * <P>Only column descriptions matching the catalog, schema, table
3275:             * and column name criteria are returned.  They are ordered by
3276:             * <code>TABLE_SCHEM</code>, <code>TABLE_NAME</code>, and
3277:             * <code>ORDINAL_POSITION</code>.
3278:             *
3279:             * <P>Each column description has the following columns:
3280:             * <OL>
3281:             *  <LI><B>TABLE_CAT</B> String => table catalog (may be <code>null</code>)
3282:             *  <LI><B>TABLE_SCHEM</B> String => table schema (may be <code>null</code>)
3283:             *  <LI><B>TABLE_NAME</B> String => table name
3284:             *  <LI><B>COLUMN_NAME</B> String => column name
3285:             *  <LI><B>DATA_TYPE</B> short => SQL type from java.sql.Types
3286:             *  <LI><B>TYPE_NAME</B> String => Data source dependent type name,
3287:             * for a UDT the type name is fully qualified
3288:             *  <LI><B>COLUMN_SIZE</B> int => column size.  For char or date
3289:             *      types this is the maximum number of characters, for numeric or
3290:             *      decimal types this is precision.
3291:             *  <LI><B>BUFFER_LENGTH</B> is not used.
3292:             *  <LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits
3293:             *  <LI><B>NUM_PREC_RADIX</B> int => Radix (typically either 10 or 2)
3294:             *  <LI><B>NULLABLE</B> int => is NULL allowed.
3295:             *    <UL>
3296:             *    <LI> columnNoNulls - might not allow <code>NULL</code> values
3297:             *    <LI> columnNullable - definitely allows <code>NULL</code> values
3298:             *    <LI> columnNullableUnknown - nullability unknown
3299:             *    </UL>
3300:             *  <LI><B>REMARKS</B> String => comment describing column (may be <code>null</code>)
3301:             *  <LI><B>COLUMN_DEF</B> String => default value (may be <code>null</code>)
3302:             *  <LI><B>SQL_DATA_TYPE</B> int => unused
3303:             *  <LI><B>SQL_DATETIME_SUB</B> int => unused
3304:             *  <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the
3305:             *     maximum number of bytes in the column
3306:             *  <LI><B>ORDINAL_POSITION</B> int => index of column in table
3307:             *    (starting at 1)
3308:             *  <LI><B>IS_NULLABLE</B> String => "NO" means column definitely
3309:             *    does not allow NULL values; "YES" means the column might
3310:             *    allow NULL values.  An empty string means nobody knows.
3311:             * <LI><B>SCOPE_CATLOG</B> String => catalog of table that is the scope
3312:             *    of a reference attribute (<code>null</code> if DATA_TYPE isn't REF)
3313:             * <LI><B>SCOPE_SCHEMA</B> String => schema of table that is the scope
3314:             *    of a reference attribute (<code>null</code> if the DATA_TYPE isn't REF)
3315:             * <LI><B>SCOPE_TABLE</B> String => table name that this the scope
3316:             *    of a reference attribure (<code>null</code> if the DATA_TYPE isn't REF)
3317:             * <LI><B>SOURCE_DATA_TYPE</B> short => source type of a distinct type or user-generated
3318:             *    Ref type, SQL type from java.sql.Types (<code>null</code> if DATA_TYPE
3319:             *    isn't DISTINCT or user-generated REF)
3320:             * </OL> <p>
3321:             *
3322:             * <!-- start release-specific documentation -->
3323:             * <div class="ReleaseSpecificDocumentation">
3324:             * <h3>HSQLDB-Specific Information:</h3> <p>
3325:             *
3326:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
3327:             * them in upper case; it treats quoted identifiers as case sensitive and
3328:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
3329:             * case-sensitive comparison between name (pattern) arguments and the
3330:             * corresponding identifier values as they are stored in the database.
3331:             * Therefore, care must be taken to specify name arguments precisely
3332:             * (including case) as they are stored in the database. <p>
3333:             *
3334:             * Since 1.7.0, HSQLDB includes the new JDBC 3 columns SCOPE_CATLOG,
3335:             * SCOPE_SCHEMA, SCOPE_TABLE and SOURCE_DATA_TYPE in anticipation
3336:             * of JDBC 3 compliant tools.  However, these columns are never filled in;
3337:             * the engine does not support the related features. <p>
3338:             *
3339:             * Since 1.7.2, this feature is supported by default. If the jar is
3340:             * compiled without org.hsqldb.DatabaseInformationFull or
3341:             * org.hsqldb.DatabaseInformationMain, the feature is
3342:             * not supported. The default implementation is
3343:             * {@link org.hsqldb.DatabaseInformationFull}.
3344:             * </div>
3345:             * <!-- end release-specific documentation -->
3346:             *
3347:             * @param catalog a catalog name; must match the catalog name as it
3348:             *      is stored in the database; "" retrieves those without a catalog;
3349:             *      <code>null</code> means that the catalog name should not be used
3350:             *      to narrow the search
3351:             * @param schemaPattern a schema name pattern; must match the schema name
3352:             *      as it is stored in the database; "" retrieves those without a
3353:             *      schema; <code>null</code> means that the schema name should not be
3354:             *      used to narrow the search
3355:             * @param tableNamePattern a table name pattern; must match the
3356:             *      table name as it is stored in the database
3357:             * @param columnNamePattern a column name pattern; must match the column
3358:             *      name as it is stored in the database
3359:             * @return <code>ResultSet</code> - each row is a column description
3360:             * @exception SQLException if a database access error occurs
3361:             * @see #getSearchStringEscape
3362:             */
3363:            public ResultSet getColumns(String catalog, String schemaPattern,
3364:                    String tableNamePattern, String columnNamePattern)
3365:                    throws SQLException {
3366:
3367:                if (wantsIsNull(tableNamePattern)
3368:                        || wantsIsNull(columnNamePattern)) {
3369:                    return executeSelect("SYSTEM_COLUMNS", "0=1");
3370:                }
3371:
3372:                schemaPattern = translateSchema(schemaPattern);
3373:
3374:                StringBuffer select = toQueryPrefix("SYSTEM_COLUMNS").append(
3375:                        and("TABLE_CAT", "=", catalog)).append(
3376:                        and("TABLE_SCHEM", "LIKE", schemaPattern)).append(
3377:                        and("TABLE_NAME", "LIKE", tableNamePattern)).append(
3378:                        and("COLUMN_NAME", "LIKE", columnNamePattern));
3379:
3380:                // by default, query already returns the result ordered
3381:                // by TABLE_SCHEM, TABLE_NAME and ORDINAL_POSITION
3382:                return execute(select.toString());
3383:            }
3384:
3385:            /**
3386:             * Retrieves a description of the access rights for a table's columns.
3387:             *
3388:             * <P>Only privileges matching the column name criteria are
3389:             * returned.  They are ordered by COLUMN_NAME and PRIVILEGE.
3390:             *
3391:             * <P>Each privilige description has the following columns:
3392:             * <OL>
3393:             *  <LI><B>TABLE_CAT</B> String => table catalog (may be <code>null</code>)
3394:             *  <LI><B>TABLE_SCHEM</B> String => table schema (may be <code>null</code>)
3395:             *  <LI><B>TABLE_NAME</B> String => table name
3396:             *  <LI><B>COLUMN_NAME</B> String => column name
3397:             *  <LI><B>GRANTOR</B> => grantor of access (may be <code>null</code>)
3398:             *  <LI><B>GRANTEE</B> String => grantee of access
3399:             *  <LI><B>PRIVILEGE</B> String => name of access (SELECT,
3400:             *     INSERT, UPDATE, REFRENCES, ...)
3401:             *  <LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
3402:             *     to grant to others; "NO" if not; <code>null</code> if unknown
3403:             * </OL> <p>
3404:             *
3405:             * <!-- start release-specific documentation -->
3406:             * <div class="ReleaseSpecificDocumentation">
3407:             * <h3>HSQLDB-Specific Information:</h3> <p>
3408:             *
3409:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
3410:             * them in upper case; it treats quoted identifiers as case sensitive and
3411:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
3412:             * case-sensitive comparison between name (pattern) arguments and the
3413:             * corresponding identifier values as they are stored in the database.
3414:             * Therefore, care must be taken to specify name arguments precisely
3415:             * (including case) as they are stored in the database. <p>
3416:             *
3417:             * Since 1.7.2, this feature is supported by default. If the jar is
3418:             * compiled without org.hsqldb.DatabaseInformationFull or
3419:             * org.hsqldb.DatabaseInformationMain, the feature is
3420:             * not supported. The default implementation is
3421:             * {@link org.hsqldb.DatabaseInformationFull}.
3422:             * </div>
3423:             * <!-- end release-specific documentation -->
3424:             *
3425:             * @param catalog a catalog name; must match the catalog name as it
3426:             *       is stored in the database; "" retrieves those without a catalog;
3427:             *       <code>null</code> means that the catalog name should not be used
3428:             *       to narrow the search
3429:             * @param schema a schema name; must match the schema name as it is
3430:             *       stored in the database; "" retrieves those without a schema;
3431:             *       <code>null</code> means that the schema name should not be used
3432:             *       to narrow the search
3433:             * @param table a table name; must match the table name as it is
3434:             *       stored in the database
3435:             * @param columnNamePattern a column name pattern; must match the column
3436:             *       name as it is stored in the database
3437:             * @return <code>ResultSet</code> - each row is a column privilege
3438:             *       description
3439:             * @exception SQLException if a database access error occurs
3440:             * @see #getSearchStringEscape
3441:             */
3442:            public ResultSet getColumnPrivileges(String catalog, String schema,
3443:                    String table, String columnNamePattern) throws SQLException {
3444:
3445:                if (table == null) {
3446:                    Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
3447:                }
3448:
3449:                if (wantsIsNull(columnNamePattern)) {
3450:                    return executeSelect("SYSTEM_COLUMNPRIVILEGES", "0=1");
3451:                }
3452:
3453:                schema = translateSchema(schema);
3454:
3455:                StringBuffer select = toQueryPrefix("SYSTEM_COLUMNPRIVILEGES")
3456:                        .append(and("TABLE_CAT", "=", catalog)).append(
3457:                                and("TABLE_SCHEM", "=", schema)).append(
3458:                                and("TABLE_NAME", "=", table)).append(
3459:                                and("COLUMN_NAME", "LIKE", columnNamePattern));
3460:
3461:                // By default, the query already returns the result
3462:                // ordered by column name, privilege...
3463:                return execute(select.toString());
3464:            }
3465:
3466:            /**
3467:             * Retrieves a description of the access rights for each table available
3468:             * in a catalog. Note that a table privilege applies to one or
3469:             * more columns in the table. It would be wrong to assume that
3470:             * this privilege applies to all columns (this may be true for
3471:             * some systems but is not true for all.)
3472:             *
3473:             * <P>Only privileges matching the schema and table name
3474:             * criteria are returned.  They are ordered by TABLE_SCHEM,
3475:             * TABLE_NAME, and PRIVILEGE.
3476:             *
3477:             * <P>Each privilige description has the following columns:
3478:             * <OL>
3479:             *  <LI><B>TABLE_CAT</B> String => table catalog (may be <code>null</code>)
3480:             *  <LI><B>TABLE_SCHEM</B> String => table schema (may be <code>null</code>)
3481:             *  <LI><B>TABLE_NAME</B> String => table name
3482:             *  <LI><B>GRANTOR</B> => grantor of access (may be <code>null</code>)
3483:             *  <LI><B>GRANTEE</B> String => grantee of access
3484:             *  <LI><B>PRIVILEGE</B> String => name of access (SELECT,
3485:             *     INSERT, UPDATE, REFRENCES, ...)
3486:             *  <LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
3487:             *     to grant to others; "NO" if not; <code>null</code> if unknown
3488:             * </OL> <p>
3489:             *
3490:             * <!-- start release-specific documentation -->
3491:             * <div class="ReleaseSpecificDocumentation">
3492:             * <h3>HSQLDB-Specific Information:</h3> <p>
3493:             *
3494:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
3495:             * them in upper case; it treats quoted identifiers as case sensitive and
3496:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
3497:             * case-sensitive comparison between name (pattern) arguments and the
3498:             * corresponding identifier values as they are stored in the database.
3499:             * Therefore, care must be taken to specify name arguments precisely
3500:             * (including case) as they are stored in the database. <p>
3501:             *
3502:             * Since 1.7.2, this feature is supported by default. If the jar is
3503:             * compiled without org.hsqldb.DatabaseInformationFull or
3504:             * org.hsqldb.DatabaseInformationMain, the feature is
3505:             * not supported. The default implementation is
3506:             * {@link org.hsqldb.DatabaseInformationFull}.
3507:             * </div>
3508:             * <!-- end release-specific documentation -->
3509:             *
3510:             * @param catalog a catalog name; must match the catalog name as it
3511:             *       is stored in the database; "" retrieves those without a catalog;
3512:             *       <code>null</code> means that the catalog name should not be used
3513:             *       to narrow the search
3514:             * @param schemaPattern a schema name pattern; must match the schema name
3515:             *       as it is stored in the database; "" retrieves those without a
3516:             *       schema; <code>null</code> means that the schema name should not be
3517:             *       used to narrow the search
3518:             * @param tableNamePattern a table name pattern; must match the
3519:             *       table name as it is stored in the database
3520:             * @return <code>ResultSet</code> - each row is a table privilege
3521:             *       description
3522:             * @exception SQLException if a database access error occurs
3523:             * @see #getSearchStringEscape
3524:             */
3525:            public ResultSet getTablePrivileges(String catalog,
3526:                    String schemaPattern, String tableNamePattern)
3527:                    throws SQLException {
3528:
3529:                if (wantsIsNull(tableNamePattern)) {
3530:                    return executeSelect("SYSTEM_TABLEPRIVILEGES", "0=1");
3531:                }
3532:
3533:                schemaPattern = translateSchema(schemaPattern);
3534:
3535:                StringBuffer select = toQueryPrefix("SYSTEM_TABLEPRIVILEGES")
3536:                        .append(and("TABLE_CAT", "=", catalog)).append(
3537:                                and("TABLE_SCHEM", "LIKE", schemaPattern))
3538:                        .append(and("TABLE_NAME", "LIKE", tableNamePattern));
3539:
3540:                // By default, the query already returns a result ordered by
3541:                // TABLE_SCHEM, TABLE_NAME, and PRIVILEGE...
3542:                return execute(select.toString());
3543:            }
3544:
3545:            /**
3546:             * Retrieves a description of a table's optimal set of columns that
3547:             * uniquely identifies a row. They are ordered by SCOPE.
3548:             *
3549:             * <P>Each column description has the following columns:
3550:             * <OL>
3551:             *  <LI><B>SCOPE</B> short => actual scope of result
3552:             *     <UL>
3553:             *     <LI> bestRowTemporary - very temporary, while using row
3554:             *     <LI> bestRowTransaction - valid for remainder of current transaction
3555:             *     <LI> bestRowSession - valid for remainder of current session
3556:             *     </UL>
3557:             *  <LI><B>COLUMN_NAME</B> String => column name
3558:             *  <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
3559:             *  <LI><B>TYPE_NAME</B> String => Data source dependent type name,
3560:             * for a UDT the type name is fully qualified
3561:             *  <LI><B>COLUMN_SIZE</B> int => precision
3562:             *  <LI><B>BUFFER_LENGTH</B> int => not used
3563:             *  <LI><B>DECIMAL_DIGITS</B> short  => scale
3564:             *  <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column
3565:             *     like an Oracle ROWID
3566:             *     <UL>
3567:             *     <LI> bestRowUnknown - may or may not be pseudo column
3568:             *     <LI> bestRowNotPseudo - is NOT a pseudo column
3569:             *     <LI> bestRowPseudo - is a pseudo column
3570:             *     </UL>
3571:             * </OL> <p>
3572:             *
3573:             * <!-- start release-specific documentation -->
3574:             * <div class="ReleaseSpecificDocumentation">
3575:             * <h3>HSQLDB-Specific Information:</h3> <p>
3576:             *
3577:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
3578:             * them in upper case; it treats quoted identifiers as case sensitive and
3579:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
3580:             * case-sensitive comparison between name (pattern) arguments and the
3581:             * corresponding identifier values as they are stored in the database.
3582:             * Therefore, care must be taken to specify name arguments precisely
3583:             * (including case) as they are stored in the database. <p>
3584:             *
3585:             * If the name of a column is defined in the database without double
3586:             * quotes, an all-uppercase name must be specified when calling this
3587:             * method. Otherwise, the name must be specified in the exact case of
3588:             * the column definition in the database. <p>
3589:             *
3590:             * Since 1.7.2, this feature is supported by default. If the jar is
3591:             * compiled without org.hsqldb.DatabaseInformationFull or
3592:             * org.hsqldb.DatabaseInformationMain, the feature is
3593:             * not supported. The default implementation is
3594:             * {@link org.hsqldb.DatabaseInformationFull}.
3595:             * </div>
3596:             * <!-- end release-specific documentation -->
3597:             *
3598:             * @param catalog a catalog name; must match the catalog name as it
3599:             *       is stored in the database; "" retrieves those without a catalog;
3600:             *       <code>null</code> means that the catalog name should not be used
3601:             *       to narrow the search
3602:             * @param schema a schema name; must match the schema name
3603:             *       as it is stored in the database; "" retrieves those without a
3604:             *       schema; <code>null</code> means that the schema name should not
3605:             *       be used to narrow the search
3606:             * @param table a table name; must match the table name as it is stored
3607:             *       in the database
3608:             * @param scope the scope of interest; use same values as SCOPE
3609:             * @param nullable include columns that are nullable.
3610:             * @return <code>ResultSet</code> - each row is a column description
3611:             * @exception SQLException if a database access error occurs
3612:             */
3613:            public ResultSet getBestRowIdentifier(String catalog,
3614:                    String schema, String table, int scope, boolean nullable)
3615:                    throws SQLException {
3616:
3617:                String scopeIn;
3618:
3619:                switch (scope) {
3620:
3621:                case bestRowTemporary:
3622:                    scopeIn = BRI_TEMPORARY_SCOPE_IN_LIST;
3623:                    break;
3624:
3625:                case bestRowTransaction:
3626:                    scopeIn = BRI_TRANSACTION_SCOPE_IN_LIST;
3627:                    break;
3628:
3629:                case bestRowSession:
3630:                    scopeIn = BRI_SESSION_SCOPE_IN_LIST;
3631:                    break;
3632:
3633:                default:
3634:                    throw Util.sqlException(Trace.ASSERT_FAILED,
3635:                            Trace.JDBC_INVALID_BRI_SCOPE, null);
3636:                }
3637:
3638:                if (table == null) {
3639:                    Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
3640:                }
3641:
3642:                schema = translateSchema(schema);
3643:
3644:                Integer Nullable = (nullable) ? null : INT_COLUMNS_NO_NULLS;
3645:                StringBuffer select = toQueryPrefix("SYSTEM_BESTROWIDENTIFIER")
3646:                        .append(and("TABLE_CAT", "=", catalog)).append(
3647:                                and("TABLE_SCHEM", "=", schema)).append(
3648:                                and("TABLE_NAME", "=", table)).append(
3649:                                and("NULLABLE", "=", Nullable)).append(
3650:                                " AND SCOPE IN " + scopeIn);
3651:
3652:                // By default, query already returns rows in contract order.
3653:                // However, the way things are set up, there should never be
3654:                // a result where there is > 1 distinct scope value:  most requests
3655:                // will want only one table and the system table producer (for
3656:                // now) guarantees that a maximum of one BRI scope column set is
3657:                // produced for each table
3658:                return execute(select.toString());
3659:            }
3660:
3661:            /**
3662:             * Retrieves a description of a table's columns that are automatically
3663:             * updated when any value in a row is updated.  They are
3664:             * unordered.
3665:             *
3666:             * <P>Each column description has the following columns:
3667:             * <OL>
3668:             *  <LI><B>SCOPE</B> short => is not used
3669:             *  <LI><B>COLUMN_NAME</B> String => column name
3670:             *  <LI><B>DATA_TYPE</B> short => SQL data type from <code>java.sql.Types</code>
3671:             *  <LI><B>TYPE_NAME</B> String => Data source-dependent type name
3672:             *  <LI><B>COLUMN_SIZE</B> int => precision
3673:             *  <LI><B>BUFFER_LENGTH</B> int => length of column value in bytes
3674:             *  <LI><B>DECIMAL_DIGITS</B> short  => scale
3675:             *  <LI><B>PSEUDO_COLUMN</B> short => whether this is pseudo column
3676:             *     like an Oracle ROWID
3677:             *     <UL>
3678:             *     <LI> versionColumnUnknown - may or may not be pseudo column
3679:             *     <LI> versionColumnNotPseudo - is NOT a pseudo column
3680:             *     <LI> versionColumnPseudo - is a pseudo column
3681:             *     </UL>
3682:             * </OL> <p>
3683:             *
3684:             * <!-- start release-specific documentation -->
3685:             * <div class="ReleaseSpecificDocumentation">
3686:             * <h3>HSQLDB-Specific Information:</h3> <p>
3687:             *
3688:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
3689:             * them in upper case; it treats quoted identifiers as case sensitive and
3690:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
3691:             * case-sensitive comparison between name (pattern) arguments and the
3692:             * corresponding identifier values as they are stored in the database.
3693:             * Therefore, care must be taken to specify name arguments precisely
3694:             * (including case) as they are stored in the database. <p>
3695:             *
3696:             * Since 1.7.2, this feature is supported by default. If the jar is
3697:             * compiled without org.hsqldb.DatabaseInformationFull or
3698:             * org.hsqldb.DatabaseInformationMain, the feature is
3699:             * not supported. The default implementation is
3700:             * {@link org.hsqldb.DatabaseInformationFull}.
3701:             * </div>
3702:             * <!-- end release-specific documentation -->
3703:             *
3704:             * @param catalog a catalog name; must match the catalog name as it
3705:             *       is stored in the database; "" retrieves those without a catalog;
3706:             *       <code>null</code> means that the catalog name should not be used
3707:             *       to narrow the search
3708:             * @param schema a schema name; must match the schema name
3709:             *       as it is stored in the database; "" retrieves those without a
3710:             *       schema; <code>null</code> means that the schema name should not be
3711:             *       used to narrow the search
3712:             * @param table a table name; must match the table name as it is stored
3713:             *       in the database
3714:             * @return a <code>ResultSet</code> object in which each row is a
3715:             *        column description
3716:             * @exception SQLException if a database access error occurs
3717:             */
3718:            public ResultSet getVersionColumns(String catalog, String schema,
3719:                    String table) throws SQLException {
3720:
3721:                if (table == null) {
3722:                    Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
3723:                }
3724:
3725:                schema = translateSchema(schema);
3726:
3727:                StringBuffer select = toQueryPrefix("SYSTEM_VERSIONCOLUMNS")
3728:                        .append(and("TABLE_CAT", "=", catalog)).append(
3729:                                and("TABLE_SCHEM", "=", schema)).append(
3730:                                and("TABLE_NAME", "=", table));
3731:
3732:                // result does not need to be ordered
3733:                return execute(select.toString());
3734:            }
3735:
3736:            /**
3737:             * Retrieves a description of the given table's primary key columns.  They
3738:             * are ordered by COLUMN_NAME.
3739:             *
3740:             * <P>Each primary key column description has the following columns:
3741:             *  <OL>
3742:             *  <LI><B>TABLE_CAT</B> String => table catalog (may be <code>null</code>)
3743:             *  <LI><B>TABLE_SCHEM</B> String => table schema (may be <code>null</code>)
3744:             *  <LI><B>TABLE_NAME</B> String => table name
3745:             *  <LI><B>COLUMN_NAME</B> String => column name
3746:             *  <LI><B>KEY_SEQ</B> short => sequence number within primary key
3747:             *  <LI><B>PK_NAME</B> String => primary key name (may be <code>null</code>)
3748:             *  </OL> <p>
3749:             *
3750:             * <!-- start release-specific documentation -->
3751:             * <div class="ReleaseSpecificDocumentation">
3752:             * <h3>HSQLDB-Specific Information:</h3> <p>
3753:             *
3754:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
3755:             * them in upper case; it treats quoted identifiers as case sensitive and
3756:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
3757:             * case-sensitive comparison between name (pattern) arguments and the
3758:             * corresponding identifier values as they are stored in the database.
3759:             * Therefore, care must be taken to specify name arguments precisely
3760:             * (including case) as they are stored in the database. <p>
3761:             *
3762:             * Since 1.7.2, this feature is supported by default. If the jar is
3763:             * compiled without org.hsqldb.DatabaseInformationFull or
3764:             * org.hsqldb.DatabaseInformationMain, the feature is
3765:             * not supported. The default implementation is
3766:             * {@link org.hsqldb.DatabaseInformationFull}.
3767:             * </div>
3768:             * <!-- end release-specific documentation -->
3769:             *
3770:             * @param catalog a catalog name; must match the catalog name as it
3771:             *        is stored in the database; "" retrieves those without a catalog;
3772:             *        <code>null</code> means that the catalog name should not be used
3773:             *        to narrow the search
3774:             * @param schema a schema name; must match the schema name
3775:             *        as it is stored in the database; "" retrieves those without a
3776:             *        schema; <code>null</code> means that the schema name should not
3777:             *        be used to narrow the search
3778:             * @param table a table name; must match the table name as it is stored
3779:             *        in the database
3780:             * @return <code>ResultSet</code> - each row is a primary key column
3781:             *        description
3782:             * @exception SQLException if a database access error occurs
3783:             * @see #supportsMixedCaseQuotedIdentifiers
3784:             * @see #storesUpperCaseIdentifiers
3785:             */
3786:
3787:            // fredt@users 20020226 - comment - changed query to exact name
3788:            public ResultSet getPrimaryKeys(String catalog, String schema,
3789:                    String table) throws SQLException {
3790:
3791:                if (table == null) {
3792:                    Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
3793:                }
3794:
3795:                schema = translateSchema(schema);
3796:
3797:                StringBuffer select = toQueryPrefix("SYSTEM_PRIMARYKEYS")
3798:                        .append(and("TABLE_CAT", "=", catalog)).append(
3799:                                and("TABLE_SCHEM", "=", schema)).append(
3800:                                and("TABLE_NAME", "=", table));
3801:
3802:                // By default, query already returns result in contract order
3803:                return execute(select.toString());
3804:            }
3805:
3806:            /**
3807:             * Retrieves a description of the primary key columns that are
3808:             * referenced by a table's foreign key columns (the primary keys
3809:             * imported by a table).  They are ordered by PKTABLE_CAT,
3810:             * PKTABLE_SCHEM, PKTABLE_NAME, and KEY_SEQ.
3811:             *
3812:             * <P>Each primary key column description has the following columns:
3813:             * <OL>
3814:             *  <LI><B>PKTABLE_CAT</B> String => primary key table catalog
3815:             *     being imported (may be <code>null</code>)
3816:             *  <LI><B>PKTABLE_SCHEM</B> String => primary key table schema
3817:             *     being imported (may be <code>null</code>)
3818:             *  <LI><B>PKTABLE_NAME</B> String => primary key table name
3819:             *     being imported
3820:             *  <LI><B>PKCOLUMN_NAME</B> String => primary key column name
3821:             *     being imported
3822:             *  <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be <code>null</code>)
3823:             *  <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be <code>null</code>)
3824:             *  <LI><B>FKTABLE_NAME</B> String => foreign key table name
3825:             *  <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
3826:             *  <LI><B>KEY_SEQ</B> short => sequence number within a foreign key
3827:             *  <LI><B>UPDATE_RULE</B> short => What happens to a
3828:             *      foreign key when the primary key is updated:
3829:             *     <UL>
3830:             *     <LI> importedNoAction - do not allow update of primary
3831:             *              key if it has been imported
3832:             *     <LI> importedKeyCascade - change imported key to agree
3833:             *              with primary key update
3834:             *     <LI> importedKeySetNull - change imported key to <code>NULL</code>
3835:             *              if its primary key has been updated
3836:             *     <LI> importedKeySetDefault - change imported key to default values
3837:             *              if its primary key has been updated
3838:             *     <LI> importedKeyRestrict - same as importedKeyNoAction
3839:             *                                (for ODBC 2.x compatibility)
3840:             *     </UL>
3841:             *  <LI><B>DELETE_RULE</B> short => What happens to
3842:             *     the foreign key when primary is deleted.
3843:             *     <UL>
3844:             *     <LI> importedKeyNoAction - do not allow delete of primary
3845:             *              key if it has been imported
3846:             *     <LI> importedKeyCascade - delete rows that import a deleted key
3847:             *     <LI> importedKeySetNull - change imported key to NULL if
3848:             *              its primary key has been deleted
3849:             *     <LI> importedKeyRestrict - same as importedKeyNoAction
3850:             *                                (for ODBC 2.x compatibility)
3851:             *     <LI> importedKeySetDefault - change imported key to default if
3852:             *              its primary key has been deleted
3853:             *     </UL>
3854:             *  <LI><B>FK_NAME</B> String => foreign key name (may be <code>null</code>)
3855:             *  <LI><B>PK_NAME</B> String => primary key name (may be <code>null</code>)
3856:             *  <LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key
3857:             *     constraints be deferred until commit
3858:             *     <UL>
3859:             *     <LI> importedKeyInitiallyDeferred - see SQL92 for definition
3860:             *     <LI> importedKeyInitiallyImmediate - see SQL92 for definition
3861:             *     <LI> importedKeyNotDeferrable - see SQL92 for definition
3862:             *     </UL>
3863:             * </OL> <p>
3864:             *
3865:             * <!-- start release-specific documentation -->
3866:             * <div class="ReleaseSpecificDocumentation">
3867:             * <h3>HSQLDB-Specific Information:</h3> <p>
3868:             *
3869:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
3870:             * them in upper case; it treats quoted identifiers as case sensitive and
3871:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
3872:             * case-sensitive comparison between name (pattern) arguments and the
3873:             * corresponding identifier values as they are stored in the database.
3874:             * Therefore, care must be taken to specify name arguments precisely
3875:             * (including case) as they are stored in the database. <p>
3876:             *
3877:             * Since 1.7.2, this feature is supported by default. If the jar is
3878:             * compiled without org.hsqldb.DatabaseInformationFull or
3879:             * org.hsqldb.DatabaseInformationMain, the feature is
3880:             * not supported. The default implementation is
3881:             * {@link org.hsqldb.DatabaseInformationFull}.
3882:             * </div>
3883:             * <!-- end release-specific documentation -->
3884:             *
3885:             * @param catalog a catalog name; must match the catalog name as it
3886:             *       is stored in the database; "" retrieves those without a catalog;
3887:             *       <code>null</code> means that the catalog name should not be used
3888:             *       to narrow the search
3889:             * @param schema a schema name; must match the schema name
3890:             *       as it is stored in the database; "" retrieves those without a
3891:             *       schema; <code>null</code> means that the schema name should not be
3892:             *       used to narrow the search
3893:             * @param table a table name; must match the table name as it is stored
3894:             *       in the database
3895:             * @return <code>ResultSet</code> - each row is a primary key column
3896:             *       description
3897:             * @exception SQLException if a database access error occurs
3898:             * @see #getExportedKeys
3899:             * @see #supportsMixedCaseQuotedIdentifiers
3900:             * @see #storesUpperCaseIdentifiers
3901:             */
3902:            public ResultSet getImportedKeys(String catalog, String schema,
3903:                    String table) throws SQLException {
3904:
3905:                if (table == null) {
3906:                    Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
3907:                }
3908:
3909:                schema = translateSchema(schema);
3910:
3911:                StringBuffer select = toQueryPrefix("SYSTEM_CROSSREFERENCE")
3912:                        .append(and("FKTABLE_CAT", "=", catalog))
3913:                        .append(and("FKTABLE_SCHEM", "=", schema))
3914:                        .append(and("FKTABLE_NAME", "=", table))
3915:                        .append(
3916:                                " ORDER BY PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME, KEY_SEQ");
3917:
3918:                return execute(select.toString());
3919:            }
3920:
3921:            /**
3922:             * Retrieves a description of the foreign key columns that reference the
3923:             * given table's primary key columns (the foreign keys exported by a
3924:             * table).  They are ordered by FKTABLE_CAT, FKTABLE_SCHEM,
3925:             * FKTABLE_NAME, and KEY_SEQ.
3926:             *
3927:             * <P>Each foreign key column description has the following columns:
3928:             * <OL>
3929:             *  <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be <code>null</code>)
3930:             *  <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be <code>null</code>)
3931:             *  <LI><B>PKTABLE_NAME</B> String => primary key table name
3932:             *  <LI><B>PKCOLUMN_NAME</B> String => primary key column name
3933:             *  <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be <code>null</code>)
3934:             *    being exported (may be <code>null</code>)
3935:             *  <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be <code>null</code>)
3936:             *    being exported (may be <code>null</code>)
3937:             *  <LI><B>FKTABLE_NAME</B> String => foreign key table name
3938:             *    being exported
3939:             *  <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
3940:             *    being exported
3941:             *  <LI><B>KEY_SEQ</B> short => sequence number within foreign key
3942:             *  <LI><B>UPDATE_RULE</B> short => What happens to
3943:             *     foreign key when primary is updated:
3944:             *    <UL>
3945:             *    <LI> importedNoAction - do not allow update of primary
3946:             *             key if it has been imported
3947:             *    <LI> importedKeyCascade - change imported key to agree
3948:             *             with primary key update
3949:             *    <LI> importedKeySetNull - change imported key to <code>NULL</code> if
3950:             *             its primary key has been updated
3951:             *    <LI> importedKeySetDefault - change imported key to default values
3952:             *             if its primary key has been updated
3953:             *    <LI> importedKeyRestrict - same as importedKeyNoAction
3954:             *                               (for ODBC 2.x compatibility)
3955:             *    </UL>
3956:             *  <LI><B>DELETE_RULE</B> short => What happens to
3957:             *    the foreign key when primary is deleted.
3958:             *    <UL>
3959:             *    <LI> importedKeyNoAction - do not allow delete of primary
3960:             *             key if it has been imported
3961:             *    <LI> importedKeyCascade - delete rows that import a deleted key
3962:             *    <LI> importedKeySetNull - change imported key to <code>NULL</code> if
3963:             *             its primary key has been deleted
3964:             *    <LI> importedKeyRestrict - same as importedKeyNoAction
3965:             *                               (for ODBC 2.x compatibility)
3966:             *    <LI> importedKeySetDefault - change imported key to default if
3967:             *             its primary key has been deleted
3968:             *    </UL>
3969:             *  <LI><B>FK_NAME</B> String => foreign key name (may be <code>null</code>)
3970:             *  <LI><B>PK_NAME</B> String => primary key name (may be <code>null</code>)
3971:             *  <LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key
3972:             *    constraints be deferred until commit
3973:             *    <UL>
3974:             *    <LI> importedKeyInitiallyDeferred - see SQL92 for definition
3975:             *    <LI> importedKeyInitiallyImmediate - see SQL92 for definition
3976:             *    <LI> importedKeyNotDeferrable - see SQL92 for definition
3977:             *    </UL>
3978:             * </OL> <p>
3979:             *
3980:             * <!-- start release-specific documentation -->
3981:             * <div class="ReleaseSpecificDocumentation">
3982:             * <h3>HSQLDB-Specific Information:</h3> <p>
3983:             *
3984:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
3985:             * them in upper case; it treats quoted identifiers as case sensitive and
3986:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
3987:             * case-sensitive comparison between name (pattern) arguments and the
3988:             * corresponding identifier values as they are stored in the database.
3989:             * Therefore, care must be taken to specify name arguments precisely
3990:             * (including case) as they are stored in the database. <p>
3991:             *
3992:             * Since 1.7.2, this feature is supported by default. If the jar is
3993:             * compiled without org.hsqldb.DatabaseInformationFull or
3994:             * org.hsqldb.DatabaseInformationMain, the feature is
3995:             * not supported. The default implementation is
3996:             * {@link org.hsqldb.DatabaseInformationFull}.
3997:             * </div>
3998:             * <!-- end release-specific documentation -->
3999:             *
4000:             * @param catalog a catalog name; must match the catalog name as it
4001:             *      is stored in this database; "" retrieves those without a catalog;
4002:             *      <code>null</code> means that the catalog name should not be used
4003:             *      to narrow the search
4004:             * @param schema a schema name; must match the schema name
4005:             *      as it is stored in the database; "" retrieves those without a
4006:             *      schema; <code>null</code> means that the schema name should not be
4007:             *      used to narrow the search
4008:             * @param table a table name; must match the table name as it is stored
4009:             *      in this database
4010:             * @return a <code>ResultSet</code> object in which each row is a
4011:             *       foreign key column description
4012:             * @exception SQLException if a database access error occurs
4013:             * @see #getImportedKeys
4014:             * @see #supportsMixedCaseQuotedIdentifiers
4015:             * @see #storesUpperCaseIdentifiers
4016:             */
4017:            public ResultSet getExportedKeys(String catalog, String schema,
4018:                    String table) throws SQLException {
4019:
4020:                if (table == null) {
4021:                    Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
4022:                }
4023:
4024:                schema = translateSchema(schema);
4025:
4026:                StringBuffer select = toQueryPrefix("SYSTEM_CROSSREFERENCE")
4027:                        .append(and("PKTABLE_CAT", "=", catalog)).append(
4028:                                and("PKTABLE_SCHEM", "=", schema)).append(
4029:                                and("PKTABLE_NAME", "=", table));
4030:
4031:                // By default, query already returns the table ordered by
4032:                // FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and KEY_SEQ.
4033:                return execute(select.toString());
4034:            }
4035:
4036:            /**
4037:             * Retrieves a description of the foreign key columns in the given foreign key
4038:             * table that reference the primary key columns of the given primary key
4039:             * table (describe how one table imports another's key). This
4040:             * should normally return a single foreign key/primary key pair because
4041:             * most tables import a foreign key from a table only once.  They
4042:             * are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and
4043:             * KEY_SEQ.
4044:             *
4045:             * <P>Each foreign key column description has the following columns:
4046:             * <OL>
4047:             *  <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be <code>null</code>)
4048:             *  <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be <code>null</code>)
4049:             *  <LI><B>PKTABLE_NAME</B> String => primary key table name
4050:             *  <LI><B>PKCOLUMN_NAME</B> String => primary key column name
4051:             *  <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be <code>null</code>)
4052:             *    being exported (may be <code>null</code>)
4053:             *  <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be <code>null</code>)
4054:             *    being exported (may be <code>null</code>)
4055:             *  <LI><B>FKTABLE_NAME</B> String => foreign key table name
4056:             *    being exported
4057:             *  <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
4058:             *    being exported
4059:             *  <LI><B>KEY_SEQ</B> short => sequence number within foreign key
4060:             *  <LI><B>UPDATE_RULE</B> short => What happens to
4061:             *     foreign key when primary is updated:
4062:             *    <UL>
4063:             *    <LI> importedNoAction - do not allow update of primary
4064:             *             key if it has been imported
4065:             *    <LI> importedKeyCascade - change imported key to agree
4066:             *             with primary key update
4067:             *    <LI> importedKeySetNull - change imported key to <code>NULL</code> if
4068:             *             its primary key has been updated
4069:             *    <LI> importedKeySetDefault - change imported key to default values
4070:             *             if its primary key has been updated
4071:             *    <LI> importedKeyRestrict - same as importedKeyNoAction
4072:             *                               (for ODBC 2.x compatibility)
4073:             *    </UL>
4074:             *  <LI><B>DELETE_RULE</B> short => What happens to
4075:             *    the foreign key when primary is deleted.
4076:             *    <UL>
4077:             *    <LI> importedKeyNoAction - do not allow delete of primary
4078:             *             key if it has been imported
4079:             *    <LI> importedKeyCascade - delete rows that import a deleted key
4080:             *    <LI> importedKeySetNull - change imported key to <code>NULL</code> if
4081:             *             its primary key has been deleted
4082:             *    <LI> importedKeyRestrict - same as importedKeyNoAction
4083:             *                               (for ODBC 2.x compatibility)
4084:             *    <LI> importedKeySetDefault - change imported key to default if
4085:             *             its primary key has been deleted
4086:             *    </UL>
4087:             *  <LI><B>FK_NAME</B> String => foreign key name (may be <code>null</code>)
4088:             *  <LI><B>PK_NAME</B> String => primary key name (may be <code>null</code>)
4089:             *  <LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key
4090:             *    constraints be deferred until commit
4091:             *    <UL>
4092:             *    <LI> importedKeyInitiallyDeferred - see SQL92 for definition
4093:             *    <LI> importedKeyInitiallyImmediate - see SQL92 for definition
4094:             *    <LI> importedKeyNotDeferrable - see SQL92 for definition
4095:             *    </UL>
4096:             * </OL> <p>
4097:             *
4098:             * <!-- start release-specific documentation -->
4099:             * <div class="ReleaseSpecificDocumentation">
4100:             * <h3>HSQLDB-Specific Information:</h3> <p>
4101:             *
4102:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
4103:             * them in upper case; it treats quoted identifiers as case sensitive and
4104:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
4105:             * case-sensitive comparison between name (pattern) arguments and the
4106:             * corresponding identifier values as they are stored in the database.
4107:             * Therefore, care must be taken to specify name arguments precisely
4108:             * (including case) as they are stored in the database. <p>
4109:             *
4110:             * Since 1.7.2, this feature is supported by default. If the jar is
4111:             * compiled without org.hsqldb.DatabaseInformationFull or
4112:             * org.hsqldb.DatabaseInformationMain, the feature is
4113:             * not supported. The default implementation is
4114:             * {@link org.hsqldb.DatabaseInformationFull}.
4115:             * </div>
4116:             * <!-- end release-specific documentation -->
4117:             *
4118:             * @param primaryCatalog a catalog name; must match the catalog name
4119:             * as it is stored in the database; "" retrieves those without a
4120:             *      catalog; <code>null</code> means drop catalog name from the
4121:             *      selection criteria
4122:             * @param primarySchema a schema name; must match the schema name as
4123:             * it is stored in the database; "" retrieves those without a schema;
4124:             * <code>null</code> means drop schema name from the selection criteria
4125:             * @param primaryTable the name of the table that exports the key; must
4126:             *      match the table name as it is stored in the database
4127:             * @param foreignCatalog a catalog name; must match the catalog name as
4128:             * it is stored in the database; "" retrieves those without a
4129:             *      catalog; <code>null</code> means drop catalog name from the
4130:             *      selection criteria
4131:             * @param foreignSchema a schema name; must match the schema name as it
4132:             * is stored in the database; "" retrieves those without a schema;
4133:             * <code>null</code> means drop schema name from the selection criteria
4134:             * @param foreignTable the name of the table that imports the key; must
4135:             *      match the table name as it is stored in the database
4136:             * @return <code>ResultSet</code> - each row is a foreign key column
4137:             *      description
4138:             * @exception SQLException if a database access error occurs
4139:             * @see #getImportedKeys
4140:             * @see #supportsMixedCaseQuotedIdentifiers
4141:             * @see #storesUpperCaseIdentifiers
4142:             */
4143:            public ResultSet getCrossReference(String primaryCatalog,
4144:                    String primarySchema, String primaryTable,
4145:                    String foreignCatalog, String foreignSchema,
4146:                    String foreignTable) throws SQLException {
4147:
4148:                if (primaryTable == null || foreignTable == null) {
4149:                    Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
4150:                }
4151:
4152:                primarySchema = translateSchema(primarySchema);
4153:                foreignSchema = translateSchema(foreignSchema);
4154:
4155:                StringBuffer select = toQueryPrefix("SYSTEM_CROSSREFERENCE")
4156:                        .append(and("PKTABLE_CAT", "=", primaryCatalog))
4157:                        .append(and("PKTABLE_SCHEM", "=", primarySchema))
4158:                        .append(and("PKTABLE_NAME", "=", primaryTable)).append(
4159:                                and("FKTABLE_CAT", "=", foreignCatalog))
4160:                        .append(and("FKTABLE_SCHEM", "=", foreignSchema))
4161:                        .append(and("FKTABLE_NAME", "=", foreignTable));
4162:
4163:                // by default, query already returns the table ordered by
4164:                // FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and KEY_SEQ.
4165:                return execute(select.toString());
4166:            }
4167:
4168:            /**
4169:             * Retrieves a description of all the standard SQL types supported by
4170:             * this database. They are ordered by DATA_TYPE and then by how
4171:             * closely the data type maps to the corresponding JDBC SQL type.
4172:             *
4173:             * <P>Each type description has the following columns:
4174:             * <OL>
4175:             *  <LI><B>TYPE_NAME</B> String => Type name
4176:             *  <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
4177:             *  <LI><B>PRECISION</B> int => maximum precision
4178:             *  <LI><B>LITERAL_PREFIX</B> String => prefix used to quote a literal
4179:             *     (may be <code>null</code>)
4180:             *  <LI><B>LITERAL_SUFFIX</B> String => suffix used to quote a literal
4181:             * (may be <code>null</code>)
4182:             *  <LI><B>CREATE_PARAMS</B> String => parameters used in creating
4183:             *     the type (may be <code>null</code>)
4184:             *  <LI><B>NULLABLE</B> short => can you use NULL for this type.
4185:             *     <UL>
4186:             *     <LI> typeNoNulls - does not allow NULL values
4187:             *     <LI> typeNullable - allows NULL values
4188:             *     <LI> typeNullableUnknown - nullability unknown
4189:             *     </UL>
4190:             *  <LI><B>CASE_SENSITIVE</B> boolean=> is it case sensitive.
4191:             *  <LI><B>SEARCHABLE</B> short => can you use "WHERE" based on this type:
4192:             *     <UL>
4193:             *     <LI> typePredNone - No support
4194:             *     <LI> typePredChar - Only supported with WHERE .. LIKE
4195:             *     <LI> typePredBasic - Supported except for WHERE .. LIKE
4196:             *     <LI> typeSearchable - Supported for all WHERE ..
4197:             *     </UL>
4198:             *  <LI><B>UNSIGNED_ATTRIBUTE</B> boolean => is it unsigned.
4199:             *  <LI><B>FIXED_PREC_SCALE</B> boolean => can it be a money value.
4200:             *  <LI><B>AUTO_INCREMENT</B> boolean => can it be used for an
4201:             *     auto-increment value.
4202:             *  <LI><B>LOCAL_TYPE_NAME</B> String => localized version of type name
4203:             *     (may be <code>null</code>)
4204:             *  <LI><B>MINIMUM_SCALE</B> short => minimum scale supported
4205:             *  <LI><B>MAXIMUM_SCALE</B> short => maximum scale supported
4206:             *  <LI><B>SQL_DATA_TYPE</B> int => unused
4207:             *  <LI><B>SQL_DATETIME_SUB</B> int => unused
4208:             *  <LI><B>NUM_PREC_RADIX</B> int => usually 2 or 10
4209:             * </OL> <p>
4210:             *
4211:             * <!-- start release-specific documentation -->
4212:             * <div class="ReleaseSpecificDocumentation">
4213:             * <h3>HSQLDB-Specific Information:</h3> <p>
4214:             *
4215:             * Since 1.7.2, this feature is supported by default. If the jar is
4216:             * compiled without org.hsqldb.DatabaseInformationFull or
4217:             * org.hsqldb.DatabaseInformationMain, the feature is
4218:             * not supported. The default implementation is
4219:             * {@link org.hsqldb.DatabaseInformationFull}.
4220:             * </div>
4221:             * <!-- end release-specific documentation -->
4222:             *
4223:             * @return a <code>ResultSet</code> object in which each row is an SQL
4224:             *        type description
4225:             * @exception SQLException if a database access error occurs
4226:             */
4227:            public ResultSet getTypeInfo() throws SQLException {
4228:
4229:                // system table producer returns rows in contract order
4230:                return executeSelect("SYSTEM_TYPEINFO", null);
4231:            }
4232:
4233:            /**
4234:             * Retrieves a description of the given table's indices and statistics. They are
4235:             * ordered by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION.
4236:             *
4237:             * <P>Each index column description has the following columns:
4238:             * <OL>
4239:             *  <LI><B>TABLE_CAT</B> String => table catalog (may be <code>null</code>)
4240:             *  <LI><B>TABLE_SCHEM</B> String => table schema (may be <code>null</code>)
4241:             *  <LI><B>TABLE_NAME</B> String => table name
4242:             *  <LI><B>NON_UNIQUE</B> boolean => Can index values be non-unique.
4243:             *     false when TYPE is tableIndexStatistic
4244:             *  <LI><B>INDEX_QUALIFIER</B> String => index catalog (may be <code>null</code>);
4245:             *     <code>null</code> when TYPE is tableIndexStatistic
4246:             *  <LI><B>INDEX_NAME</B> String => index name; <code>null</code> when TYPE is
4247:             *     tableIndexStatistic
4248:             *  <LI><B>TYPE</B> short => index type:
4249:             *     <UL>
4250:             *     <LI> tableIndexStatistic - this identifies table statistics that are
4251:             *          returned in conjuction with a table's index descriptions
4252:             *     <LI> tableIndexClustered - this is a clustered index
4253:             *     <LI> tableIndexHashed - this is a hashed index
4254:             *     <LI> tableIndexOther - this is some other style of index
4255:             *     </UL>
4256:             *  <LI><B>ORDINAL_POSITION</B> short => column sequence number
4257:             *     within index; zero when TYPE is tableIndexStatistic
4258:             *  <LI><B>COLUMN_NAME</B> String => column name; <code>null</code> when TYPE is
4259:             *     tableIndexStatistic
4260:             *  <LI><B>ASC_OR_DESC</B> String => column sort sequence, "A" => ascending,
4261:             *     "D" => descending, may be <code>null</code> if sort sequence is not supported;
4262:             *     <code>null</code> when TYPE is tableIndexStatistic
4263:             *  <LI><B>CARDINALITY</B> int => When TYPE is tableIndexStatistic, then
4264:             *     this is the number of rows in the table; otherwise, it is the
4265:             *     number of unique values in the index.
4266:             *  <LI><B>PAGES</B> int => When TYPE is  tableIndexStatisic then
4267:             *     this is the number of pages used for the table, otherwise it
4268:             *     is the number of pages used for the current index.
4269:             *  <LI><B>FILTER_CONDITION</B> String => Filter condition, if any.
4270:             *     (may be <code>null</code>)
4271:             * </OL> <p>
4272:             *
4273:             * <!-- start release-specific documentation -->
4274:             * <div class="ReleaseSpecificDocumentation">
4275:             * <h3>HSQLDB-Specific Information:</h3> <p>
4276:             *
4277:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
4278:             * them in upper case; it treats quoted identifiers as case sensitive and
4279:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
4280:             * case-sensitive comparison between name (pattern) arguments and the
4281:             * corresponding identifier values as they are stored in the database.
4282:             * Therefore, care must be taken to specify name arguments precisely
4283:             * (including case) as they are stored in the database. <p>
4284:             *
4285:             * Since 1.7.2, this feature is supported by default. If the jar is
4286:             * compiled without org.hsqldb.DatabaseInformationFull or
4287:             * org.hsqldb.DatabaseInformationMain, the feature is
4288:             * not supported. The default implementation is
4289:             * {@link org.hsqldb.DatabaseInformationFull}.
4290:             * </div>
4291:             * <!-- end release-specific documentation -->
4292:             *
4293:             * @param catalog a catalog name; must match the catalog name as it
4294:             *       is stored in this database; "" retrieves those without a catalog;
4295:             *       <code>null</code> means that the catalog name should not be used
4296:             *       to narrow the search
4297:             * @param schema a schema name; must match the schema name
4298:             *       as it is stored in this database; "" retrieves those without a
4299:             *       schema; <code>null</code> means that the schema name should not be
4300:             *       used to narrow the search
4301:             * @param table a table name; must match the table name as it is stored
4302:             *       in this database
4303:             * @param unique when true, return only indices for unique values;
4304:             *    when false, return indices regardless of whether unique or not
4305:             * @param approximate when true, result is allowed to reflect approximate
4306:             *    or out of date values; when false, results are requested to be
4307:             *    accurate
4308:             * @return <code>ResultSet</code> - each row is an index column description
4309:             * @exception SQLException if a database access error occurs
4310:             * @see #supportsMixedCaseQuotedIdentifiers
4311:             * @see #storesUpperCaseIdentifiers
4312:             */
4313:
4314:            // fredt@users 20020526 - comment - changed to exact table name
4315:            public ResultSet getIndexInfo(String catalog, String schema,
4316:                    String table, boolean unique, boolean approximate)
4317:                    throws SQLException {
4318:
4319:                if (table == null) {
4320:                    Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
4321:                }
4322:
4323:                schema = translateSchema(schema);
4324:
4325:                Boolean nu = (unique) ? Boolean.FALSE : null;
4326:                StringBuffer select = toQueryPrefix("SYSTEM_INDEXINFO").append(
4327:                        and("TABLE_CAT", "=", catalog)).append(
4328:                        and("TABLE_SCHEM", "=", schema)).append(
4329:                        and("TABLE_NAME", "=", table)).append(
4330:                        and("NON_UNIQUE", "=", nu));
4331:
4332:                // By default, this query already returns the table ordered by
4333:                // NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION...
4334:                return execute(select.toString());
4335:            }
4336:
4337:            //--------------------------JDBC 2.0-----------------------------
4338:
4339:            /**
4340:             * Retrieves whether this database supports the given result set type. <p>
4341:             *
4342:             * @param type defined in <code>java.sql.ResultSet</code>
4343:             * @return <code>true</code> if so; <code>false</code> otherwise
4344:             * @exception SQLException if a database access error occurs
4345:             * @see jdbcConnection
4346:             * @since  JDK 1.2 (JDK 1.1.x developers: read the new overview
4347:             *      for jdbcDatabaseMetaData)
4348:             */
4349:            public boolean supportsResultSetType(int type) throws SQLException {
4350:                return (type == jdbcResultSet.TYPE_FORWARD_ONLY || type == jdbcResultSet.TYPE_SCROLL_INSENSITIVE);
4351:            }
4352:
4353:            /**
4354:             * Retrieves whether this database supports the given concurrency type
4355:             * in combination with the given result set type. <p>
4356:             *
4357:             * @param type defined in <code>java.sql.ResultSet</code>
4358:             * @param concurrency type defined in <code>java.sql.ResultSet</code>
4359:             * @return <code>true</code> if so; <code>false</code> otherwise
4360:             * @exception SQLException if a database access error occurs
4361:             * @see jdbcConnection
4362:             * @since  JDK 1.2 (JDK 1.1.x developers: read the new overview
4363:             *      for jdbcDatabaseMetaData)
4364:             */
4365:            public boolean supportsResultSetConcurrency(int type,
4366:                    int concurrency) throws SQLException {
4367:                return supportsResultSetType(type)
4368:                        && concurrency == jdbcResultSet.CONCUR_READ_ONLY;
4369:            }
4370:
4371:            /**
4372:             * Retrieves whether for the given type of <code>ResultSet</code> object,
4373:             * the result set's own updates are visible. <p>
4374:             *
4375:             * <!-- start release-specific documentation -->
4376:             * <div class="ReleaseSpecificDocumentation">
4377:             * <h3>HSQLDB-Specific Information:</h3> <p>
4378:             *
4379:             * Up to and including 1.7.2, HSQLDB does not support updateable
4380:             * result sets; this method always returns <code>false</code>.
4381:             * </div>
4382:             * <!-- end release-specific documentation -->
4383:             * @param type the <code>ResultSet</code> type; one of
4384:             *       <code>ResultSet.TYPE_FORWARD_ONLY</code>,
4385:             *       <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
4386:             *       <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
4387:             * @return <code>true</code> if updates are visible for the given result set type;
4388:             *       <code>false</code> otherwise
4389:             * @exception SQLException if a database access error occurs
4390:             * @since JDK 1.2 (JDK 1.1.x developers: read the new overview
4391:             *     for jdbcDatabaseMetaData)
4392:             */
4393:            public boolean ownUpdatesAreVisible(int type) throws SQLException {
4394:                return false;
4395:            }
4396:
4397:            /**
4398:             * Retrieves whether a result set's own deletes are visible. <p>
4399:             *
4400:             * <!-- start release-specific documentation -->
4401:             * <div class="ReleaseSpecificDocumentation">
4402:             * <h3>HSQLDB-Specific Information:</h3> <p>
4403:             *
4404:             * Up to and including 1.7.2, HSQLDB does not support updateable
4405:             * result sets; this method always returns <code>false</code>.
4406:             * </div>
4407:             * <!-- end release-specific documentation -->
4408:             * @param type the <code>ResultSet</code> type; one of
4409:             *       <code>ResultSet.TYPE_FORWARD_ONLY</code>,
4410:             *       <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
4411:             *       <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
4412:             * @return <code>true</code> if deletes are visible for the given result set type;
4413:             *       <code>false</code> otherwise
4414:             * @exception SQLException if a database access error occurs
4415:             * @since JDK 1.2 (JDK 1.1.x developers: read the new overview
4416:             *     for jdbcDatabaseMetaData)
4417:             */
4418:            public boolean ownDeletesAreVisible(int type) throws SQLException {
4419:                return false;
4420:            }
4421:
4422:            /**
4423:             * Retrieves whether a result set's own inserts are visible. <p>
4424:             *
4425:             * <!-- start release-specific documentation -->
4426:             * <div class="ReleaseSpecificDocumentation">
4427:             * <h3>HSQLDB-Specific Information:</h3> <p>
4428:             *
4429:             * Up to and including 1.7.2, HSQLDB does not support updateable
4430:             * result sets; this method always returns <code>false</code>.
4431:             * </div>
4432:             * <!-- end release-specific documentation -->
4433:             * @param type the <code>ResultSet</code> type; one of
4434:             *       <code>ResultSet.TYPE_FORWARD_ONLY</code>,
4435:             *       <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
4436:             *       <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
4437:             * @return <code>true</code> if inserts are visible for the given result set type;
4438:             *       <code>false</code> otherwise
4439:             * @exception SQLException if a database access error occurs
4440:             * @since JDK 1.2 (JDK 1.1.x developers: read the new overview
4441:             *     for jdbcDatabaseMetaData)
4442:             */
4443:            public boolean ownInsertsAreVisible(int type) throws SQLException {
4444:                return false;
4445:            }
4446:
4447:            /**
4448:             * Retrieves whether updates made by others are visible. <p>
4449:             *
4450:             * <!-- start release-specific documentation -->
4451:             * <div class="ReleaseSpecificDocumentation">
4452:             * <h3>HSQLDB-Specific Information:</h3> <p>
4453:             *
4454:             * Up to and including 1.7.2, HSQLDB does not support updateable
4455:             * result sets; this method always returns <code>false</code>.
4456:             * </div>
4457:             * <!-- end release-specific documentation -->
4458:             * @param type the <code>ResultSet</code> type; one of
4459:             *       <code>ResultSet.TYPE_FORWARD_ONLY</code>,
4460:             *       <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
4461:             *       <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
4462:             * @return <code>true</code> if updates made by others
4463:             *       are visible for the given result set type;
4464:             *       <code>false</code> otherwise
4465:             * @exception SQLException if a database access error occurs
4466:             * @since JDK 1.2 (JDK 1.1.x developers: read the new overview
4467:             *     for jdbcDatabaseMetaData)
4468:             */
4469:            public boolean othersUpdatesAreVisible(int type)
4470:                    throws SQLException {
4471:                return false;
4472:            }
4473:
4474:            /**
4475:             * Retrieves whether deletes made by others are visible. <p>
4476:             *
4477:             * <!-- start release-specific documentation -->
4478:             * <div class="ReleaseSpecificDocumentation">
4479:             * <h3>HSQLDB-Specific Information:</h3> <p>
4480:             *
4481:             * Up to and including 1.7.2, HSQLDB does not support updateable
4482:             * result sets; this method always returns <code>false</code>.
4483:             * </div>
4484:             * <!-- end release-specific documentation -->
4485:             * @param type the <code>ResultSet</code> type; one of
4486:             *       <code>ResultSet.TYPE_FORWARD_ONLY</code>,
4487:             *       <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
4488:             *       <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
4489:             * @return <code>true</code> if deletes made by others
4490:             *       are visible for the given result set type;
4491:             *       <code>false</code> otherwise
4492:             * @exception SQLException if a database access error occurs
4493:             * @since JDK 1.2 (JDK 1.1.x developers: read the new overview
4494:             *     for jdbcDatabaseMetaData)
4495:             */
4496:            public boolean othersDeletesAreVisible(int type)
4497:                    throws SQLException {
4498:                return false;
4499:            }
4500:
4501:            /**
4502:             * Retrieves whether inserts made by others are visible. <p>
4503:             *
4504:             * <!-- start release-specific documentation -->
4505:             * <div class="ReleaseSpecificDocumentation">
4506:             * <h3>HSQLDB-Specific Information:</h3> <p>
4507:             *
4508:             * Up to and including 1.7.2, HSQLDB does not support updateable
4509:             * result sets; this method always returns <code>false</code>.
4510:             * </div>
4511:             * <!-- end release-specific documentation -->
4512:             * @param type the <code>ResultSet</code> type; one of
4513:             *       <code>ResultSet.TYPE_FORWARD_ONLY</code>,
4514:             *       <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
4515:             *       <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
4516:             * @return <code>true</code> if inserts made by others
4517:             *        are visible for the given result set type;
4518:             *        <code>false</code> otherwise
4519:             * @exception SQLException if a database access error occurs
4520:             * @since JDK 1.2 (JDK 1.1.x developers: read the new overview
4521:             *     for jdbcDatabaseMetaData)
4522:             */
4523:            public boolean othersInsertsAreVisible(int type)
4524:                    throws SQLException {
4525:                return false;
4526:            }
4527:
4528:            /**
4529:             * Retrieves whether or not a visible row update can be detected by
4530:             * calling the method <code>ResultSet.rowUpdated</code>. <p>
4531:             *
4532:             * <!-- start release-specific documentation -->
4533:             * <div class="ReleaseSpecificDocumentation">
4534:             * <h3>HSQLDB-Specific Information:</h3> <p>
4535:             *
4536:             * Up to and including 1.7.2, HSQLDB does not support updateable
4537:             * result sets; this method always returns <code>false</code>.
4538:             * </div>
4539:             * <!-- end release-specific documentation -->
4540:             * @param type the <code>ResultSet</code> type; one of
4541:             *       <code>ResultSet.TYPE_FORWARD_ONLY</code>,
4542:             *       <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
4543:             *       <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
4544:             * @return <code>true</code> if changes are detected by the result set type;
4545:             *        <code>false</code> otherwise
4546:             * @exception SQLException if a database access error occurs
4547:             * @since JDK 1.2 (JDK 1.1.x developers: read the new overview
4548:             *     for jdbcDatabaseMetaData)
4549:             */
4550:            public boolean updatesAreDetected(int type) throws SQLException {
4551:                return false;
4552:            }
4553:
4554:            /**
4555:             * Retrieves whether or not a visible row delete can be detected by
4556:             * calling the method <code>ResultSet.rowDeleted</code>.  If the method
4557:             * <code>deletesAreDetected</code> returns <code>false</code>, it means that
4558:             * deleted rows are removed from the result set. <p>
4559:             *
4560:             * <!-- start release-specific documentation -->
4561:             * <div class="ReleaseSpecificDocumentation">
4562:             * <h3>HSQLDB-Specific Information:</h3> <p>
4563:             *
4564:             * Including 1.7.2, HSQLDB does not support updateable
4565:             * result sets; this method <em>always</em> returns <code>false</code>.
4566:             * </div>
4567:             * <!-- end release-specific documentation -->
4568:             *
4569:             *
4570:             * @param type the <code>ResultSet</code> type; one of
4571:             *       <code>ResultSet.TYPE_FORWARD_ONLY</code>,
4572:             *       <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
4573:             *       <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
4574:             * @return <code>true</code> if deletes are detected by the given result set type;
4575:             *        <code>false</code> otherwise
4576:             * @exception SQLException if a database access error occurs
4577:             * @since JDK 1.2 (JDK 1.1.x developers: read the new overview
4578:             *     for jdbcDatabaseMetaData)
4579:             */
4580:            public boolean deletesAreDetected(int type) throws SQLException {
4581:                return false;
4582:            }
4583:
4584:            /**
4585:             * Retrieves whether or not a visible row insert can be detected
4586:             * by calling the method <code>ResultSet.rowInserted</code>. <p>
4587:             *
4588:             * <!-- start release-specific documentation -->
4589:             * <div class="ReleaseSpecificDocumentation">
4590:             * <h3>HSQLDB-Specific Information:</h3> <p>
4591:             *
4592:             * Up to and including 1.7.2, HSQLDB does not support updateable
4593:             * result sets; this method always returns <code>false</code>.
4594:             * </div>
4595:             * <!-- end release-specific documentation -->
4596:             * @param type the <code>ResultSet</code> type; one of
4597:             *       <code>ResultSet.TYPE_FORWARD_ONLY</code>,
4598:             *       <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
4599:             *       <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
4600:             * @return <code>true</code> if changes are detected by the specified result
4601:             *        set type; <code>false</code> otherwise
4602:             * @exception SQLException if a database access error occurs
4603:             * @since JDK 1.2 (JDK 1.1.x developers: read the new overview
4604:             *     for jdbcDatabaseMetaData)
4605:             */
4606:            public boolean insertsAreDetected(int type) throws SQLException {
4607:                return false;
4608:            }
4609:
4610:            /**
4611:             * Retrieves whether this database supports batch updates. <p>
4612:             *
4613:             * <!-- start release-specific documentation -->
4614:             * <div class="ReleaseSpecificDocumentation">
4615:             * <h3>HSQLDB-Specific Information:</h3> <p>
4616:             *
4617:             * Starting with 1.7.2, HSQLDB supports batch updates;
4618:             * this method always returns <code>true</code>.
4619:             * </div>
4620:             * <!-- end release-specific documentation -->
4621:             * @return <code>true</code> if this database supports batch upcates;
4622:             *        <code>false</code> otherwise
4623:             * @exception SQLException if a database access error occurs
4624:             * @since JDK 1.2 (JDK 1.1.x developers: read the new overview
4625:             *     for jdbcDatabaseMetaData)
4626:             */
4627:            public boolean supportsBatchUpdates() throws SQLException {
4628:                return true;
4629:            }
4630:
4631:            /**
4632:             * Retrieves a description of the user-defined types (UDTs) defined
4633:             * in a particular schema.  Schema-specific UDTs may have type
4634:             * <code>JAVA_OBJECT</code>, <code>STRUCT</code>,
4635:             * or <code>DISTINCT</code>.
4636:             *
4637:             * <P>Only types matching the catalog, schema, type name and type
4638:             * criteria are returned.  They are ordered by DATA_TYPE, TYPE_SCHEM
4639:             * and TYPE_NAME.  The type name parameter may be a fully-qualified
4640:             * name.  In this case, the catalog and schemaPattern parameters are
4641:             * ignored.
4642:             *
4643:             * <P>Each type description has the following columns:
4644:             * <OL>
4645:             *  <LI><B>TYPE_CAT</B> String => the type's catalog (may be <code>null</code>)
4646:             *  <LI><B>TYPE_SCHEM</B> String => type's schema (may be <code>null</code>)
4647:             *  <LI><B>TYPE_NAME</B> String => type name
4648:             * <LI><B>CLASS_NAME</B> String => Java class name
4649:             *  <LI><B>DATA_TYPE</B> String => type value defined in java.sql.Types.
4650:             *    One of JAVA_OBJECT, STRUCT, or DISTINCT
4651:             *  <LI><B>REMARKS</B> String => explanatory comment on the type
4652:             * <LI><B>BASE_TYPE</B> short => type code of the source type of a
4653:             *    DISTINCT type or the type that implements the user-generated
4654:             *    reference type of the SELF_REFERENCING_COLUMN of a structured
4655:             *    type as defined in java.sql.Types (<code>null</code> if DATA_TYPE is not
4656:             *    DISTINCT or not STRUCT with REFERENCE_GENERATION = USER_DEFINED)
4657:             * </OL>
4658:             *
4659:             * <P><B>Note:</B> If the driver does not support UDTs, an empty
4660:             * result set is returned. <p>
4661:             *
4662:             * <!-- start release-specific documentation -->
4663:             * <div class="ReleaseSpecificDocumentation">
4664:             * <h3>HSQLDB-Specific Information:</h3> <p>
4665:             *
4666:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
4667:             * them in upper case; it treats quoted identifiers as case sensitive and
4668:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
4669:             * case-sensitive comparison between name (pattern) arguments and the
4670:             * corresponding identifier values as they are stored in the database.
4671:             * Therefore, care must be taken to specify name arguments precisely
4672:             * (including case) as they are stored in the database. <p>
4673:             *
4674:             * Up to and including 1.7.1, HSQLDB does not support UDTs and
4675:             * thus produces an empty result. <p>
4676:             *
4677:             * Starting with 1.7.2, there is an option to support this feature
4678:             * to greater or lesser degrees.  See the documentation specific to the
4679:             * selected system table provider implementation. The default implementation
4680:             * is org.hsqldb.DatabaseInformationFull.
4681:             * </div>
4682:             * <!-- end release-specific documentation -->
4683:             * @param catalog a catalog name; must match the catalog name as it
4684:             *       is stored in the database; "" retrieves those without a catalog;
4685:             *       <code>null</code> means that the catalog name should not be used
4686:             *       to narrow the search
4687:             * @param schemaPattern a schema pattern name; must match the schema name
4688:             *       as it is stored in the database; "" retrieves those without a
4689:             *       schema; <code>null</code> means that the schema name should not be
4690:             *       used to narrow the search
4691:             * @param typeNamePattern a type name pattern; must match the type name
4692:             *       as it is stored in the database; may be a fully qualified name
4693:             * @param types a list of user-defined types (JAVA_OBJECT,
4694:             *       STRUCT, or DISTINCT) to include; <code>null</code> returns
4695:             *      all types
4696:             * @return <code>ResultSet</code> object in which each row describes a UDT
4697:             * @exception SQLException if a database access error occurs
4698:             * @since JDK 1.2 (JDK 1.1.x developers: read the new overview
4699:             *     for jdbcDatabaseMetaData)
4700:             */
4701:            public ResultSet getUDTs(String catalog, String schemaPattern,
4702:                    String typeNamePattern, int[] types) throws SQLException {
4703:
4704:                if (wantsIsNull(typeNamePattern)
4705:                        || (types != null && types.length == 0)) {
4706:                    executeSelect("SYSTEM_UDTS", "0=1");
4707:                }
4708:
4709:                schemaPattern = translateSchema(schemaPattern);
4710:
4711:                StringBuffer select = toQueryPrefix("SYSTEM_UDTS").append(
4712:                        and("TYPE_CAT", "=", catalog)).append(
4713:                        and("TYPE_SCHEM", "LIKE", schemaPattern)).append(
4714:                        and("TYPE_NAME", "LIKE", typeNamePattern));
4715:
4716:                if (types == null) {
4717:
4718:                    // do not use to narrow search
4719:                } else {
4720:                    select.append(" AND DATA_TYPE IN (").append(
4721:                            StringUtil.getList(types, ",", "'")).append(')');
4722:                }
4723:
4724:                // By default, the query already returns a result ordered by
4725:                // DATA_TYPE, TYPE_SCHEM, and TYPE_NAME...
4726:                return execute(select.toString());
4727:            }
4728:
4729:            /**
4730:             * Retrieves the connection that produced this metadata object. <p>
4731:             *
4732:             * @return the connection that produced this metadata object
4733:             * @exception SQLException if a database access error occurs
4734:             * @since  JDK 1.2 (JDK 1.1.x developers: read the new overview
4735:             *      for jdbcDatabaseMetaData)
4736:             */
4737:            public Connection getConnection() throws SQLException {
4738:                return connection;
4739:            }
4740:
4741:            // boucherb@users 20020426 - javadocs for all JDBC 3 methods
4742:            // boucherb@users 20020426 - todos
4743:            // ------------------- JDBC 3.0 -------------------------
4744:
4745:            /**
4746:             * Retrieves whether this database supports savepoints. <p>
4747:             *
4748:             * <!-- start release-specific documentation -->
4749:             * <div class="ReleaseSpecificDocumentation">
4750:             * <h3>HSQLDB-Specific Information:</h3> <p>
4751:             *
4752:             * Beginning with 1.7.2, this SQL feature is supported
4753:             * through JDBC as well as SQL. <p>
4754:             *
4755:             * </div>
4756:             * <!-- end release-specific documentation -->
4757:             * @return <code>true</code> if savepoints are supported;
4758:             *        <code>false</code> otherwise
4759:             * @exception SQLException if a database access error occurs
4760:             * @since JDK 1.4, HSQLDB 1.7
4761:             */
4762:            //#ifdef JDBC3
4763:            public boolean supportsSavepoints() throws SQLException {
4764:                return true;
4765:            }
4766:
4767:            //#endif JDBC3
4768:
4769:            /**
4770:             * Retrieves whether this database supports named parameters to callable
4771:             * statements. <p>
4772:             *
4773:             * <!-- start release-specific documentation -->
4774:             * <div class="ReleaseSpecificDocumentation">
4775:             * <h3>HSQLDB-Specific Information:</h3> <p>
4776:             *
4777:             * Starting with 1.7.2, HSQLDB supports JDBC named parameters to
4778:             * callable statements; this method returns true. <p>
4779:             *
4780:             * </div>
4781:             * <!-- end release-specific documentation -->
4782:             * @return <code>true</code> if named parameters are supported;
4783:             *        <code>false</code> otherwise
4784:             * @exception SQLException if a database access error occurs
4785:             * @since JDK 1.4, HSQLDB 1.7
4786:             */
4787:            //#ifdef JDBC3
4788:            public boolean supportsNamedParameters() throws SQLException {
4789:                return true;
4790:            }
4791:
4792:            //#endif JDBC3
4793:
4794:            /**
4795:             * Retrieves whether it is possible to have multiple <code>ResultSet</code>
4796:             * objects returned from a <code>CallableStatement</code> object
4797:             * simultaneously. <p>
4798:             *
4799:             * <!-- start release-specific documentation -->
4800:             * <div class="ReleaseSpecificDocumentation">
4801:             * <h3>HSQLDB-Specific Information:</h3> <p>
4802:             *
4803:             * Up to and including 1.7.2, HSQLDB does not support multiple ResultSet
4804:             * objects returned from a <code>CallableStatement</code> object at all;
4805:             * this method always returns <code>false</code>. <p>
4806:             *
4807:             * </div>
4808:             * <!-- end release-specific documentation -->
4809:             * @return <code>true</code> if a <code>CallableStatement</code> object
4810:             *        can return multiple <code>ResultSet</code> objects
4811:             *        simultaneously; <code>false</code> otherwise
4812:             * @exception SQLException if a database access error occurs
4813:             * @since JDK 1.4, HSQLDB 1.7
4814:             */
4815:            //#ifdef JDBC3
4816:            public boolean supportsMultipleOpenResults() throws SQLException {
4817:                return false;
4818:            }
4819:
4820:            //#endif JDBC3
4821:
4822:            /**
4823:             * Retrieves whether auto-generated keys can be retrieved after
4824:             * a statement has been executed. <p>
4825:             *
4826:             * <!-- start release-specific documentation -->
4827:             * <div class="ReleaseSpecificDocumentation">
4828:             * <h3>HSQLDB-Specific Information:</h3> <p>
4829:             *
4830:             * Up to and including 1.7.2, HSQLDB does not support retrieving
4831:             * autogenerated keys through the JDBC interface at all, although
4832:             * it is possible to retrieve them in a proprietary fashion;
4833:             * this method always returns <code>false</code>. <p>
4834:             *
4835:             * </div>
4836:             * <!-- end release-specific documentation -->
4837:             * @return <code>true</code> if auto-generated keys can be retrieved
4838:             *        after a statement has executed; <code>false</code> otherwise
4839:             * @exception SQLException if a database access error occurs
4840:             * @since JDK 1.4, HSQLDB 1.7
4841:             */
4842:            //#ifdef JDBC3
4843:            public boolean supportsGetGeneratedKeys() throws SQLException {
4844:                return false;
4845:            }
4846:
4847:            //#endif JDBC3
4848:
4849:            /**
4850:             * Retrieves a description of the user-defined type (UDT) hierarchies defined in a
4851:             * particular schema in this database. Only the immediate super type
4852:             * sub type relationship is modeled.
4853:             * <P>
4854:             * Only supertype information for UDTs matching the catalog,
4855:             * schema, and type name is returned. The type name parameter
4856:             * may be a fully-qualified name. When the UDT name supplied is a
4857:             * fully-qualified name, the catalog and schemaPattern parameters are
4858:             * ignored.
4859:             * <P>
4860:             * If a UDT does not have a direct super type, it is not listed here.
4861:             * A row of the <code>ResultSet</code> object returned by this method
4862:             * describes the designated UDT and a direct supertype. A row has the following
4863:             * columns:
4864:             * <OL>
4865:             * <LI><B>TYPE_CAT</B> String => the UDT's catalog (may be <code>null</code>)
4866:             * <LI><B>TYPE_SCHEM</B> String => UDT's schema (may be <code>null</code>)
4867:             * <LI><B>TYPE_NAME</B> String => type name of the UDT
4868:             * <LI><B>SUPERTYPE_CAT</B> String => the direct super type's catalog
4869:             *                          (may be <code>null</code>)
4870:             * <LI><B>SUPERTYPE_SCHEM</B> String => the direct super type's schema
4871:             *                            (may be <code>null</code>)
4872:             * <LI><B>SUPERTYPE_NAME</B> String => the direct super type's name
4873:             * </OL>
4874:             *
4875:             * <P><B>Note:</B> If the driver does not support type hierarchies, an
4876:             * empty result set is returned. <p>
4877:             *
4878:             * <!-- start release-specific documentation -->
4879:             * <div class="ReleaseSpecificDocumentation">
4880:             * <h3>HSQLDB-Specific Information:</h3> <p>
4881:             *
4882:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
4883:             * them in upper case; it treats quoted identifiers as case sensitive and
4884:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
4885:             * case-sensitive comparison between name (pattern) arguments and the
4886:             * corresponding identifier values as they are stored in the database.
4887:             * Therefore, care must be taken to specify name arguments precisely
4888:             * (including case) as they are stored in the database. <p>
4889:             *
4890:             * Including 1.7.1, this JDBC feature is not supported; calling
4891:             * this method throws a SQLException stating that the operation
4892:             * is not supported. <p>
4893:             *
4894:             * Since 1.7.2, this feature is supported by default. If the jar is
4895:             * compiled without org.hsqldb.DatabaseInformationFull or
4896:             * org.hsqldb.DatabaseInformationMain, the feature is
4897:             * not supported. The default implementation is
4898:             * {@link org.hsqldb.DatabaseInformationFull}.
4899:             * </div>
4900:             * <!-- end release-specific documentation -->
4901:             *
4902:             * @param catalog a catalog name; "" retrieves those without a catalog;
4903:             *       <code>null</code> means drop catalog name from the selection
4904:             *       criteria
4905:             * @param schemaPattern a schema name pattern; "" retrieves those
4906:             *       without a schema
4907:             * @param typeNamePattern a UDT name pattern; may be a fully-qualified
4908:             *       name
4909:             * @return a <code>ResultSet</code> object in which a row gives information
4910:             *        about the designated UDT
4911:             * @throws SQLException if a database access error occurs
4912:             * @since JDK 1.4, HSQLDB 1.7
4913:             */
4914:            //#ifdef JDBC3
4915:            public ResultSet getSuperTypes(String catalog,
4916:                    String schemaPattern, String typeNamePattern)
4917:                    throws SQLException {
4918:
4919:                if (wantsIsNull(typeNamePattern)) {
4920:                    return executeSelect("SYSTEM_SUPERTYPES", "0=1");
4921:                }
4922:
4923:                schemaPattern = translateSchema(schemaPattern);
4924:
4925:                StringBuffer select = toQueryPrefix("SYSTEM_SUPERTYPES")
4926:                        .append(and("TYPE_CAT", "=", catalog)).append(
4927:                                and("TYPE_SCHEM", "LIKE", schemaPattern))
4928:                        .append(and("TYPE_NAME", "LIKE", typeNamePattern));
4929:
4930:                return execute(select.toString());
4931:            }
4932:
4933:            //#endif JDBC3
4934:
4935:            /**
4936:             * Retrieves a description of the table hierarchies defined in a particular
4937:             * schema in this database.
4938:             *
4939:             * <P>Only supertable information for tables matching the catalog, schema
4940:             * and table name are returned. The table name parameter may be a fully-
4941:             * qualified name, in which case, the catalog and schemaPattern parameters
4942:             * are ignored. If a table does not have a super table, it is not listed here.
4943:             * Supertables have to be defined in the same catalog and schema as the
4944:             * sub tables. Therefore, the type description does not need to include
4945:             * this information for the supertable.
4946:             *
4947:             * <P>Each type description has the following columns:
4948:             * <OL>
4949:             * <LI><B>TABLE_CAT</B> String => the type's catalog (may be <code>null</code>)
4950:             * <LI><B>TABLE_SCHEM</B> String => type's schema (may be <code>null</code>)
4951:             * <LI><B>TABLE_NAME</B> String => type name
4952:             * <LI><B>SUPERTABLE_NAME</B> String => the direct super type's name
4953:             * </OL>
4954:             *
4955:             * <P><B>Note:</B> If the driver does not support type hierarchies, an
4956:             * empty result set is returned. <p>
4957:             *
4958:             * <!-- start release-specific documentation -->
4959:             * <div class="ReleaseSpecificDocumentation">
4960:             * <h3>HSQLDB-Specific Information:</h3> <p>
4961:             *
4962:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
4963:             * them in upper case; it treats quoted identifiers as case sensitive and
4964:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
4965:             * case-sensitive comparison between name (pattern) arguments and the
4966:             * corresponding identifier values as they are stored in the database.
4967:             * Therefore, care must be taken to specify name arguments precisely
4968:             * (including case) as they are stored in the database. <p>
4969:             *
4970:             * Since 1.7.2, this feature is supported by default. If the jar is
4971:             * compiled without org.hsqldb.DatabaseInformationFull or
4972:             * org.hsqldb.DatabaseInformationMain, the feature is
4973:             * not supported. The default implementation is
4974:             * {@link org.hsqldb.DatabaseInformationFull}.
4975:             * </div>
4976:             * <!-- end release-specific documentation -->
4977:             *
4978:             * @param catalog a catalog name; "" retrieves those without a catalog;
4979:             *       <code>null</code> means drop catalog name from the selection
4980:             *       criteria
4981:             * @param schemaPattern a schema name pattern; "" retrieves those
4982:             *       without a schema
4983:             * @param tableNamePattern a table name pattern; may be a fully-qualified
4984:             *       name
4985:             * @return a <code>ResultSet</code> object in which each row is a type
4986:             *       description
4987:             * @throws SQLException if a database access error occurs
4988:             * @since JDK 1.4, HSQLDB 1.7
4989:             */
4990:            //#ifdef JDBC3
4991:            public ResultSet getSuperTables(String catalog,
4992:                    String schemaPattern, String tableNamePattern)
4993:                    throws SQLException {
4994:
4995:                if (wantsIsNull(tableNamePattern)) {
4996:                    return executeSelect("SYSTEM_SUPERTABLES", "0=1");
4997:                }
4998:
4999:                schemaPattern = translateSchema(schemaPattern);
5000:
5001:                StringBuffer select = toQueryPrefix("SYSTEM_SUPERTABLES")
5002:                        .append(and("TABLE_CAT", "=", catalog)).append(
5003:                                and("TABLE_SCHEM", "LIKE", schemaPattern))
5004:                        .append(and("TABLE_NAME", "LIKE", tableNamePattern));
5005:
5006:                return execute(select.toString());
5007:            }
5008:
5009:            //#endif JDBC3
5010:
5011:            /**
5012:             * Retrieves a description of the given attribute of the given type
5013:             * for a user-defined type (UDT) that is available in the given schema
5014:             * and catalog.
5015:             * <P>
5016:             * Descriptions are returned only for attributes of UDTs matching the
5017:             * catalog, schema, type, and attribute name criteria. They are ordered by
5018:             * TYPE_SCHEM, TYPE_NAME and ORDINAL_POSITION. This description
5019:             * does not contain inherited attributes.
5020:             * <P>
5021:             * The <code>ResultSet</code> object that is returned has the following
5022:             * columns:
5023:             * <OL>
5024:             * <LI><B>TYPE_CAT</B> String => type catalog (may be <code>null</code>)
5025:             *  <LI><B>TYPE_SCHEM</B> String => type schema (may be <code>null</code>)
5026:             *  <LI><B>TYPE_NAME</B> String => type name
5027:             *  <LI><B>ATTR_NAME</B> String => attribute name
5028:             *  <LI><B>DATA_TYPE</B> short => attribute type SQL type from java.sql.Types
5029:             *  <LI><B>ATTR_TYPE_NAME</B> String => Data source dependent type name.
5030:             * For a UDT, the type name is fully qualified. For a REF, the type name is
5031:             * fully qualified and represents the target type of the reference type.
5032:             *  <LI><B>ATTR_SIZE</B> int => column size.  For char or date
5033:             *      types this is the maximum number of characters; for numeric or
5034:             *      decimal types this is precision.
5035:             *  <LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits
5036:             *  <LI><B>NUM_PREC_RADIX</B> int => Radix (typically either 10 or 2)
5037:             *  <LI><B>NULLABLE</B> int => whether NULL is allowed
5038:             *     <UL>
5039:             *     <LI> attributeNoNulls - might not allow NULL values
5040:             *     <LI> attributeNullable - definitely allows NULL values
5041:             *     <LI> attributeNullableUnknown - nullability unknown
5042:             *     </UL>
5043:             *  <LI><B>REMARKS</B> String => comment describing column (may be <code>null</code>)
5044:             *  <LI><B>ATTR_DEF</B> String => default value (may be <code>null</code>)
5045:             *  <LI><B>SQL_DATA_TYPE</B> int => unused
5046:             *  <LI><B>SQL_DATETIME_SUB</B> int => unused
5047:             *  <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the
5048:             *      maximum number of bytes in the column
5049:             *  <LI><B>ORDINAL_POSITION</B> int => index of column in table
5050:             *     (starting at 1)
5051:             *  <LI><B>IS_NULLABLE</B> String => "NO" means column definitely
5052:             *     does not allow NULL values; "YES" means the column might
5053:             *     allow NULL values.  An empty string means unknown.
5054:             * <LI><B>SCOPE_CATALOG</B> String => catalog of table that is the
5055:             *     scope of a reference attribute (<code>null</code> if DATA_TYPE isn't REF)
5056:             * <LI><B>SCOPE_SCHEMA</B> String => schema of table that is the
5057:             *     scope of a reference attribute (<code>null</code> if DATA_TYPE isn't REF)
5058:             * <LI><B>SCOPE_TABLE</B> String => table name that is the scope of a
5059:             *     reference attribute (<code>null</code> if the DATA_TYPE isn't REF)
5060:             * <LI><B>SOURCE_DATA_TYPE</B> short => source type of a distinct type or user-generated
5061:             *     Ref type,SQL type from java.sql.Types (<code>null</code> if DATA_TYPE
5062:             *     isn't DISTINCT or user-generated REF)
5063:             * </OL> <p>
5064:             *
5065:             * <!-- start release-specific documentation -->
5066:             * <div class="ReleaseSpecificDocumentation">
5067:             * <h3>HSQLDB-Specific Information:</h3> <p>
5068:             *
5069:             * HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
5070:             * them in upper case; it treats quoted identifiers as case sensitive and
5071:             * stores them verbatim. All jdbcDatabaseMetaData methods perform
5072:             * case-sensitive comparison between name (pattern) arguments and the
5073:             * corresponding identifier values as they are stored in the database.
5074:             * Therefore, care must be taken to specify name arguments precisely
5075:             * (including case) as they are stored in the database. <p>
5076:             *
5077:             * Including 1.7.1, this JDBC feature is not supported; calling
5078:             * this method throws a SQLException stating that the operation
5079:             * is not supported. <p>
5080:             *
5081:             * Since 1.7.2, this feature is supported by default. If the jar is
5082:             * compiled without org.hsqldb.DatabaseInformationFull or
5083:             * org.hsqldb.DatabaseInformationMain, the feature is
5084:             * not supported. The default implementation is
5085:             * {@link org.hsqldb.DatabaseInformationFull}.
5086:             * </div>
5087:             * <!-- end release-specific documentation -->
5088:             *
5089:             * @param catalog a catalog name; must match the catalog name as it
5090:             *       is stored in the database; "" retrieves those without a catalog;
5091:             *       <code>null</code> means that the catalog name should not be used
5092:             *       to narrow the search
5093:             * @param schemaPattern a schema name pattern; must match the schema name
5094:             *       as it is stored in the database; "" retrieves those without a
5095:             *       schema; <code>null</code> means that the schema name should not be
5096:             *       used to narrow the search
5097:             * @param typeNamePattern a type name pattern; must match the
5098:             *       type name as it is stored in the database
5099:             * @param attributeNamePattern an attribute name pattern; must match the
5100:             *       attribute name as it is declared in the database
5101:             * @return a <code>ResultSet</code> object in which each row is an
5102:             *        attribute description
5103:             * @exception SQLException if a database access error occurs
5104:             * @since JDK 1.4, HSQLDB 1.7
5105:             */
5106:            //#ifdef JDBC3
5107:            public ResultSet getAttributes(String catalog,
5108:                    String schemaPattern, String typeNamePattern,
5109:                    String attributeNamePattern) throws SQLException {
5110:
5111:                if (wantsIsNull(typeNamePattern)
5112:                        || wantsIsNull(attributeNamePattern)) {
5113:                    return executeSelect("SYSTEM_UDTATTRIBUTES", "0=1");
5114:                }
5115:
5116:                schemaPattern = translateSchema(schemaPattern);
5117:
5118:                StringBuffer select = toQueryPrefix("SYSTEM_UDTATTRIBUTES")
5119:                        .append(and("TYPE_CAT", "=", catalog)).append(
5120:                                and("TYPE_SCHEM", "LIKE", schemaPattern))
5121:                        .append(and("TYPE_NAME", "LIKE", typeNamePattern))
5122:                        .append(and("ATTR_NAME", "LIKE", attributeNamePattern));
5123:
5124:                return execute(select.toString());
5125:            }
5126:
5127:            //#endif JDBC3
5128:
5129:            /**
5130:             * Retrieves whether this database supports the given result
5131:             * set holdability. <p>
5132:             *
5133:             * <!-- start release-specific documentation -->
5134:             * <div class="ReleaseSpecificDocumentation">
5135:             * <h3>HSQLDB-Specific Information:</h3> <p>
5136:             *
5137:             * Starting with 1.7.2, HSQLDB returns true for
5138:             * HOLD_CURSORS_OVER_COMMIT, else false. <p>
5139:             *
5140:             * </div>
5141:             * <!-- end release-specific documentation -->
5142:             * @param holdability one of the following constants:
5143:             *         <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
5144:             *         <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
5145:             * @return <code>true</code> if so; <code>false</code> otherwise
5146:             * @exception SQLException if a database access error occurs
5147:             * @see jdbcConnection
5148:             * @since JDK 1.4, HSQLDB 1.7
5149:             */
5150:            //#ifdef JDBC3
5151:            public boolean supportsResultSetHoldability(int holdability)
5152:                    throws SQLException {
5153:                return holdability == jdbcResultSet.HOLD_CURSORS_OVER_COMMIT;
5154:            }
5155:
5156:            //#endif JDBC3
5157:
5158:            /**
5159:             * Retrieves the default holdability of this <code>ResultSet</code>
5160:             * object. <p>
5161:             *
5162:             * <!-- start release-specific documentation -->
5163:             * <div class="ReleaseSpecificDocumentation">
5164:             * <h3>HSQLDB-Specific Information:</h3> <p>
5165:             *
5166:             * Starting with HSQLDB 1.7.2, this JDBC feature is supported. <p>
5167:             *
5168:             * Calling this method returns HOLD_CURSORS_OVER_COMMIT, since HSQLDB
5169:             * ResultSet objects are never closed as the result of an implicit
5170:             * or explicit commit operation. <p>
5171:             *
5172:             * </div>
5173:             * <!-- end release-specific documentation -->
5174:             *
5175:             * @return the default holdability; either
5176:             *        <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
5177:             *        <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
5178:             * @exception SQLException if a database access error occurs
5179:             * @since JDK 1.4, HSQLDB 1.7
5180:             */
5181:            //#ifdef JDBC3
5182:            public int getResultSetHoldability() throws SQLException {
5183:
5184:                // JDBC 3.0 fr spec:
5185:                // 14.1.3 ResultSet Holdability
5186:                //
5187:                // Calling the method Connection.commit can close the ResultSet objects that
5188:                // have been created during the current transaction. In some cases, however,
5189:                // this may not be the desired behaviour. The ResultSet property holdability
5190:                // gives the application control over whether ResultSet objects (cursors) are
5191:                // closed when a commit operation is implicity or explictly performed.
5192:                // The following ResultSet constants may be supplied to the Connection methods
5193:                // createStatement, prepareStatement, and prepareCall:
5194:                //
5195:                // 1. HOLD_CURSORS_OVER_COMMIT
5196:                //
5197:                // * ResultSet objects (cursors) are not closed; they are held open when a
5198:                //   commit operation is implicity or explicity performed.
5199:                //
5200:                // 2. CLOSE_CURSORS_AT_COMMIT
5201:                //
5202:                // * ResultSet objects (cursors) are closed when a commit operation is
5203:                //   implicity or explicity performed. Closing cursors at commit can result
5204:                //   in better performance for some applications.
5205:                //
5206:                //   The default holdability of ResultSet objects is implementation defined.
5207:                //   The DatabaseMetaData method getResultSetHoldability can be called to
5208:                //   determine the default holdability of result sets returned by the
5209:                //   underlying data source.
5210:                // --
5211:                // boucherb@users 20030819
5212:                // Our ResultSet objects are never closed as the result of a commit
5213:                return jdbcResultSet.HOLD_CURSORS_OVER_COMMIT;
5214:            }
5215:
5216:            //#endif JDBC3
5217:
5218:            /**
5219:             * Retrieves the major version number of the underlying database. <p>
5220:             *
5221:             * <!-- start release-specific documentation -->
5222:             * <div class="ReleaseSpecificDocumentation">
5223:             * <h3>HSQLDB-Specific Information:</h3> <p>
5224:             *
5225:             * Starting with 1.7.2, the feature is supported under JDK14 builds. <p>
5226:             *
5227:             * This value is retrieved through an SQL call to the new
5228:             * {@link Library#getDatabaseMajorVersion} method which allows
5229:             * correct determination of the database major version for both local
5230:             * and remote database instances.
5231:             * </div>
5232:             * <!-- end release-specific documentation -->
5233:             * @return the underlying database's major version
5234:             * @exception SQLException if a database access error occurs
5235:             * @since JDK 1.4, HSQLDB 1.7
5236:             */
5237:            //#ifdef JDBC3
5238:            public int getDatabaseMajorVersion() throws SQLException {
5239:
5240:                ResultSet rs = execute("call \"org.hsqldb.Library.getDatabaseMajorVersion\"()");
5241:
5242:                rs.next();
5243:
5244:                int result = rs.getInt(1);
5245:
5246:                rs.close();
5247:
5248:                return result;
5249:            }
5250:
5251:            //#endif JDBC3
5252:
5253:            /**
5254:             * Retrieves the minor version number of the underlying database. <p>
5255:             *
5256:             * <!-- start release-specific documentation -->
5257:             * <div class="ReleaseSpecificDocumentation">
5258:             * <h3>HSQLDB-Specific Information:</h3> <p>
5259:             *
5260:             * Starting with 1.7.2, the feature is supported under JDK14 builds. <p>
5261:             *
5262:             * This value is retrieved through an SQL call to the new
5263:             * {@link Library#getDatabaseMinorVersion} method which allows
5264:             * correct determination of the database minor version for both local
5265:             * and remote database instances.
5266:             * </div>
5267:             * <!-- end release-specific documentation -->
5268:             * @return underlying database's minor version
5269:             * @exception SQLException if a database access error occurs
5270:             * @since JDK 1.4, HSQLDB 1.7
5271:             */
5272:            //#ifdef JDBC3
5273:            public int getDatabaseMinorVersion() throws SQLException {
5274:
5275:                ResultSet rs = execute("call \"org.hsqldb.Library.getDatabaseMinorVersion\"()");
5276:
5277:                rs.next();
5278:
5279:                int result = rs.getInt(1);
5280:
5281:                rs.close();
5282:
5283:                return result;
5284:            }
5285:
5286:            //#endif JDBC3
5287:
5288:            /**
5289:             * Retrieves the major JDBC version number for this
5290:             * driver. <p>
5291:             *
5292:             * <!-- start release-specific documentation -->
5293:             * <div class="ReleaseSpecificDocumentation">
5294:             * <h3>HSQLDB-Specific Information:</h3> <p>
5295:             *
5296:             * Starting with 1.7.2, the feature is supported under JDK14 builds.
5297:             * </div>
5298:             * <!-- end release-specific documentation -->
5299:             *
5300:             * @return JDBC version major number
5301:             * @exception SQLException if a database access error occurs
5302:             * @since JDK 1.4, HSQLDB 1.7
5303:             */
5304:            //#ifdef JDBC3
5305:            public int getJDBCMajorVersion() throws SQLException {
5306:                return 3;
5307:            }
5308:
5309:            //#endif JDBC3
5310:
5311:            /**
5312:             * Retrieves the minor JDBC version number for this
5313:             * driver. <p>
5314:             *
5315:             * <!-- start release-specific documentation -->
5316:             * <div class="ReleaseSpecificDocumentation">
5317:             * <h3>HSQLDB-Specific Information:</h3> <p>
5318:             *
5319:             * Starting with 1.7.2, the feature is supported under JDK14 builds.
5320:             * </div>
5321:             * <!-- end release-specific documentation -->
5322:             * @return JDBC version minor number
5323:             * @exception SQLException if a database access error occurs
5324:             * @since JDK 1.4, HSQLDB 1.7
5325:             */
5326:            //#ifdef JDBC3
5327:            public int getJDBCMinorVersion() throws SQLException {
5328:                return 0;
5329:            }
5330:
5331:            //#endif JDBC3
5332:
5333:            /**
5334:             * @todo fredt@users we haven't checked it all but should aim at
5335:             *  sqlStateSQL99; Need to review the codes.
5336:             */
5337:
5338:            /**
5339:             * Indicates whether the SQLSTATEs returned by
5340:             * <code>SQLException.getSQLState</code> is X/Open (now known as Open Group)
5341:             * SQL CLI or SQL99. <p>
5342:             *
5343:             * <!-- start release-specific documentation -->
5344:             * <div class="ReleaseSpecificDocumentation">
5345:             * <h3>HSQLDB-Specific Information:</h3> <p>
5346:             *
5347:             * Starting with 1.7.2, HSQLDB returns <code>sqlStateSQL99</code>.
5348:             * </div>
5349:             * <!-- end release-specific documentation -->
5350:             * @return the type of SQLSTATEs, one of:
5351:             *       sqlStateXOpen or
5352:             *       sqlStateSQL99
5353:             * @throws SQLException if a database access error occurs
5354:             * @since JDK 1.4, HSQLDB 1.7
5355:             */
5356:            //#ifdef JDBC3
5357:            public int getSQLStateType() throws SQLException {
5358:                return sqlStateSQL99;
5359:            }
5360:
5361:            //#endif JDBC3
5362:
5363:            /**
5364:             * Indicates whether updates made to a LOB are made on a copy or directly
5365:             * to the LOB. <p>
5366:             *
5367:             * <!-- start release-specific documentation -->
5368:             * <div class="ReleaseSpecificDocumentation">
5369:             * <h3>HSQLDB-Specific Information:</h3> <p>
5370:             *
5371:             * Up to and including 1.7.2, HSQLDB updates the LOB directly. This
5372:             * method return false.
5373:             * </div>
5374:             * <!-- end release-specific documentation -->
5375:             *
5376:             * @return <code>true</code> if updates are made to a copy of the LOB;
5377:             *        <code>false</code> if updates are made directly to the LOB
5378:             * @throws SQLException if a database access error occurs
5379:             * @since JDK 1.4, HSQLDB 1.7
5380:             */
5381:            //#ifdef JDBC3
5382:            public boolean locatorsUpdateCopy() throws SQLException {
5383:                return false;
5384:            }
5385:
5386:            //#endif JDBC3
5387:
5388:            /**
5389:             * Retrieves whether this database supports statement pooling. <p>
5390:             *
5391:             * <!-- start release-specific documentation -->
5392:             * <div class="ReleaseSpecificDocumentation">
5393:             * <h3>HSQLDB-Specific Information:</h3> <p>
5394:             *
5395:             * Up to and including 1.7.2, HSQLDB does not support statement pooling.
5396:             * This method returns false.
5397:             * </div>
5398:             * <!-- end release-specific documentation -->
5399:             *
5400:             * @return <code>true</code> is so;
5401:             * <code>false</code> otherwise
5402:             * @throws SQLException if a database access error occurs
5403:             * @since JDK 1.4, HSQLDB 1.7
5404:             */
5405:            //#ifdef JDBC3
5406:            public boolean supportsStatementPooling() throws SQLException {
5407:                return false;
5408:            }
5409:
5410:            //#endif JDBC3
5411:            //----------------------- Internal Implementation --------------------------
5412:
5413:            /**
5414:             * Constructs a new <code>jdbcDatabaseMetaData</code> object using the
5415:             * specified connection.  This contructor is used by <code>jdbcConnection</code>
5416:             * when producing a <code>DatabaseMetaData</code> object from a call to
5417:             * {@link jdbcConnection#getMetaData() getMetaData}.
5418:             * @param c the connection this object will use to retrieve
5419:             *         instance-specific metadata
5420:             * @throws SQLException never - reserved for future use
5421:             */
5422:            jdbcDatabaseMetaData(jdbcConnection c) throws SQLException {
5423:
5424:                // PRE: is non-null and not closed
5425:                connection = c;
5426:                useSchemaDefault = c.connProperties
5427:                        .isPropertyTrue("default_schema");
5428:            }
5429:
5430:            /**
5431:             * Retrieves an "AND" predicate based on the (column) <code>id</code>,
5432:             * <code>op</code>(erator) and<code>val</code>(ue) arguments to be
5433:             * included in an SQL "WHERE" clause, using the conventions laid out for
5434:             * JDBC DatabaseMetaData filter parameter values. <p>
5435:             *
5436:             * @return an "AND" predicate built from the arguments
5437:             * @param id the simple, non-quoted identifier of a system table
5438:             *      column upon which to filter. <p>
5439:             *
5440:             *      No checking is done for column name validity. <br>
5441:             *      It is assumed the system table column name is correct. <p>
5442:             *
5443:             * @param op the conditional operation to perform using the system table
5444:             *      column name value and the <code>val</code> argument. <p>
5445:             *
5446:             * @param val an object representing the value to use in some conditional
5447:             *      operation, op, between the column identified by the id argument
5448:             *      and this argument. <p>
5449:             *
5450:             *      <UL>
5451:             *          <LI>null causes the empty string to be returned. <p>
5452:             *
5453:             *          <LI>toString().length() == 0 causes the returned expression
5454:             *              to be built so that the IS NULL operation will occur
5455:             *              against the specified column. <p>
5456:             *
5457:             *          <LI>instanceof String causes the returned expression to be
5458:             *              built so that the specified operation will occur between
5459:             *              the specified column and the specified value, converted to
5460:             *              an SQL string (single quoted, with internal single quotes
5461:             *              escaped by doubling). If <code>op</code> is "LIKE" and
5462:             *              <code>val</code> does not contain any "%" or "_" wild
5463:             *              card characters, then <code>op</code> is silently
5464:             *              converted to "=". <p>
5465:             *
5466:             *          <LI>!instanceof String causes an expression to built so that
5467:             *              the specified operation will occur between the specified
5468:             *              column and <code>String.valueOf(val)</code>. <p>
5469:             *
5470:             *      </UL>
5471:             */
5472:            private static String and(String id, String op, Object val) {
5473:
5474:                // The JDBC standard for pattern arguments seems to be:
5475:                //
5476:                // - pass null to mean ignore (do not include in query),
5477:                // - pass "" to mean filter on <column-ident> IS NULL,
5478:                // - pass "%" to filter on <column-ident> IS NOT NULL.
5479:                // - pass sequence with "%" and "_" for wildcard matches
5480:                // - when searching on values reported directly from DatabaseMetaData
5481:                //   results, typically an exact match is desired.  In this case, it
5482:                //   is the client's responsibility to escape any reported "%" and "_"
5483:                //   characters using whatever DatabaseMetaData returns from
5484:                //   getSearchEscapeString(). In our case, this is the standard escape
5485:                //   character: '\'. Typically, '%' will rarely be encountered, but
5486:                //   certainly '_' is to be expected on a regular basis.
5487:                // - checkme:  what about the (silly) case where an identifier
5488:                //   has been declared such as:  'create table "xxx\_yyy"(...)'?
5489:                //   Must the client still escape the Java string like this:
5490:                //   "xxx\\\\_yyy"?
5491:                //   Yes: because otherwise the driver is expected to
5492:                //   construct something like:
5493:                //   select ... where ... like 'xxx\_yyy' escape '\'
5494:                //   which will try to match 'xxx_yyy', not 'xxx\_yyy'
5495:                //   Testing indicates that indeed, higher quality popular JDBC
5496:                //   database browsers do the escapes "properly."
5497:                if (val == null) {
5498:                    return "";
5499:                }
5500:
5501:                StringBuffer sb = new StringBuffer();
5502:                boolean isStr = (val instanceof  String);
5503:
5504:                if (isStr && ((String) val).length() == 0) {
5505:                    return sb.append(" AND ").append(id).append(" IS NULL")
5506:                            .toString();
5507:                }
5508:
5509:                String v = isStr ? Column.createSQLString((String) val)
5510:                        : String.valueOf(val);
5511:
5512:                sb.append(" AND ").append(id).append(' ');
5513:
5514:                // add the escape to like if required
5515:                if (isStr && "LIKE".equalsIgnoreCase(op)) {
5516:                    if (v.indexOf('_') < 0 && v.indexOf('%') < 0) {
5517:
5518:                        // then we can optimize.
5519:                        sb.append("=").append(' ').append(v);
5520:                    } else {
5521:                        sb.append("LIKE").append(' ').append(v);
5522:
5523:                        if ((v.indexOf("\\_") >= 0) || (v.indexOf("\\%") >= 0)) {
5524:
5525:                            // then client has requested at least one escape.
5526:                            sb.append(" ESCAPE '\\'");
5527:                        }
5528:                    }
5529:                } else {
5530:                    sb.append(op).append(' ').append(v);
5531:                }
5532:
5533:                return sb.toString();
5534:            }
5535:
5536:            /**
5537:             * The main SQL statement executor.  All SQL destined for execution
5538:             * ultimately goes through this method. <p>
5539:             *
5540:             * The sqlStatement field for the result is set autoClose to comply with
5541:             * ResultSet.getStatement() semantics for result sets that are not from
5542:             * a user supplied Statement object. (fredt) <p>
5543:             *
5544:             * @param sql SQL statement to execute
5545:             * @return the result of issuing the statement
5546:             * @throws SQLException is a database error occurs
5547:             */
5548:            private ResultSet execute(String sql) throws SQLException {
5549:
5550:                // NOTE:
5551:                // Need to create a jdbcStatement here so jdbcResultSet can return
5552:                // its Statement object on call to getStatement().
5553:                // The native jdbcConnection.execute() method does not
5554:                // automatically assign a Statement object for the ResultSet, but
5555:                // jdbcStatement does.  That is, without this, there is no way for the
5556:                // jdbcResultSet to find its way back to its Connection (or Statement)
5557:                // Also, cannot use single, shared jdbcStatement object, as each
5558:                // fetchResult() closes any old jdbcResultSet before fetching the
5559:                // next, causing the jdbcResultSet's Result object to be nullified
5560:                final int scroll = jdbcResultSet.TYPE_SCROLL_INSENSITIVE;
5561:                final int concur = jdbcResultSet.CONCUR_READ_ONLY;
5562:                ResultSet r = connection.createStatement(scroll, concur)
5563:                        .executeQuery(sql);
5564:
5565:                ((jdbcResultSet) r).autoClose = true;
5566:
5567:                return r;
5568:            }
5569:
5570:            /**
5571:             * An SQL statement executor that knows how to create a "SELECT
5572:             * * FROM" statement, given a table name and a <em>where</em> clause.<p>
5573:             *
5574:             *  If the <em>where</em> clause is null, it is ommited.  <p>
5575:             *
5576:             *  It is assumed that the table name is non-null, since this is a private
5577:             *  method.  No check is performed. <p>
5578:             *
5579:             * @return the result of executing "SELECT * FROM " + table " " + where
5580:             * @param table the name of a table to "select * from"
5581:             * @param where the where condition for the select
5582:             * @throws SQLException if database error occurs
5583:             */
5584:            private ResultSet executeSelect(String table, String where)
5585:                    throws SQLException {
5586:
5587:                String select = selstar + table;
5588:
5589:                if (where != null) {
5590:                    select += " WHERE " + where;
5591:                }
5592:
5593:                return execute(select);
5594:            }
5595:
5596:            /**
5597:             * Retrieves "SELECT * FROM &lt;table&gt; WHERE 1=1" in string
5598:             * buffer form. <p>
5599:             *
5600:             * This is a convenience method provided because, for most
5601:             * <code>DatabaseMetaData</code> queries, this is the most suitable
5602:             * thing upon which to start building. <p>
5603:             *
5604:             * @return an StringBuffer whose content is:
5605:             *      "SELECT * FROM &lt;table&gt; WHERE 1=1"
5606:             * @param t the name of the table
5607:             */
5608:            private StringBuffer toQueryPrefix(String t) {
5609:
5610:                StringBuffer sb = new StringBuffer(255);
5611:
5612:                return sb.append(selstar).append(t).append(whereTrue);
5613:            }
5614:
5615:            /**
5616:             * Retrieves whether the JDBC <code>DatabaseMetaData</code> contract
5617:             * specifies that the argument <code>s</code>code> is filter parameter
5618:             * value that requires a corresponding IS NULL predicate. <p>
5619:             *
5620:             * @param s the filter parameter to test
5621:             * @return true if the argument, s, is filter paramter value that
5622:             *        requires a corresponding IS NULL predicate
5623:             */
5624:            private static boolean wantsIsNull(String s) {
5625:                return (s != null && s.length() == 0);
5626:            }
5627:
5628:            /**
5629:             * For compatibility, when the connection property "default_schame=true"
5630:             * is present, any DatabaseMetaData call with an empty string as the
5631:             * schema parameter will use the default schema (noramlly "PUBLIC").
5632:             */
5633:            private String translateSchema(String schemaName)
5634:                    throws SQLException {
5635:
5636:                if (useSchemaDefault && schemaName != null
5637:                        && schemaName.length() == 0) {
5638:                    ResultSet rs = executeSelect("SYSTEM_SCHEMAS",
5639:                            "IS_DEFAULT=TRUE");
5640:
5641:                    if (rs.next()) {
5642:                        return rs.getString(1);
5643:                    }
5644:
5645:                    return schemaName;
5646:                }
5647:
5648:                return schemaName;
5649:            }
5650:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.