..." => URI of aliased database
* </pre>
*
* <b>Note: No provision is made for qualifying database objects
* by catalog in DML or DDL SQL. This feature is functional only with
* respect to browsing the database through the DatabaseMetaData and system
* table interfaces. <p>
*
* </ol>
*
* Again, it should be well understood that this feature provide an
* <i>emulation of catalog support and is intended only
* as an experimental implementation to enhance the browsing experience
* when using graphical database explorers and to make a first foray
* into tackling the issue of implementing true catalog support
* in the future. <p>
*
* Due the nature of the new database system table production process, fewer
* assumptions can be made by this class about what information is made
* available in the system tables supporting <code>DatabaseMetaData
* methods. Because of this, the SQL queries behind the <code>ResultSet
* producing methods have been cleaned up and made to adhere more strictly to
* the JDBC contracts specified in relation to the method parameters. <p>
*
* One of the remaining assumptions concerns the <code>approximate
* argument of {@link #getIndexInfo getIndexInfo()}. This parameter is still
* ignored since there is not yet any process in place to internally gather
* and persist table and index statistics. A primitive version of a statistics
* gathering and reporting subsystem <em>may be introduced some time in the
* 1.7.x series of releases, but no hard decision has yet been made. <p>
*
* Another assumption is that simple select queries against certain system
* tables will return rows in JDBC contract order in the absence of an
* "ORDER BY" clause. The reason for this is that results
* come back much faster when no "ORDER BY" clause is used.
* Developers wishing to extend or replace an existing system table production
* class should be aware of this, either adding the contract
* "ORDER BY" clause to the SQL in corresponding methods in this class,
* or, better, by maintaing rows in the correct order in the underlying
* system tables, prefereably by creating appropriate primary indices. <p>
*
* <hr>
*
* <b>JRE 1.1.x Notes:
*
* In general, JDBC 2 support requires Java 1.2 and above, and JDBC3 requires
* Java 1.4 and above. In HSQLDB, support for methods introduced in different
* versions of JDBC depends on the JDK version used for compiling and building
* HSQLDB.<p>
*
* Since 1.7.0, it is possible to build the product so that
* all JDBC 2 methods can be called while executing under the version 1.1.x
* <em>Java Runtime EnvironmentTM.
* However, some of these method calls require <code>int values that
* are defined only in the JDBC 2 or greater version of the
* {@link java.sql.ResultSet ResultSet} interface. For this reason, when the
* product is compiled under JDK 1.1.x, these values are defined in
* {@link jdbcResultSet jdbcResultSet}.<p>
*
* In a JRE 1.1.x environment, calling JDBC 2 methods that take or return the
* JDBC2-only <code>ResultSet values can be achieved by referring
* to them in parameter specifications and return value comparisons,
* respectively, as follows: <p>
*
* <pre class="JavaCodeExample">
* jdbcResultSet.FETCH_FORWARD
* jdbcResultSet.TYPE_FORWARD_ONLY
* jdbcResultSet.TYPE_SCROLL_INSENSITIVE
* jdbcResultSet.CONCUR_READ_ONLY
* // etc
* </pre>
*
* However, please note that code written in such a manner will not be
* compatible for use with other JDBC 2 drivers, since they expect and use
* <code>ResultSet, rather than jdbcResultSet
. Also
* note, this feature is offered solely as a convenience to developers
* who must work under JDK 1.1.x due to operating constraints, yet wish to
* use some of the more advanced features available under the JDBC 2
* specification.<p>
*
* (fredt@users)<br>
* (boucherb@users)
* </div>
* <!-- end release-specific documentation -->
*
* @author boucherb@users
* @author fredt@users
* @version 1.7.2
* @see org.hsqldb.DatabaseInformation
* @see org.hsqldb.DatabaseInformationMain
* @see org.hsqldb.DatabaseInformationFull
*/
public class jdbcDatabaseMetaData implements DatabaseMetaData {
/** Used by getBestRowIdentifier to avoid extra object construction */
static final Integer INT_COLUMNS_NO_NULLS = new Integer(columnNoNulls);
// -----------------------------------------------------------------------
// private attributes
// -----------------------------------------------------------------------
/**
* The connection this object uses to retrieve database instance-specific
* metadata.
*/
private jdbcConnection connection;
/**
* Connection property for schema reporting.
*/
private boolean useSchemaDefault;
/**
* A CSV list representing the SQL IN list to use when generating
* queries for <code>getBestRowIdentifier when the
* <code>scope argument is bestRowSession
.
* @since HSQLDB 1.7.2
*/
private static final String BRI_SESSION_SCOPE_IN_LIST = "("
+ bestRowSession + ")";
/**
* A CSV list representing the SQL IN list to use when generating
* queries for <code>getBestRowIdentifier when the
* <code>scope argument is bestRowTemporary
.
* @since HSQLDB 1.7.2
*/
private static final String BRI_TEMPORARY_SCOPE_IN_LIST = "("
+ bestRowTemporary + "," + bestRowTransaction + "," + bestRowSession
+ ")";
/**
* A CSV list representing the SQL IN list to use when generating
* queries for <code>getBestRowIdentifier when the
* <code>scope argument is bestRowTransaction
.
* @since HSQLDB 1.7.2
*/
private static final String BRI_TRANSACTION_SCOPE_IN_LIST = "("
+ bestRowTransaction + "," + bestRowSession + ")";
/**
* "SELECT * FROM ". <p>
*
* This attribute is in support of methods that use SQL SELECT statements to
* generate returned <code>ResultSet objects.
*
* @since HSQLDB 1.7.2
*/
private static final String selstar = "SELECT * FROM INFORMATION_SCHEMA.";
/**
* " WHERE 1=1 ". <p>
*
* This attribute is in support of methods that use SQL SELECT statements to
* generate returned <code>ResultSet objects.
*
* A good optimizer will simply drop this when parsing a condition
* expression. And it makes our code much easier to write, since we don't
* have to check our "WHERE" clause productions as strictly for proper
* conjunction: we just stick additional conjunctive predicates on the
* end of this and Presto! Everything works :-) <p>
* @since HSQLDB 1.7.2
*/
private static final String whereTrue = " WHERE 1=1";
//----------------------------------------------------------------------
// First, a variety of minor information about the target database.
/**
* Retrieves whether the current user can call all the procedures
* returned by the method <code>getProcedures.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* This method still <em>always returns
* <code>true.
*
* In a future release, the plugin interface may be modified to allow
* implementors to report different values here, based on their
* implementations.
* </div>
* <!-- end release-specific documentation -->
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean allProceduresAreCallable() throws SQLException {
return true;
}
/**
* Retrieves whether the current user can use all the tables returned
* by the method <code>getTables in a SELECT
* statement. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB always reports <code>true.
*
* Please note that the default 1.7.2 <code>getTables behaviour is
* omit from the list of <em>requested tables only those to which the
* invoking user has <em>no access of any kind.
*
* </div>
* <!-- end release-specific documentation -->
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean allTablesAreSelectable() throws SQLException {
return true;
}
/**
* Retrieves the URL for this DBMS.
*
*
* @return the URL for this DBMS or <code>null if it cannot be
* generated
* @exception SQLException if a database access error occurs
*/
public String getURL() throws SQLException {
return connection.getURL();
}
/**
* Retrieves the user name as known to this database.
*
*
* @return the database user name
* @exception SQLException if a database access error occurs
*/
public String getUserName() throws SQLException {
ResultSet rs = execute("CALL USER()");
rs.next();
String result = rs.getString(1);
rs.close();
return result;
}
/**
* Retrieves whether this database is in read-only mode. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Starting with 1.7.2, this makes
* an SQL call to the new {@link Library#isReadOnlyDatabase} method
* which provides correct determination of the read-only status for
* both local and remote database instances.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean isReadOnly() throws SQLException {
ResultSet rs =
execute("CALL \"org.hsqldb.Library.isReadOnlyDatabase\"()");
rs.next();
boolean result = rs.getBoolean(1);
rs.close();
return result;
}
/**
* Retrieves whether <code>NULL values are sorted high.
* Sorted high means that <code>NULL values
* sort higher than any other value in a domain. In an ascending order,
* if this method returns <code>true, NULL
values
* will appear at the end. By contrast, the method
* <code>nullsAreSortedAtEnd indicates whether NULL
values
* are sorted at the end regardless of sort order. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB sorts null low; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean nullsAreSortedHigh() throws SQLException {
return false;
}
/**
* Retrieves whether <code>NULL values are sorted low.
* Sorted low means that <code>NULL values
* sort lower than any other value in a domain. In an ascending order,
* if this method returns <code>true, NULL
values
* will appear at the beginning. By contrast, the method
* <code>nullsAreSortedAtStart indicates whether NULL
values
* are sorted at the beginning regardless of sort order. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB sorts null low; this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean nullsAreSortedLow() throws SQLException {
return true;
}
/**
* Retrieves whether <code>NULL values are sorted at the start regardless
* of sort order. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB sorts null low; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean nullsAreSortedAtStart() throws SQLException {
return false;
}
/**
* Retrieves whether <code>NULL values are sorted at the end regardless of
* sort order. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB sorts null low; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean nullsAreSortedAtEnd() throws SQLException {
return false;
}
/**
* Retrieves the name of this database product. <p>
*
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Starting with HSQLDB 1.7.2, this value is retrieved through an
* SQL call to the new {@link Library#getDatabaseProductName} method
* which allows correct determination of the database product name
* for both local and remote database instances.
* </div>
*
* @return database product name
* @exception SQLException if a database access error occurs
*/
public String getDatabaseProductName() throws SQLException {
ResultSet rs =
execute("call \"org.hsqldb.Library.getDatabaseProductName\"()");
rs.next();
String result = rs.getString(1);
rs.close();
return result;
}
/**
* Retrieves the version number of this database product. <p>
*
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Starting with HSQLDB 1.7.2, this value is retrieved through an
* SQL call to the new {@link Library#getDatabaseProductVersion} method
* which allows correct determination of the database product name
* for both local and remote database instances.
* </div>
*
* @return database version number
* @exception SQLException if a database access error occurs
*/
public String getDatabaseProductVersion() throws SQLException {
ResultSet rs =
execute("call \"org.hsqldb.Library.getDatabaseProductVersion\"()");
rs.next();
String result = rs.getString(1);
rs.close();
return result;
}
/**
* Retrieves the name of this JDBC driver.
*
* @return JDBC driver name
* @exception SQLException if a database access error occurs
*/
public String getDriverName() throws SQLException {
return HsqlDatabaseProperties.PRODUCT_NAME + " Driver";
}
/**
* Retrieves the version number of this JDBC driver as a <code>String.
*
* @return JDBC driver version
* @exception SQLException if a database access error occurs
*/
public String getDriverVersion() throws SQLException {
return HsqlDatabaseProperties.THIS_VERSION;
}
/**
* Retrieves this JDBC driver's major version number.
*
* @return JDBC driver major version
*/
public int getDriverMajorVersion() {
return HsqlDatabaseProperties.MAJOR;
}
/**
* Retrieves this JDBC driver's minor version number.
*
* @return JDBC driver minor version number
*/
public int getDriverMinorVersion() {
return HsqlDatabaseProperties.MINOR;
}
/**
* Retrieves whether this database stores tables in a local file. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* From HSQLDB 1.7.2 it is assumed that this refers to data being stored
* by the JDBC client. This method always returns false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean usesLocalFiles() throws SQLException {
return false;
}
/**
* Retrieves whether this database uses a file for each table. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not use a file for each table.
* This method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if this database uses a local file for each table;
* <code>false otherwise
* @exception SQLException if a database access error occurs
*/
public boolean usesLocalFilePerTable() throws SQLException {
return false;
}
/**
* Retrieves whether this database treats mixed case unquoted SQL identifiers as
* case sensitive and as a result stores them in mixed case. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive and stores
* them in upper case. It treats quoted identifiers as case sensitive and
* stores them verbatim; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsMixedCaseIdentifiers() throws SQLException {
return false;
}
/**
* Retrieves whether this database treats mixed case unquoted SQL identifiers as
* case insensitive and stores them in upper case. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive and stores
* them in upper case. It treats quoted identifiers as case sensitive and
* stores them verbatim; this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean storesUpperCaseIdentifiers() throws SQLException {
return true;
}
/**
* Retrieves whether this database treats mixed case unquoted SQL identifiers as
* case insensitive and stores them in lower case. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive and stores
* them in upper case. It treats quoted identifiers as case sensitive and
* stores them verbatim; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean storesLowerCaseIdentifiers() throws SQLException {
return false;
}
/**
* Retrieves whether this database treats mixed case unquoted SQL identifiers as
* case insensitive and stores them in mixed case. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive and stores
* them in upper case. It treats quoted identifiers as case sensitive and
* stores them verbatim; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean storesMixedCaseIdentifiers() throws SQLException {
return false;
}
/**
* Retrieves whether this database treats mixed case quoted SQL identifiers as
* case sensitive and as a result stores them in mixed case. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive and stores
* them in upper case. It treats quoted identifiers as case sensitive and
* stores them verbatim; this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
return true;
}
/**
* Retrieves whether this database treats mixed case quoted SQL identifiers as
* case insensitive and stores them in upper case. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive and stores
* them in upper case. It treats quoted identifiers as case sensitive and
* stores them verbatim; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
return false;
}
/**
* Retrieves whether this database treats mixed case quoted SQL identifiers as
* case insensitive and stores them in lower case. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive and stores
* them in upper case. It treats quoted identifiers as case sensitive and
* stores them verbatim; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
return false;
}
/**
* Retrieves whether this database treats mixed case quoted SQL identifiers as
* case insensitive and stores them in mixed case. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive and stores
* them in upper case. It treats quoted identifiers as case sensitive and
* stores them verbatim; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
return false;
}
/**
* Retrieves the string used to quote SQL identifiers.
* This method returns a space " " if identifier quoting is not supported. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB uses the standard SQL identifier quote character
* (the double quote character); this method always returns <b>".
* </div>
* <!-- end release-specific documentation -->
* @return the quoting string or a space if quoting is not supported
* @exception SQLException if a database access error occurs
*/
public String getIdentifierQuoteString() throws SQLException {
return "\"";
}
//fredt@users 20020429 - JavaDoc comment - in 1.7.1 there are keywords such
// as TEMP, TEXT, CACHED that are not SQL 92 keywords
/**
* Retrieves a comma-separated list of all of this database's SQL keywords
* that are NOT also SQL92 keywords. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* The list returned contains HSQLDB keywords that are not in the list
* of reserved words. Some of these are in the list reserved
* words for SQL 2003 but are not SQL92 keywords.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return the list of this database's keywords that are not also
* SQL92 keywords
* @exception SQLException if a database access error occurs
*/
public String getSQLKeywords() throws SQLException {
return "BEFORE,BIGINT,BINARY,CACHED,DATETIME,"
+ "LIMIT,LONGVARBINARY,LONGVARCHAR,OBJECT,OTHER,SAVEPOINT,"
+ "TEMP,TEXT,TOP,TRIGGER,TINYINT,VARBINARY,VARCHAR_IGNORECASE";
}
/**
* Retrieves a comma-separated list of math functions available with
* this database. These are the Open Group CLI math function names used in
* the JDBC function escape clause.
* @return the list of math functions supported by this database
* @exception SQLException if a database access error occurs
*/
public String getNumericFunctions() throws SQLException {
return StringUtil.getList(Library.sNumeric, ",", "");
}
/**
* Retrieves a comma-separated list of string functions available with
* this database. These are the Open Group CLI string function names used
* in the JDBC function escape clause.
* @return the list of string functions supported by this database
* @exception SQLException if a database access error occurs
*/
public String getStringFunctions() throws SQLException {
return StringUtil.getList(Library.sString, ",", "");
}
/**
* Retrieves a comma-separated list of system functions available with
* this database. These are the Open Group CLI system function names used
* in the JDBC function escape clause.
* @return a list of system functions supported by this database
* @exception SQLException if a database access error occurs
*/
public String getSystemFunctions() throws SQLException {
return StringUtil.getList(Library.sSystem, ",", "");
}
/**
* Retrieves a comma-separated list of the time and date functions available
* with this database.
* @return the list of time and date functions supported by this database
* @exception SQLException if a database access error occurs
*/
public String getTimeDateFunctions() throws SQLException {
return StringUtil.getList(Library.sTimeDate, ",", "");
}
/**
* Retrieves the string that can be used to escape wildcard characters.
* This is the string that can be used to escape '_' or '%' in
* the catalog search parameters that are a pattern (and therefore use one
* of the wildcard characters).
*
* <P>The '_' character represents any single character;
* the '%' character represents any sequence of zero or
* more characters. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB uses the "\" character to escape wildcard characters.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return the string used to escape wildcard characters
* @exception SQLException if a database access error occurs
*/
public String getSearchStringEscape() throws SQLException {
return "\\";
}
/**
* Retrieves all the "extra" characters that can be used in unquoted
* identifier names (those beyond a-z, A-Z, 0-9 and _). <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not support using any "extra" characters in unquoted
* identifier names; this method always returns the empty String.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return the string containing the extra characters
* @exception SQLException if a database access error occurs
*/
public String getExtraNameCharacters() throws SQLException {
return "";
}
//--------------------------------------------------------------------
// Functions describing which features are supported.
/**
* Retrieves whether this database supports <code>ALTER TABLE
* with add column. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* From 1.7.0, HSQLDB supports this type of
* <code>ALTER TABLE statement; this method always
* returns <code>true.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsAlterTableWithAddColumn() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports <code>ALTER TABLE
* with drop column. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* From 1.7.0, HSQLDB supports this type of
* <code>ALTER TABLE statement; this method always
* returns <code>true.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsAlterTableWithDropColumn() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports column aliasing.
*
* <P>If so, the SQL AS clause can be used to provide names for
* computed columns or to provide alias names for columns as
* required. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports column aliasing; this method always
* returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsColumnAliasing() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports concatenations between
* <code>NULL and non-NULL
values being
* <code>NULL.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports this; this method always
* returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean nullPlusNonNullIsNull() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports the <code>CONVERT
* function between SQL types. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports conversions; this method always
* returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsConvert() throws SQLException {
return true;
}
// fredt@users - JD comment - I think this is unsupported at the moment
// because SQL92 says conversion is implementation dependent, so if
// conversion from DOUBLE to INTEGER were possbible we would return the
// whole number part, but we currently throw. I'm not so sure about
// conversions between string and numeric where it is logically possible
// only if the string represents a numeric value
/**
* Retrieves whether this database supports the <code>CONVERT
* for two given SQL types. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports conversion though String intermediates, so everything
* should be possible, short of number format errors (all Java objects
* have a toString method); this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @param fromType the type to convert from; one of the type codes from
* the class <code>java.sql.Types
* @param toType the type to convert to; one of the type codes from
* the class <code>java.sql.Types
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
* @see java.sql.Types
*/
public boolean supportsConvert(int fromType,
int toType) throws SQLException {
return true;
}
/**
* Retrieves whether this database supports table correlation names. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports table correlation names; this method always
* returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsTableCorrelationNames() throws SQLException {
return true;
}
/**
* Retrieves whether, when table correlation names are supported, they
* are restricted to being different from the names of the tables. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB requires that table correlation names are different from the
* names of the tables; this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsDifferentTableCorrelationNames()
throws SQLException {
return true;
}
/**
* Retrieves whether this database supports expressions in
* <code>ORDER BY lists.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports expressions in <code>ORDER BY lists; this
* method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsExpressionsInOrderBy() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports using a column that is
* not in the <code>SELECT statement in an
* <code>ORDER BY clause.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports using a column that is not in the <code>SELECT
* statement in an <code>ORDER BY clause; this method always
* returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsOrderByUnrelated() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports some form of
* <code>GROUP BY clause.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports using the <code>GROUP BY clause; this method
* always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsGroupBy() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports using a column that is
* not in the <code>SELECT statement in a
* <code>GROUP BY clause.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports using a column that is
* not in the <code>SELECT statement in a
* <code>GROUP BY clause; this method
* always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsGroupByUnrelated() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports using columns not included in
* the <code>SELECT statement in a GROUP BY
clause
* provided that all of the columns in the <code>SELECT statement
* are included in the <code>GROUP BY clause.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports using columns not included in
* the <code>SELECT statement in a GROUP BY
clause
* provided that all of the columns in the <code>SELECT statement
* are included in the <code>GROUP BY clause; this method
* always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsGroupByBeyondSelect() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports specifying a
* <code>LIKE escape clause.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports specifying a
* <code>LIKE escape clause; this method
* always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsLikeEscapeClause() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports getting multiple
* <code>ResultSet objects from a single call to the
* method <code>execute.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support getting multiple
* <code>ResultSet objects from a single call to the
* method <code>execute; this method
* always returns <code>false.
*
* This behaviour <i>may change in a future release.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsMultipleResultSets() throws SQLException {
return false;
}
/**
* Retrieves whether this database allows having multiple
* transactions open at once (on different connections). <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB allows having multiple
* transactions open at once (on different connections); this method
* always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsMultipleTransactions() throws SQLException {
return true;
}
/**
* Retrieves whether columns in this database may be defined as
* non-nullable. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports the specification of non-nullable columns; this method
* always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsNonNullableColumns() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports the ODBC Minimum SQL grammar. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support the ODBC
* Minimum SQL grammar; this method
* always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsMinimumSQLGrammar() throws SQLException {
return false;
}
/**
* Retrieves whether this database supports the ODBC Core SQL grammar. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* From 1.7.2 this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsCoreSQLGrammar() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports the ODBC Extended SQL grammar. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support the ODBC
* Extended SQL grammar; this method
* always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsExtendedSQLGrammar() throws SQLException {
return false;
}
/**
* Retrieves whether this database supports the ANSI92 entry level SQL
* grammar. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support the ANSI92 entry
* level SQL grammar; this method
* always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsANSI92EntryLevelSQL() throws SQLException {
return false;
}
/**
* Retrieves whether this database supports the ANSI92 intermediate SQL
* grammar supported. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support the ANSI92
* intermediate SQL grammar; this method always returns
* <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsANSI92IntermediateSQL() throws SQLException {
return false;
}
/**
* Retrieves whether this database supports the ANSI92 full SQL
* grammar supported. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support the ANSI92
* full SQL grammar; this method always returns
* <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsANSI92FullSQL() throws SQLException {
return false;
}
// fredt@users 20030413 - return value change to support OpenOffice.org
/**
* Retrieves whether this database supports the SQL Integrity
* Enhancement Facility. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* From 1.7.2, this method always returns
* <code>true.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsIntegrityEnhancementFacility() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports some form of outer join. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports outer joins; this method always returns
* <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsOuterJoins() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports full nested outer joins. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support full nested outer
* joins; this method always returns <code>false.
*
* This behaviour may change in a future release.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsFullOuterJoins() throws SQLException {
return false;
}
/**
* Retrieves whether this database provides limited support for outer
* joins. (This will be <code>true if the method
* <code>supportsFullOuterJoins returns true
).
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB support the LEFT OUTER join syntax;
* this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsLimitedOuterJoins() throws SQLException {
return true;
}
/**
* Retrieves the database vendor's preferred term for "schema". <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Starting with 1.8.0, HSQLDB provides support for schemas.
* </div>
* <!-- end release-specific documentation -->
* @return the vendor term for "schema"
* @exception SQLException if a database access error occurs
*/
public String getSchemaTerm() throws SQLException {
return "SCHEMA";
}
/**
* Retrieves the database vendor's preferred term for "procedure". <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support declaration of
* functions or procedures directly in SQL but instead relies on the
* HSQLDB-specific CLASS grant mechanism to make public static
* Java methods available as SQL routines; this method always returns
* an empty <code>String.
* </div>
* <!-- end release-specific documentation -->
* @return the vendor term for "procedure"
* @exception SQLException if a database access error occurs
*/
public String getProcedureTerm() throws SQLException {
return "";
}
/**
* Retrieves the database vendor's preferred term for "catalog". <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Including 1.7.2, HSQLDB does not support catalogs in DDL or DML;
* this method <ewm>always returns the empty String.
* </div>
* <!-- end release-specific documentation -->
*
* @return the vendor term for "catalog"
* @exception SQLException if a database access error occurs
*/
public String getCatalogTerm() throws SQLException {
return "";
}
/**
* Retrieves whether a catalog appears at the start of a fully qualified
* table name. If not, the catalog appears at the end. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support catalogs in DDL or DML;
* this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if the catalog name appears at the beginning
* of a fully qualified table name; <code>false otherwise
* @exception SQLException if a database access error occurs
*/
public boolean isCatalogAtStart() throws SQLException {
return false;
}
/**
* Retrieves the <code>String that this database uses as the
* separator between a catalog and table name. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Including 1.7.2, HSQLDB does not support catalogs in DDL or DML;
* this method <em>always returns an empty String
.
* </div>
* <!-- end release-specific documentation -->
*
* @return the separator string
* @exception SQLException if a database access error occurs
*/
public String getCatalogSeparator() throws SQLException {
return "";
}
/**
* Retrieves whether a schema name can be used in a data
* manipulation statement. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* In 1.8.0, HSQLDB supports schemas in table names but not in column names;
* this method always returns <code>false.
*
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsSchemasInDataManipulation() throws SQLException {
// false for OOo client server compatibility
// otherwise schema name is used by OOo in column references
return false;
}
/**
* Retrieves whether a schema name can be used in a procedure call
* statement. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support schema-qualified
* procedure identifiers; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsSchemasInProcedureCalls() throws SQLException {
return false;
}
/**
* Retrieves whether a schema name can be used in a table
* definition statement. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* In 1.8.0, HSQLDB supports schemas;
* By default, this method returns <code>true.
*
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsSchemasInTableDefinitions() throws SQLException {
return !useSchemaDefault;
}
/**
* Retrieves whether a schema name can be used in an index
* definition statement. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* In 1.8.0, HSQLDB supports schemas;
* By default, this method returns <code>true.
*
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsSchemasInIndexDefinitions() throws SQLException {
return !useSchemaDefault;
}
/**
* Retrieves whether a schema name can be used in a privilege
* definition statement. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* In 1.8.0, HSQLDB supports schemas;
* By default, this method returns <code>true.
*
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsSchemasInPrivilegeDefinitions()
throws SQLException {
return !useSchemaDefault;
}
/**
* Retrieves whether a catalog name can be used in a data
* manipulation statement. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support catalog-qualified;
* data manipulation; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsCatalogsInDataManipulation() throws SQLException {
return false;
}
/**
* Retrieves whether a catalog name can be used in a
* procedure call statement. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support catalog-qualified
* procedure calls; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsCatalogsInProcedureCalls() throws SQLException {
return false;
}
/**
* Retrieves whether a catalog name can be used in a
* table definition statement. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support catalog-qualified
* table definitions; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsCatalogsInTableDefinitions() throws SQLException {
return false;
}
/**
* Retrieves whether a catalog name can be used in an
* index definition statement. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support catalog-qualified
* index definitions; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
return false;
}
/**
* Retrieves whether a catalog name can be used in a
* privilege definition statement. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support catalog-qualified
* privilege definitions; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsCatalogsInPrivilegeDefinitions()
throws SQLException {
return false;
}
/**
* Retrieves whether this database supports positioned <code>DELETE
* statements. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support updateable
* result sets; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsPositionedDelete() throws SQLException {
return false;
}
/**
* Retrieves whether this database supports positioned <code>UPDATE
* statements. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support updateable
* result sets; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsPositionedUpdate() throws SQLException {
return false;
}
/**
* Retrieves whether this database supports <code>SELECT FOR UPDATE
* statements. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support explicit locking;
* this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsSelectForUpdate() throws SQLException {
return false;
}
/**
* Retrieves whether this database supports stored procedure calls
* that use the stored procedure escape syntax. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB supports calling public static
* Java methods in the context of SQL Stored Procedures; this method
* always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
* @see jdbcPreparedStatement
* @see jdbcConnection#prepareCall
*/
public boolean supportsStoredProcedures() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports subqueries in comparison
* expressions. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB has always supported subqueries in comparison expressions;
* this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsSubqueriesInComparisons() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports subqueries in
* <code>EXISTS expressions.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB has always supported subqueries in <code>EXISTS
* expressions; this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsSubqueriesInExists() throws SQLException {
return true;
}
/**
* JDBC4 correction: Retrieves whether this database supports subqueries in
* <code>IN expressions.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB has always supported subqueries in <code>IN
* statements; this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsSubqueriesInIns() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports subqueries in quantified
* expressions. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB has always supported subqueries in quantified
* expressions; this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsSubqueriesInQuantifieds() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports correlated subqueries. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB has always supported correlated subqueries;
* this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsCorrelatedSubqueries() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports SQL <code>UNION.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports SQL <code>UNION;
* this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsUnion() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports SQL <code>UNION ALL.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports SQL <code>UNION ALL;
* this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsUnionAll() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports keeping cursors open
* across commits. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support keeping
* cursors open across commits; this method always returns
* <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if cursors always remain open;
* <code>false if they might not remain open
* @exception SQLException if a database access error occurs
*/
public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
return false;
}
/**
* Retrieves whether this database supports keeping cursors open
* across rollbacks. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support keeping
* cursors open across rollbacks;
* this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if cursors always remain open;
* <code>false if they might not remain open
* @exception SQLException if a database access error occurs
*/
public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
return false;
}
/**
* Retrieves whether this database supports keeping statements open
* across commits. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports keeping statements open
* across commits;
* this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if statements always remain open;
* <code>false if they might not remain open
* @exception SQLException if a database access error occurs
*/
public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports keeping statements open
* across rollbacks. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports keeping statements open
* across commits;
* this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if statements always remain open;
* <code>false if they might not remain open
* @exception SQLException if a database access error occurs
*/
public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
return true;
}
//----------------------------------------------------------------------
// The following group of methods exposes various limitations
// based on the target database with the current driver.
// Unless otherwise specified, a result of zero means there is no
// limit, or the limit is not known.
/**
* Retrieves the maximum number of hex characters this database allows in an
* inline binary literal. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit. The hard limit is the maximum
* length of a java.lang.String (java.lang.Integer.MAX_VALUE);
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return max the maximum length (in hex characters) for a binary literal;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxBinaryLiteralLength() throws SQLException {
// hard limit is Integer.MAX_VALUE
return 0;
}
/**
* Retrieves the maximum number of characters this database allows
* for a character literal. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit. The hard limit is the maximum
* length of a java.lang.String (java.lang.Integer.MAX_VALUE);
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of characters allowed for a character literal;
* a result of zero means that there is no limit or the limit is
* not known
* @exception SQLException if a database access error occurs
*/
public int getMaxCharLiteralLength() throws SQLException {
// hard limit is Integer.MAX_VALUE
return 0;
}
/**
* Retrieves the maximum number of characters this database allows
* for a column name. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit. The hard limit is the maximum
* length of a java.lang.String (java.lang.Integer.MAX_VALUE);
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of characters allowed for a column name;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxColumnNameLength() throws SQLException {
// hard limit is Integer.MAX_VALUE
return 0;
}
/**
* Retrieves the maximum number of columns this database allows in a
* <code>GROUP BY clause.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit. The hard limit is the maximum
* length of a Java array (java.lang.Integer.MAX_VALUE);
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of columns allowed;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxColumnsInGroupBy() throws SQLException {
// hard limit is Integer.MAX_VALUE
return 0;
}
/**
* Retrieves the maximum number of columns this database allows in
* an index. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit. The hard limit is the maximum
* length of a Java array (java.lang.Integer.MAX_VALUE);
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of columns allowed;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxColumnsInIndex() throws SQLException {
// hard limit is Integer.MAX_VALUE
return 0;
}
/**
* Retrieves the maximum number of columns this database allows in an
* <code>ORDER BY clause.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit. The hard limit is the maximum
* length of a Java array (java.lang.Integer.MAX_VALUE);
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of columns allowed;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxColumnsInOrderBy() throws SQLException {
// hard limit is Integer.MAX_VALUE
return 0;
}
/**
* Retrieves the maximum number of columns this database allows in a
* <code>SELECT list.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit. The hard limit is the maximum
* length of a Java array (java.lang.Integer.MAX_VALUE);
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of columns allowed;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxColumnsInSelect() throws SQLException {
// hard limit is Integer.MAX_VALUE
return 0;
}
/**
* Retrieves the maximum number of columns this database allows in
* a table. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit. The hard limit is the maximum
* length of a Java array (java.lang.Integer.MAX_VALUE);
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of columns allowed;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxColumnsInTable() throws SQLException {
// hard limit is Integer.MAX_VALUE
return 0;
}
/**
* Retrieves the maximum number of concurrent connections to this
* database that are possible. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit. The hard limit is the maximum
* length of a Java array (java.lang.Integer.MAX_VALUE);
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of active connections possible at one time;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxConnections() throws SQLException {
// hard limit is (probably) Integer.MAX_VALUE
return 0;
}
/**
* Retrieves the maximum number of characters that this database allows in a
* cursor name. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit. The hard limit is the maximum
* length of a java.lang.String (java.lang.Integer.MAX_VALUE);
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of characters allowed in a cursor name;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxCursorNameLength() throws SQLException {
return 0;
}
/**
* Retrieves the maximum number of bytes this database allows for an
* index, including all of the parts of the index. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit;
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of bytes allowed; this limit includes the
* composite of all the constituent parts of the index;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxIndexLength() throws SQLException {
return 0;
}
/**
* Retrieves the maximum number of characters that this database allows in a
* schema name. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* 1.8.0 supports schema names with no known limit imposed,
* so this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
* @return the maximum number of characters allowed in a schema name;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxSchemaNameLength() throws SQLException {
return 0;
}
/**
* Retrieves the maximum number of characters that this database allows in a
* procedure name. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit. The hard limit is the maximum
* length of a java.lang.String (java.lang.Integer.MAX_VALUE);
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of characters allowed in a procedure name;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxProcedureNameLength() throws SQLException {
return 0;
}
/**
* Retrieves the maximum number of characters that this database allows in a
* catalog name. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support catalogs in
* DDL or DML; this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of characters allowed in a catalog name;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxCatalogNameLength() throws SQLException {
return 0;
}
/**
* Retrieves the maximum number of bytes this database allows in
* a single row. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit;
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of bytes allowed for a row; a result of
* zero means that there is no limit or the limit is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxRowSize() throws SQLException {
return 0;
}
/**
* Retrieves whether the return value for the method
* <code>getMaxRowSize includes the SQL data types
* <code>LONGVARCHAR and LONGVARBINARY
.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Indormation:
*
* Including 1.7.2, {@link #getMaxRowSize} <em>always returns
* 0, indicating that the maximum row size is unknown or has no limit.
* This applies to the above types as well; this method <em>always
* returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {
return true;
}
/**
* Retrieves the maximum number of characters this database allows in
* an SQL statement. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit. The hard limit is the maximum
* length of a java.lang.String (java.lang.Integer.MAX_VALUE);
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of characters allowed for an SQL statement;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxStatementLength() throws SQLException {
return 0;
}
/**
* Retrieves the maximum number of active statements to this database
* that can be open at the same time. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit;
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of statements that can be open at one time;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxStatements() throws SQLException {
return 0;
}
/**
* Retrieves the maximum number of characters this database allows in
* a table name. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit. The hard limit is the maximum
* length of a java.lang.String (java.lang.Integer.MAX_VALUE);
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of characters allowed for a table name;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxTableNameLength() throws SQLException {
return 0;
}
/**
* Retrieves the maximum number of tables this database allows in a
* <code>SELECT statement.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit. The hard limit is the maximum
* length of a Java array (java.lang.Integer.MAX_VALUE);
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of tables allowed in a <code>SELECT
* statement; a result of zero means that there is no limit or
* the limit is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxTablesInSelect() throws SQLException {
// - soft limit is >>> than will ever be seen in any real stmnt
// - exists a fixed (non statement dependent) hard limit? No.
// - depends totally on number of table idents that can fit in
// Integer.MAX_VALUE characters, minus the rest of the stmnt
return 0;
}
/**
* Retrieves the maximum number of characters this database allows in
* a user name. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not impose a "known" limit. The hard limit is the maximum
* length of a java.lang.String (java.lang.Integer.MAX_VALUE);
* this method always returns <code>0.
* </div>
* <!-- end release-specific documentation -->
*
* @return the maximum number of characters allowed for a user name;
* a result of zero means that there is no limit or the limit
* is not known
* @exception SQLException if a database access error occurs
*/
public int getMaxUserNameLength() throws SQLException {
// hard limit is Integer.MAX_VALUE
return 0;
}
//----------------------------------------------------------------------
/**
* Retrieves this database's default transaction isolation level. The
* possible values are defined in <code>java.sql.Connection.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information
*
* Including 1.7.2, HSQLDB supports only TRANSACTION_READ_UNCOMMITED
* and <em>always returns this value here.
* </div>
* <!-- end release-specific documentation -->
*
* @return the default isolation level
* @exception SQLException if a database access error occurs
* @see jdbcConnection
*/
public int getDefaultTransactionIsolation() throws SQLException {
return Connection.TRANSACTION_READ_UNCOMMITTED;
}
/**
* Retrieves whether this database supports transactions. If not, invoking the
* method <code>commit is a noop, and the isolation level is
* <code>TRANSACTION_NONE.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports transactions;
* this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if transactions are supported;
* <code>false otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsTransactions() throws SQLException {
return true;
}
/**
* Retrieves whether this database supports the given transaction
* isolation level. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information
* HSQLDB supports <code>TRANSACTION_READ_UNCOMMITED in all cases
* and the rest of the isolation levels where there is only one connection
* to the database.
* </div>
* <!-- end release-specific documentation -->
*
*
* @param level one of the transaction isolation levels defined in
* <code>java.sql.Connection
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
* @see jdbcConnection
*/
public boolean supportsTransactionIsolationLevel(int level)
throws SQLException {
return level == Connection.TRANSACTION_READ_UNCOMMITTED
|| level == Connection.TRANSACTION_READ_COMMITTED
|| level == Connection.TRANSACTION_REPEATABLE_READ
|| level == Connection.TRANSACTION_SERIALIZABLE;
}
/**
* Retrieves whether this database supports both data definition and
* data manipulation statements within a transaction. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB does not support a mix of both data definition and
* data manipulation statements within a transaction. DDL commits the
* current transaction before proceding;
* this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsDataDefinitionAndDataManipulationTransactions()
throws SQLException {
return false;
}
/**
* Retrieves whether this database supports only data manipulation
* statements within a transaction. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB supports only data manipulation
* statements within a transaction. DDL commits the
* current transaction before proceeding, while DML does not;
* this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean supportsDataManipulationTransactionsOnly()
throws SQLException {
return true;
}
/**
* Retrieves whether a data definition statement within a transaction forces
* the transaction to commit. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Including 1.7.2, a data definition statement within a transaction forces
* the transaction to commit; this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean dataDefinitionCausesTransactionCommit()
throws SQLException {
return true;
}
/**
* Retrieves whether this database ignores a data definition statement
* within a transaction. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Including 1.7.2, a data definition statement is not ignored within a
* transaction. Rather, a data definition statement within a
* transaction forces the transaction to commit; this method
* <em>always returns false
.
* </div>
* <!-- end release-specific documentation -->
*
*
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
*/
public boolean dataDefinitionIgnoredInTransactions() throws SQLException {
return false;
}
/**
* Retrieves a description of the stored procedures available in the given
* catalog.
* <P>
* Only procedure descriptions matching the schema and
* procedure name criteria are returned. They are ordered by
* <code>PROCEDURE_SCHEM and PROCEDURE_NAME
.
*
* <P>Each procedure description has the the following columns:
* <OL>
* <LI>PROCEDURE_CAT String => procedure catalog (may be null
)
* <LI>PROCEDURE_SCHEM String => procedure schema (may be null
)
* <LI>PROCEDURE_NAME String => procedure name
* <LI> reserved for future use
* <LI> reserved for future use
* <LI> reserved for future use
* <LI>REMARKS String => explanatory comment on the procedure
* <LI>PROCEDURE_TYPE short => kind of procedure:
* <UL>
* <LI> procedureResultUnknown - May return a result
* <LI> procedureNoResult - Does not return a result
* <LI> procedureReturnsResult - Returns a result
* </UL>
* </OL>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @param catalog a catalog name; must match the catalog name as it
* is stored in the database; "" retrieves those without a catalog;
* <code>null means that the catalog name should not be used
* to narrow the search
* @param schemaPattern a schema name pattern; must match the schema name
* as it is stored in the database; "" retrieves those without a
* schema; <code>null means that the schema name should not be
* used to narrow the search
* @param procedureNamePattern a procedure name pattern; must match the
* procedure name as it is stored in the database
* @return <code>ResultSet - each row is a procedure description
* @exception SQLException if a database access error occurs
* @see #getSearchStringEscape
*/
public ResultSet getProcedures(String catalog, String schemaPattern,
String procedureNamePattern)
throws SQLException {
if (wantsIsNull(procedureNamePattern)) {
return executeSelect("SYSTEM_PROCEDURES", "0=1");
}
schemaPattern = translateSchema(schemaPattern);
StringBuffer select = toQueryPrefix("SYSTEM_PROCEDURES").append(
and("PROCEDURE_CAT", "=", catalog)).append(
and("PROCEDURE_SCHEM", "LIKE", schemaPattern)).append(
and("PROCEDURE_NAME", "LIKE", procedureNamePattern));
// By default, query already returns the result ordered by
// PROCEDURE_SCHEM, PROCEDURE_NAME...
return execute(select.toString());
}
/**
* Retrieves a description of the given catalog's stored procedure parameter
* and result columns.
*
* <P>Only descriptions matching the schema, procedure and
* parameter name criteria are returned. They are ordered by
* PROCEDURE_SCHEM and PROCEDURE_NAME. Within this, the return value,
* if any, is first. Next are the parameter descriptions in call
* order. The column descriptions follow in column number order.
*
* <P>Each row in the ResultSet
is a parameter description or
* column description with the following fields:
* <OL>
* <LI>PROCEDURE_CAT String => procedure catalog (may be null
)
* <LI>PROCEDURE_SCHEM String => procedure schema (may be null
)
* <LI>PROCEDURE_NAME String => procedure name
* <LI>COLUMN_NAME String => column/parameter name
* <LI>COLUMN_TYPE Short => kind of column/parameter:
* <UL>
* <LI> procedureColumnUnknown - nobody knows
* <LI> procedureColumnIn - IN parameter
* <LI> procedureColumnInOut - INOUT parameter
* <LI> procedureColumnOut - OUT parameter
* <LI> procedureColumnReturn - procedure return value
* <LI> procedureColumnResult - result column in ResultSet
* </UL>
* <LI>DATA_TYPE short => SQL type from java.sql.Types
* <LI>TYPE_NAME String => SQL type name, for a UDT type the
* type name is fully qualified
* <LI>PRECISION int => precision
* <LI>LENGTH int => length in bytes of data
* <LI>SCALE short => scale
* <LI>RADIX short => radix
* <LI>NULLABLE short => can it contain NULL.
* <UL>
* <LI> procedureNoNulls - does not allow NULL values
* <LI> procedureNullable - allows NULL values
* <LI> procedureNullableUnknown - nullability unknown
* </UL>
* <LI>REMARKS String => comment describing parameter/column
* </OL>
*
* <P>Note: Some databases may not return the column
* descriptions for a procedure. Additional columns beyond
* REMARKS can be defined by the database. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @param catalog a catalog name; must match the catalog name as it
* is stored in the database; "" retrieves those without a catalog;
* <code>null means that the catalog name should not be used
* to narrow the search
* @param schemaPattern a schema name pattern; must match the schema name
* as it is stored in the database; "" retrieves those without a
* schema; <code>null means that the schema name should not be
* used to narrow the search
* @param procedureNamePattern a procedure name pattern; must match the
* procedure name as it is stored in the database
* @param columnNamePattern a column name pattern; must match the column
* name as it is stored in the database
* @return <code>ResultSet - each row describes a stored procedure
* parameter or column
* @exception SQLException if a database access error occurs
* @see #getSearchStringEscape
*/
public ResultSet getProcedureColumns(String catalog, String schemaPattern,
String procedureNamePattern,
String columnNamePattern)
throws SQLException {
if (wantsIsNull(procedureNamePattern)
|| wantsIsNull(columnNamePattern)) {
return executeSelect("SYSTEM_PROCEDURECOLUMNS", "0=1");
}
schemaPattern = translateSchema(schemaPattern);
StringBuffer select = toQueryPrefix("SYSTEM_PROCEDURECOLUMNS").append(
and("PROCEDURE_CAT", "=", catalog)).append(
and("PROCEDURE_SCHEM", "LIKE", schemaPattern)).append(
and("PROCEDURE_NAME", "LIKE", procedureNamePattern)).append(
and("COLUMN_NAME", "LIKE", columnNamePattern));
// By default, query already returns result ordered by
// PROCEDURE_SCHEM and PROCEDURE_NAME...
return execute(select.toString());
}
/**
* Retrieves a description of the tables available in the given catalog.
* Only table descriptions matching the catalog, schema, table
* name and type criteria are returned. They are ordered by
* TABLE_TYPE, TABLE_SCHEM and TABLE_NAME.
* <P>
* Each table description has the following columns:
* <OL>
* <LI>TABLE_CAT String => table catalog (may be null
)
* <LI>TABLE_SCHEM String => table schema (may be null
)
* <LI>TABLE_NAME String => table name
* <LI>TABLE_TYPE String => table type. Typical types are "TABLE",
* "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
* "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
* <LI>REMARKS String => explanatory comment on the table
* <LI>TYPE_CAT String => the types catalog (may be null
)
* <LI>TYPE_SCHEM String => the types schema (may be null
)
* <LI>TYPE_NAME String => type name (may be null
)
* <LI>SELF_REFERENCING_COL_NAME String => name of the designated
* "identifier" column of a typed table (may be <code>null)
* <LI>REF_GENERATION String => specifies how values in
* SELF_REFERENCING_COL_NAME are created. Values are
* "SYSTEM", "USER", "DERIVED". (may be <code>null)
* </OL>
*
* <P>Note: Some databases may not return information for
* all tables. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* Since 1.7.0, HSQLDB returns extra information on TEXT tables
* in the REMARKS column. <p>
*
* Since 1.7.0, HSQLDB includes the new JDBC3 columns TYPE_CAT,
* TYPE_SCHEM, TYPE_NAME and SELF_REFERENCING_COL_NAME in anticipation
* of JDBC3 compliant tools. <p>
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @param catalog a catalog name; must match the catalog name as it
* is stored in the database; "" retrieves those without a catalog;
* <code>null means that the catalog name should not be used
* to narrow the search
* @param schemaPattern a schema name pattern; must match the schema name
* as it is stored in the database; "" retrieves those without a
* schema; <code>null means that the schema name should not be
* used to narrow the search
* @param tableNamePattern a table name pattern; must match the
* table name as it is stored in the database
* @param types a list of table types to include; <code>null returns
* all types
* @return <code>ResultSet - each row is a table description
* @exception SQLException if a database access error occurs
* @see #getSearchStringEscape
*/
public ResultSet getTables(String catalog, String schemaPattern,
String tableNamePattern,
String[] types) throws SQLException {
if (wantsIsNull(tableNamePattern)
|| (types != null && types.length == 0)) {
return executeSelect("SYSTEM_TABLES", "0=1");
}
schemaPattern = translateSchema(schemaPattern);
StringBuffer select =
toQueryPrefix("SYSTEM_TABLES").append(and("TABLE_CAT", "=",
catalog)).append(and("TABLE_SCHEM", "LIKE",
schemaPattern)).append(and("TABLE_NAME",
"LIKE", tableNamePattern));
if (types == null) {
// do not use to narrow search
} else {
select.append(" AND TABLE_TYPE IN (").append(
StringUtil.getList(types, ",", "'")).append(')');
}
// By default, query already returns result ordered by
// TABLE_TYPE, TABLE_SCHEM and TABLE_NAME...
return execute(select.toString());
}
/**
* Retrieves the schema names available in this database. The results
* are ordered by schema name.
*
* <P>The schema column is:
* <OL>
* <LI>TABLE_SCHEM String => schema name
* <LI>TABLE_CATALOG String => catalog name (may be null
)
* </OL>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* In 1.8.0, the list of schemas is returned.
* </div>
* <!-- end release-specific documentation -->
*
* @return a <code>ResultSet object in which each row is a
* schema decription
* @exception SQLException if a database access error occurs
*/
public ResultSet getSchemas() throws SQLException {
// By default, query already returns the result in contract order
return executeSelect("SYSTEM_SCHEMAS", null);
}
/**
* Retrieves the catalog names available in this database. The results
* are ordered by catalog name.
*
* <P>The catalog column is:
* <OL>
* <LI>TABLE_CAT String => catalog name
* </OL>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @return a <code>ResultSet object in which each row has a
* single <code>String column that is a catalog name
* @exception SQLException if a database access error occurs
*/
public ResultSet getCatalogs() throws SQLException {
return executeSelect("SYSTEM_CATALOGS", null);
}
/**
* Retrieves the table types available in this database. The results
* are ordered by table type.
*
* <P>The table type is:
* <OL>
* <LI>TABLE_TYPE String => table type. Typical types are "TABLE",
* "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
* "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
* </OL>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Since 1.7.1, HSQLDB reports: "TABLE", "VIEW" and "GLOBAL TEMPORARY"
* types.
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
* @return a <code>ResultSet object in which each row has a
* single <code>String column that is a table type
* @exception SQLException if a database access error occurs
*/
public ResultSet getTableTypes() throws SQLException {
// system table producer returns rows in contract order
return executeSelect("SYSTEM_TABLETYPES", null);
}
/**
* Retrieves a description of table columns available in
* the specified catalog.
*
* <P>Only column descriptions matching the catalog, schema, table
* and column name criteria are returned. They are ordered by
* <code>TABLE_SCHEM, TABLE_NAME
, and
* <code>ORDINAL_POSITION.
*
* <P>Each column description has the following columns:
* <OL>
* <LI>TABLE_CAT String => table catalog (may be null
)
* <LI>TABLE_SCHEM String => table schema (may be null
)
* <LI>TABLE_NAME String => table name
* <LI>COLUMN_NAME String => column name
* <LI>DATA_TYPE short => SQL type from java.sql.Types
* <LI>TYPE_NAME String => Data source dependent type name,
* for a UDT the type name is fully qualified
* <LI>COLUMN_SIZE int => column size. For char or date
* types this is the maximum number of characters, for numeric or
* decimal types this is precision.
* <LI>BUFFER_LENGTH is not used.
* <LI>DECIMAL_DIGITS int => the number of fractional digits
* <LI>NUM_PREC_RADIX int => Radix (typically either 10 or 2)
* <LI>NULLABLE int => is NULL allowed.
* <UL>
* <LI> columnNoNulls - might not allow NULL
values
* <LI> columnNullable - definitely allows NULL
values
* <LI> columnNullableUnknown - nullability unknown
* </UL>
* <LI>REMARKS String => comment describing column (may be null
)
* <LI>COLUMN_DEF String => default value (may be null
)
* <LI>SQL_DATA_TYPE int => unused
* <LI>SQL_DATETIME_SUB int => unused
* <LI>CHAR_OCTET_LENGTH int => for char types the
* maximum number of bytes in the column
* <LI>ORDINAL_POSITION int => index of column in table
* (starting at 1)
* <LI>IS_NULLABLE String => "NO" means column definitely
* does not allow NULL values; "YES" means the column might
* allow NULL values. An empty string means nobody knows.
* <LI>SCOPE_CATLOG String => catalog of table that is the scope
* of a reference attribute (<code>null if DATA_TYPE isn't REF)
* <LI>SCOPE_SCHEMA String => schema of table that is the scope
* of a reference attribute (<code>null if the DATA_TYPE isn't REF)
* <LI>SCOPE_TABLE String => table name that this the scope
* of a reference attribure (<code>null if the DATA_TYPE isn't REF)
* <LI>SOURCE_DATA_TYPE short => source type of a distinct type or user-generated
* Ref type, SQL type from java.sql.Types (<code>null if DATA_TYPE
* isn't DISTINCT or user-generated REF)
* </OL>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* Since 1.7.0, HSQLDB includes the new JDBC 3 columns SCOPE_CATLOG,
* SCOPE_SCHEMA, SCOPE_TABLE and SOURCE_DATA_TYPE in anticipation
* of JDBC 3 compliant tools. However, these columns are never filled in;
* the engine does not support the related features. <p>
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @param catalog a catalog name; must match the catalog name as it
* is stored in the database; "" retrieves those without a catalog;
* <code>null means that the catalog name should not be used
* to narrow the search
* @param schemaPattern a schema name pattern; must match the schema name
* as it is stored in the database; "" retrieves those without a
* schema; <code>null means that the schema name should not be
* used to narrow the search
* @param tableNamePattern a table name pattern; must match the
* table name as it is stored in the database
* @param columnNamePattern a column name pattern; must match the column
* name as it is stored in the database
* @return <code>ResultSet - each row is a column description
* @exception SQLException if a database access error occurs
* @see #getSearchStringEscape
*/
public ResultSet getColumns(String catalog, String schemaPattern,
String tableNamePattern,
String columnNamePattern) throws SQLException {
if (wantsIsNull(tableNamePattern) || wantsIsNull(columnNamePattern)) {
return executeSelect("SYSTEM_COLUMNS", "0=1");
}
schemaPattern = translateSchema(schemaPattern);
StringBuffer select = toQueryPrefix("SYSTEM_COLUMNS").append(
and("TABLE_CAT", "=", catalog)).append(
and("TABLE_SCHEM", "LIKE", schemaPattern)).append(
and("TABLE_NAME", "LIKE", tableNamePattern)).append(
and("COLUMN_NAME", "LIKE", columnNamePattern));
// by default, query already returns the result ordered
// by TABLE_SCHEM, TABLE_NAME and ORDINAL_POSITION
return execute(select.toString());
}
/**
* Retrieves a description of the access rights for a table's columns.
*
* <P>Only privileges matching the column name criteria are
* returned. They are ordered by COLUMN_NAME and PRIVILEGE.
*
* <P>Each privilige description has the following columns:
* <OL>
* <LI>TABLE_CAT String => table catalog (may be null
)
* <LI>TABLE_SCHEM String => table schema (may be null
)
* <LI>TABLE_NAME String => table name
* <LI>COLUMN_NAME String => column name
* <LI>GRANTOR => grantor of access (may be null
)
* <LI>GRANTEE String => grantee of access
* <LI>PRIVILEGE String => name of access (SELECT,
* INSERT, UPDATE, REFRENCES, ...)
* <LI>IS_GRANTABLE String => "YES" if grantee is permitted
* to grant to others; "NO" if not; <code>null if unknown
* </OL>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @param catalog a catalog name; must match the catalog name as it
* is stored in the database; "" retrieves those without a catalog;
* <code>null means that the catalog name should not be used
* to narrow the search
* @param schema a schema name; must match the schema name as it is
* stored in the database; "" retrieves those without a schema;
* <code>null means that the schema name should not be used
* to narrow the search
* @param table a table name; must match the table name as it is
* stored in the database
* @param columnNamePattern a column name pattern; must match the column
* name as it is stored in the database
* @return <code>ResultSet - each row is a column privilege
* description
* @exception SQLException if a database access error occurs
* @see #getSearchStringEscape
*/
public ResultSet getColumnPrivileges(String catalog, String schema,
String table,
String columnNamePattern)
throws SQLException {
if (table == null) {
Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
}
if (wantsIsNull(columnNamePattern)) {
return executeSelect("SYSTEM_COLUMNPRIVILEGES", "0=1");
}
schema = translateSchema(schema);
StringBuffer select =
toQueryPrefix("SYSTEM_COLUMNPRIVILEGES").append(and("TABLE_CAT",
"=", catalog)).append(and("TABLE_SCHEM", "=",
schema)).append(and("TABLE_NAME",
"=",
table)).append(and("COLUMN_NAME",
"LIKE", columnNamePattern));
// By default, the query already returns the result
// ordered by column name, privilege...
return execute(select.toString());
}
/**
* Retrieves a description of the access rights for each table available
* in a catalog. Note that a table privilege applies to one or
* more columns in the table. It would be wrong to assume that
* this privilege applies to all columns (this may be true for
* some systems but is not true for all.)
*
* <P>Only privileges matching the schema and table name
* criteria are returned. They are ordered by TABLE_SCHEM,
* TABLE_NAME, and PRIVILEGE.
*
* <P>Each privilige description has the following columns:
* <OL>
* <LI>TABLE_CAT String => table catalog (may be null
)
* <LI>TABLE_SCHEM String => table schema (may be null
)
* <LI>TABLE_NAME String => table name
* <LI>GRANTOR => grantor of access (may be null
)
* <LI>GRANTEE String => grantee of access
* <LI>PRIVILEGE String => name of access (SELECT,
* INSERT, UPDATE, REFRENCES, ...)
* <LI>IS_GRANTABLE String => "YES" if grantee is permitted
* to grant to others; "NO" if not; <code>null if unknown
* </OL>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @param catalog a catalog name; must match the catalog name as it
* is stored in the database; "" retrieves those without a catalog;
* <code>null means that the catalog name should not be used
* to narrow the search
* @param schemaPattern a schema name pattern; must match the schema name
* as it is stored in the database; "" retrieves those without a
* schema; <code>null means that the schema name should not be
* used to narrow the search
* @param tableNamePattern a table name pattern; must match the
* table name as it is stored in the database
* @return <code>ResultSet - each row is a table privilege
* description
* @exception SQLException if a database access error occurs
* @see #getSearchStringEscape
*/
public ResultSet getTablePrivileges(String catalog, String schemaPattern,
String tableNamePattern)
throws SQLException {
if (wantsIsNull(tableNamePattern)) {
return executeSelect("SYSTEM_TABLEPRIVILEGES", "0=1");
}
schemaPattern = translateSchema(schemaPattern);
StringBuffer select = toQueryPrefix("SYSTEM_TABLEPRIVILEGES").append(
and("TABLE_CAT", "=", catalog)).append(
and("TABLE_SCHEM", "LIKE", schemaPattern)).append(
and("TABLE_NAME", "LIKE", tableNamePattern));
// By default, the query already returns a result ordered by
// TABLE_SCHEM, TABLE_NAME, and PRIVILEGE...
return execute(select.toString());
}
/**
* Retrieves a description of a table's optimal set of columns that
* uniquely identifies a row. They are ordered by SCOPE.
*
* <P>Each column description has the following columns:
* <OL>
* <LI>SCOPE short => actual scope of result
* <UL>
* <LI> bestRowTemporary - very temporary, while using row
* <LI> bestRowTransaction - valid for remainder of current transaction
* <LI> bestRowSession - valid for remainder of current session
* </UL>
* <LI>COLUMN_NAME String => column name
* <LI>DATA_TYPE short => SQL data type from java.sql.Types
* <LI>TYPE_NAME String => Data source dependent type name,
* for a UDT the type name is fully qualified
* <LI>COLUMN_SIZE int => precision
* <LI>BUFFER_LENGTH int => not used
* <LI>DECIMAL_DIGITS short => scale
* <LI>PSEUDO_COLUMN short => is this a pseudo column
* like an Oracle ROWID
* <UL>
* <LI> bestRowUnknown - may or may not be pseudo column
* <LI> bestRowNotPseudo - is NOT a pseudo column
* <LI> bestRowPseudo - is a pseudo column
* </UL>
* </OL>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* If the name of a column is defined in the database without double
* quotes, an all-uppercase name must be specified when calling this
* method. Otherwise, the name must be specified in the exact case of
* the column definition in the database. <p>
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @param catalog a catalog name; must match the catalog name as it
* is stored in the database; "" retrieves those without a catalog;
* <code>null means that the catalog name should not be used
* to narrow the search
* @param schema a schema name; must match the schema name
* as it is stored in the database; "" retrieves those without a
* schema; <code>null means that the schema name should not
* be used to narrow the search
* @param table a table name; must match the table name as it is stored
* in the database
* @param scope the scope of interest; use same values as SCOPE
* @param nullable include columns that are nullable.
* @return <code>ResultSet - each row is a column description
* @exception SQLException if a database access error occurs
*/
public ResultSet getBestRowIdentifier(String catalog, String schema,
String table, int scope,
boolean nullable)
throws SQLException {
String scopeIn;
switch (scope) {
case bestRowTemporary :
scopeIn = BRI_TEMPORARY_SCOPE_IN_LIST;
break;
case bestRowTransaction :
scopeIn = BRI_TRANSACTION_SCOPE_IN_LIST;
break;
case bestRowSession :
scopeIn = BRI_SESSION_SCOPE_IN_LIST;
break;
default :
throw Util.sqlException(Trace.ASSERT_FAILED,
Trace.JDBC_INVALID_BRI_SCOPE, null);
}
if (table == null) {
Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
}
schema = translateSchema(schema);
Integer Nullable = (nullable) ? null
: INT_COLUMNS_NO_NULLS;
StringBuffer select = toQueryPrefix("SYSTEM_BESTROWIDENTIFIER").append(
and("TABLE_CAT", "=", catalog)).append(
and("TABLE_SCHEM", "=", schema)).append(
and("TABLE_NAME", "=", table)).append(
and("NULLABLE", "=", Nullable)).append(" AND SCOPE IN " + scopeIn);
// By default, query already returns rows in contract order.
// However, the way things are set up, there should never be
// a result where there is > 1 distinct scope value: most requests
// will want only one table and the system table producer (for
// now) guarantees that a maximum of one BRI scope column set is
// produced for each table
return execute(select.toString());
}
/**
* Retrieves a description of a table's columns that are automatically
* updated when any value in a row is updated. They are
* unordered.
*
* <P>Each column description has the following columns:
* <OL>
* <LI>SCOPE short => is not used
* <LI>COLUMN_NAME String => column name
* <LI>DATA_TYPE short => SQL data type from java.sql.Types
* <LI>TYPE_NAME String => Data source-dependent type name
* <LI>COLUMN_SIZE int => precision
* <LI>BUFFER_LENGTH int => length of column value in bytes
* <LI>DECIMAL_DIGITS short => scale
* <LI>PSEUDO_COLUMN short => whether this is pseudo column
* like an Oracle ROWID
* <UL>
* <LI> versionColumnUnknown - may or may not be pseudo column
* <LI> versionColumnNotPseudo - is NOT a pseudo column
* <LI> versionColumnPseudo - is a pseudo column
* </UL>
* </OL>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @param catalog a catalog name; must match the catalog name as it
* is stored in the database; "" retrieves those without a catalog;
* <code>null means that the catalog name should not be used
* to narrow the search
* @param schema a schema name; must match the schema name
* as it is stored in the database; "" retrieves those without a
* schema; <code>null means that the schema name should not be
* used to narrow the search
* @param table a table name; must match the table name as it is stored
* in the database
* @return a <code>ResultSet object in which each row is a
* column description
* @exception SQLException if a database access error occurs
*/
public ResultSet getVersionColumns(String catalog, String schema,
String table) throws SQLException {
if (table == null) {
Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
}
schema = translateSchema(schema);
StringBuffer select =
toQueryPrefix("SYSTEM_VERSIONCOLUMNS").append(and("TABLE_CAT",
"=", catalog)).append(and("TABLE_SCHEM", "=",
schema)).append(and("TABLE_NAME",
"=", table));
// result does not need to be ordered
return execute(select.toString());
}
/**
* Retrieves a description of the given table's primary key columns. They
* are ordered by COLUMN_NAME.
*
* <P>Each primary key column description has the following columns:
* <OL>
* <LI>TABLE_CAT String => table catalog (may be null
)
* <LI>TABLE_SCHEM String => table schema (may be null
)
* <LI>TABLE_NAME String => table name
* <LI>COLUMN_NAME String => column name
* <LI>KEY_SEQ short => sequence number within primary key
* <LI>PK_NAME String => primary key name (may be null
)
* </OL>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @param catalog a catalog name; must match the catalog name as it
* is stored in the database; "" retrieves those without a catalog;
* <code>null means that the catalog name should not be used
* to narrow the search
* @param schema a schema name; must match the schema name
* as it is stored in the database; "" retrieves those without a
* schema; <code>null means that the schema name should not
* be used to narrow the search
* @param table a table name; must match the table name as it is stored
* in the database
* @return <code>ResultSet - each row is a primary key column
* description
* @exception SQLException if a database access error occurs
* @see #supportsMixedCaseQuotedIdentifiers
* @see #storesUpperCaseIdentifiers
*/
// fredt@users 20020226 - comment - changed query to exact name
public ResultSet getPrimaryKeys(String catalog, String schema,
String table) throws SQLException {
if (table == null) {
Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
}
schema = translateSchema(schema);
StringBuffer select =
toQueryPrefix("SYSTEM_PRIMARYKEYS").append(and("TABLE_CAT", "=",
catalog)).append(and("TABLE_SCHEM", "=",
schema)).append(and("TABLE_NAME", "=",
table));
// By default, query already returns result in contract order
return execute(select.toString());
}
/**
* Retrieves a description of the primary key columns that are
* referenced by a table's foreign key columns (the primary keys
* imported by a table). They are ordered by PKTABLE_CAT,
* PKTABLE_SCHEM, PKTABLE_NAME, and KEY_SEQ.
*
* <P>Each primary key column description has the following columns:
* <OL>
* <LI>PKTABLE_CAT String => primary key table catalog
* being imported (may be <code>null)
* <LI>PKTABLE_SCHEM String => primary key table schema
* being imported (may be <code>null)
* <LI>PKTABLE_NAME String => primary key table name
* being imported
* <LI>PKCOLUMN_NAME String => primary key column name
* being imported
* <LI>FKTABLE_CAT String => foreign key table catalog (may be null
)
* <LI>FKTABLE_SCHEM String => foreign key table schema (may be null
)
* <LI>FKTABLE_NAME String => foreign key table name
* <LI>FKCOLUMN_NAME String => foreign key column name
* <LI>KEY_SEQ short => sequence number within a foreign key
* <LI>UPDATE_RULE short => What happens to a
* foreign key when the primary key is updated:
* <UL>
* <LI> importedNoAction - do not allow update of primary
* key if it has been imported
* <LI> importedKeyCascade - change imported key to agree
* with primary key update
* <LI> importedKeySetNull - change imported key to NULL
* if its primary key has been updated
* <LI> importedKeySetDefault - change imported key to default values
* if its primary key has been updated
* <LI> importedKeyRestrict - same as importedKeyNoAction
* (for ODBC 2.x compatibility)
* </UL>
* <LI>DELETE_RULE short => What happens to
* the foreign key when primary is deleted.
* <UL>
* <LI> importedKeyNoAction - do not allow delete of primary
* key if it has been imported
* <LI> importedKeyCascade - delete rows that import a deleted key
* <LI> importedKeySetNull - change imported key to NULL if
* its primary key has been deleted
* <LI> importedKeyRestrict - same as importedKeyNoAction
* (for ODBC 2.x compatibility)
* <LI> importedKeySetDefault - change imported key to default if
* its primary key has been deleted
* </UL>
* <LI>FK_NAME String => foreign key name (may be null
)
* <LI>PK_NAME String => primary key name (may be null
)
* <LI>DEFERRABILITY short => can the evaluation of foreign key
* constraints be deferred until commit
* <UL>
* <LI> importedKeyInitiallyDeferred - see SQL92 for definition
* <LI> importedKeyInitiallyImmediate - see SQL92 for definition
* <LI> importedKeyNotDeferrable - see SQL92 for definition
* </UL>
* </OL>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @param catalog a catalog name; must match the catalog name as it
* is stored in the database; "" retrieves those without a catalog;
* <code>null means that the catalog name should not be used
* to narrow the search
* @param schema a schema name; must match the schema name
* as it is stored in the database; "" retrieves those without a
* schema; <code>null means that the schema name should not be
* used to narrow the search
* @param table a table name; must match the table name as it is stored
* in the database
* @return <code>ResultSet - each row is a primary key column
* description
* @exception SQLException if a database access error occurs
* @see #getExportedKeys
* @see #supportsMixedCaseQuotedIdentifiers
* @see #storesUpperCaseIdentifiers
*/
public ResultSet getImportedKeys(String catalog, String schema,
String table) throws SQLException {
if (table == null) {
Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
}
schema = translateSchema(schema);
StringBuffer select = toQueryPrefix("SYSTEM_CROSSREFERENCE").append(
and("FKTABLE_CAT", "=", catalog)).append(
and("FKTABLE_SCHEM", "=", schema)).append(
and("FKTABLE_NAME", "=", table)).append(
" ORDER BY PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME, KEY_SEQ");
return execute(select.toString());
}
/**
* Retrieves a description of the foreign key columns that reference the
* given table's primary key columns (the foreign keys exported by a
* table). They are ordered by FKTABLE_CAT, FKTABLE_SCHEM,
* FKTABLE_NAME, and KEY_SEQ.
*
* <P>Each foreign key column description has the following columns:
* <OL>
* <LI>PKTABLE_CAT String => primary key table catalog (may be null
)
* <LI>PKTABLE_SCHEM String => primary key table schema (may be null
)
* <LI>PKTABLE_NAME String => primary key table name
* <LI>PKCOLUMN_NAME String => primary key column name
* <LI>FKTABLE_CAT String => foreign key table catalog (may be null
)
* being exported (may be <code>null)
* <LI>FKTABLE_SCHEM String => foreign key table schema (may be null
)
* being exported (may be <code>null)
* <LI>FKTABLE_NAME String => foreign key table name
* being exported
* <LI>FKCOLUMN_NAME String => foreign key column name
* being exported
* <LI>KEY_SEQ short => sequence number within foreign key
* <LI>UPDATE_RULE short => What happens to
* foreign key when primary is updated:
* <UL>
* <LI> importedNoAction - do not allow update of primary
* key if it has been imported
* <LI> importedKeyCascade - change imported key to agree
* with primary key update
* <LI> importedKeySetNull - change imported key to NULL
if
* its primary key has been updated
* <LI> importedKeySetDefault - change imported key to default values
* if its primary key has been updated
* <LI> importedKeyRestrict - same as importedKeyNoAction
* (for ODBC 2.x compatibility)
* </UL>
* <LI>DELETE_RULE short => What happens to
* the foreign key when primary is deleted.
* <UL>
* <LI> importedKeyNoAction - do not allow delete of primary
* key if it has been imported
* <LI> importedKeyCascade - delete rows that import a deleted key
* <LI> importedKeySetNull - change imported key to NULL
if
* its primary key has been deleted
* <LI> importedKeyRestrict - same as importedKeyNoAction
* (for ODBC 2.x compatibility)
* <LI> importedKeySetDefault - change imported key to default if
* its primary key has been deleted
* </UL>
* <LI>FK_NAME String => foreign key name (may be null
)
* <LI>PK_NAME String => primary key name (may be null
)
* <LI>DEFERRABILITY short => can the evaluation of foreign key
* constraints be deferred until commit
* <UL>
* <LI> importedKeyInitiallyDeferred - see SQL92 for definition
* <LI> importedKeyInitiallyImmediate - see SQL92 for definition
* <LI> importedKeyNotDeferrable - see SQL92 for definition
* </UL>
* </OL>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @param catalog a catalog name; must match the catalog name as it
* is stored in this database; "" retrieves those without a catalog;
* <code>null means that the catalog name should not be used
* to narrow the search
* @param schema a schema name; must match the schema name
* as it is stored in the database; "" retrieves those without a
* schema; <code>null means that the schema name should not be
* used to narrow the search
* @param table a table name; must match the table name as it is stored
* in this database
* @return a <code>ResultSet object in which each row is a
* foreign key column description
* @exception SQLException if a database access error occurs
* @see #getImportedKeys
* @see #supportsMixedCaseQuotedIdentifiers
* @see #storesUpperCaseIdentifiers
*/
public ResultSet getExportedKeys(String catalog, String schema,
String table) throws SQLException {
if (table == null) {
Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
}
schema = translateSchema(schema);
StringBuffer select =
toQueryPrefix("SYSTEM_CROSSREFERENCE").append(and("PKTABLE_CAT",
"=", catalog)).append(and("PKTABLE_SCHEM", "=",
schema)).append(and("PKTABLE_NAME",
"=", table));
// By default, query already returns the table ordered by
// FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and KEY_SEQ.
return execute(select.toString());
}
/**
* Retrieves a description of the foreign key columns in the given foreign key
* table that reference the primary key columns of the given primary key
* table (describe how one table imports another's key). This
* should normally return a single foreign key/primary key pair because
* most tables import a foreign key from a table only once. They
* are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and
* KEY_SEQ.
*
* <P>Each foreign key column description has the following columns:
* <OL>
* <LI>PKTABLE_CAT String => primary key table catalog (may be null
)
* <LI>PKTABLE_SCHEM String => primary key table schema (may be null
)
* <LI>PKTABLE_NAME String => primary key table name
* <LI>PKCOLUMN_NAME String => primary key column name
* <LI>FKTABLE_CAT String => foreign key table catalog (may be null
)
* being exported (may be <code>null)
* <LI>FKTABLE_SCHEM String => foreign key table schema (may be null
)
* being exported (may be <code>null)
* <LI>FKTABLE_NAME String => foreign key table name
* being exported
* <LI>FKCOLUMN_NAME String => foreign key column name
* being exported
* <LI>KEY_SEQ short => sequence number within foreign key
* <LI>UPDATE_RULE short => What happens to
* foreign key when primary is updated:
* <UL>
* <LI> importedNoAction - do not allow update of primary
* key if it has been imported
* <LI> importedKeyCascade - change imported key to agree
* with primary key update
* <LI> importedKeySetNull - change imported key to NULL
if
* its primary key has been updated
* <LI> importedKeySetDefault - change imported key to default values
* if its primary key has been updated
* <LI> importedKeyRestrict - same as importedKeyNoAction
* (for ODBC 2.x compatibility)
* </UL>
* <LI>DELETE_RULE short => What happens to
* the foreign key when primary is deleted.
* <UL>
* <LI> importedKeyNoAction - do not allow delete of primary
* key if it has been imported
* <LI> importedKeyCascade - delete rows that import a deleted key
* <LI> importedKeySetNull - change imported key to NULL
if
* its primary key has been deleted
* <LI> importedKeyRestrict - same as importedKeyNoAction
* (for ODBC 2.x compatibility)
* <LI> importedKeySetDefault - change imported key to default if
* its primary key has been deleted
* </UL>
* <LI>FK_NAME String => foreign key name (may be null
)
* <LI>PK_NAME String => primary key name (may be null
)
* <LI>DEFERRABILITY short => can the evaluation of foreign key
* constraints be deferred until commit
* <UL>
* <LI> importedKeyInitiallyDeferred - see SQL92 for definition
* <LI> importedKeyInitiallyImmediate - see SQL92 for definition
* <LI> importedKeyNotDeferrable - see SQL92 for definition
* </UL>
* </OL>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @param primaryCatalog a catalog name; must match the catalog name
* as it is stored in the database; "" retrieves those without a
* catalog; <code>null means drop catalog name from the
* selection criteria
* @param primarySchema a schema name; must match the schema name as
* it is stored in the database; "" retrieves those without a schema;
* <code>null means drop schema name from the selection criteria
* @param primaryTable the name of the table that exports the key; must
* match the table name as it is stored in the database
* @param foreignCatalog a catalog name; must match the catalog name as
* it is stored in the database; "" retrieves those without a
* catalog; <code>null means drop catalog name from the
* selection criteria
* @param foreignSchema a schema name; must match the schema name as it
* is stored in the database; "" retrieves those without a schema;
* <code>null means drop schema name from the selection criteria
* @param foreignTable the name of the table that imports the key; must
* match the table name as it is stored in the database
* @return <code>ResultSet - each row is a foreign key column
* description
* @exception SQLException if a database access error occurs
* @see #getImportedKeys
* @see #supportsMixedCaseQuotedIdentifiers
* @see #storesUpperCaseIdentifiers
*/
public ResultSet getCrossReference(String primaryCatalog,
String primarySchema,
String primaryTable,
String foreignCatalog,
String foreignSchema,
String foreignTable)
throws SQLException {
if (primaryTable == null || foreignTable == null) {
Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
}
primarySchema = translateSchema(primarySchema);
foreignSchema = translateSchema(foreignSchema);
StringBuffer select = toQueryPrefix("SYSTEM_CROSSREFERENCE").append(
and("PKTABLE_CAT", "=", primaryCatalog)).append(
and("PKTABLE_SCHEM", "=", primarySchema)).append(
and("PKTABLE_NAME", "=", primaryTable)).append(
and("FKTABLE_CAT", "=", foreignCatalog)).append(
and("FKTABLE_SCHEM", "=", foreignSchema)).append(
and("FKTABLE_NAME", "=", foreignTable));
// by default, query already returns the table ordered by
// FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and KEY_SEQ.
return execute(select.toString());
}
/**
* Retrieves a description of all the standard SQL types supported by
* this database. They are ordered by DATA_TYPE and then by how
* closely the data type maps to the corresponding JDBC SQL type.
*
* <P>Each type description has the following columns:
* <OL>
* <LI>TYPE_NAME String => Type name
* <LI>DATA_TYPE short => SQL data type from java.sql.Types
* <LI>PRECISION int => maximum precision
* <LI>LITERAL_PREFIX String => prefix used to quote a literal
* (may be <code>null)
* <LI>LITERAL_SUFFIX String => suffix used to quote a literal
* (may be <code>null)
* <LI>CREATE_PARAMS String => parameters used in creating
* the type (may be <code>null)
* <LI>NULLABLE short => can you use NULL for this type.
* <UL>
* <LI> typeNoNulls - does not allow NULL values
* <LI> typeNullable - allows NULL values
* <LI> typeNullableUnknown - nullability unknown
* </UL>
* <LI>CASE_SENSITIVE boolean=> is it case sensitive.
* <LI>SEARCHABLE short => can you use "WHERE" based on this type:
* <UL>
* <LI> typePredNone - No support
* <LI> typePredChar - Only supported with WHERE .. LIKE
* <LI> typePredBasic - Supported except for WHERE .. LIKE
* <LI> typeSearchable - Supported for all WHERE ..
* </UL>
* <LI>UNSIGNED_ATTRIBUTE boolean => is it unsigned.
* <LI>FIXED_PREC_SCALE boolean => can it be a money value.
* <LI>AUTO_INCREMENT boolean => can it be used for an
* auto-increment value.
* <LI>LOCAL_TYPE_NAME String => localized version of type name
* (may be <code>null)
* <LI>MINIMUM_SCALE short => minimum scale supported
* <LI>MAXIMUM_SCALE short => maximum scale supported
* <LI>SQL_DATA_TYPE int => unused
* <LI>SQL_DATETIME_SUB int => unused
* <LI>NUM_PREC_RADIX int => usually 2 or 10
* </OL>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @return a <code>ResultSet object in which each row is an SQL
* type description
* @exception SQLException if a database access error occurs
*/
public ResultSet getTypeInfo() throws SQLException {
// system table producer returns rows in contract order
return executeSelect("SYSTEM_TYPEINFO", null);
}
/**
* Retrieves a description of the given table's indices and statistics. They are
* ordered by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION.
*
* <P>Each index column description has the following columns:
* <OL>
* <LI>TABLE_CAT String => table catalog (may be null
)
* <LI>TABLE_SCHEM String => table schema (may be null
)
* <LI>TABLE_NAME String => table name
* <LI>NON_UNIQUE boolean => Can index values be non-unique.
* false when TYPE is tableIndexStatistic
* <LI>INDEX_QUALIFIER String => index catalog (may be null
);
* <code>null when TYPE is tableIndexStatistic
* <LI>INDEX_NAME String => index name; null
when TYPE is
* tableIndexStatistic
* <LI>TYPE short => index type:
* <UL>
* <LI> tableIndexStatistic - this identifies table statistics that are
* returned in conjuction with a table's index descriptions
* <LI> tableIndexClustered - this is a clustered index
* <LI> tableIndexHashed - this is a hashed index
* <LI> tableIndexOther - this is some other style of index
* </UL>
* <LI>ORDINAL_POSITION short => column sequence number
* within index; zero when TYPE is tableIndexStatistic
* <LI>COLUMN_NAME String => column name; null
when TYPE is
* tableIndexStatistic
* <LI>ASC_OR_DESC String => column sort sequence, "A" => ascending,
* "D" => descending, may be <code>null if sort sequence is not supported;
* <code>null when TYPE is tableIndexStatistic
* <LI>CARDINALITY int => When TYPE is tableIndexStatistic, then
* this is the number of rows in the table; otherwise, it is the
* number of unique values in the index.
* <LI>PAGES int => When TYPE is tableIndexStatisic then
* this is the number of pages used for the table, otherwise it
* is the number of pages used for the current index.
* <LI>FILTER_CONDITION String => Filter condition, if any.
* (may be <code>null)
* </OL>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @param catalog a catalog name; must match the catalog name as it
* is stored in this database; "" retrieves those without a catalog;
* <code>null means that the catalog name should not be used
* to narrow the search
* @param schema a schema name; must match the schema name
* as it is stored in this database; "" retrieves those without a
* schema; <code>null means that the schema name should not be
* used to narrow the search
* @param table a table name; must match the table name as it is stored
* in this database
* @param unique when true, return only indices for unique values;
* when false, return indices regardless of whether unique or not
* @param approximate when true, result is allowed to reflect approximate
* or out of date values; when false, results are requested to be
* accurate
* @return <code>ResultSet - each row is an index column description
* @exception SQLException if a database access error occurs
* @see #supportsMixedCaseQuotedIdentifiers
* @see #storesUpperCaseIdentifiers
*/
// fredt@users 20020526 - comment - changed to exact table name
public ResultSet getIndexInfo(String catalog, String schema, String table,
boolean unique,
boolean approximate) throws SQLException {
if (table == null) {
Util.sqlException(Trace.INVALID_JDBC_ARGUMENT);
}
schema = translateSchema(schema);
Boolean nu = (unique) ? Boolean.FALSE
: null;
StringBuffer select =
toQueryPrefix("SYSTEM_INDEXINFO").append(and("TABLE_CAT", "=",
catalog)).append(and("TABLE_SCHEM", "=",
schema)).append(and("TABLE_NAME", "=",
table)).append(and("NON_UNIQUE", "=",
nu));
// By default, this query already returns the table ordered by
// NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION...
return execute(select.toString());
}
//--------------------------JDBC 2.0-----------------------------
/**
* Retrieves whether this database supports the given result set type. <p>
*
* @param type defined in <code>java.sql.ResultSet
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
* @see jdbcConnection
* @since JDK 1.2 (JDK 1.1.x developers: read the new overview
* for jdbcDatabaseMetaData)
*/
public boolean supportsResultSetType(int type) throws SQLException {
return (type == jdbcResultSet.TYPE_FORWARD_ONLY
|| type == jdbcResultSet.TYPE_SCROLL_INSENSITIVE);
}
/**
* Retrieves whether this database supports the given concurrency type
* in combination with the given result set type. <p>
*
* @param type defined in <code>java.sql.ResultSet
* @param concurrency type defined in <code>java.sql.ResultSet
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
* @see jdbcConnection
* @since JDK 1.2 (JDK 1.1.x developers: read the new overview
* for jdbcDatabaseMetaData)
*/
public boolean supportsResultSetConcurrency(int type,
int concurrency) throws SQLException {
return supportsResultSetType(type)
&& concurrency == jdbcResultSet.CONCUR_READ_ONLY;
}
/**
* Retrieves whether for the given type of <code>ResultSet object,
* the result set's own updates are visible. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support updateable
* result sets; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @param type the <code>ResultSet type; one of
* <code>ResultSet.TYPE_FORWARD_ONLY,
* <code>ResultSet.TYPE_SCROLL_INSENSITIVE, or
* <code>ResultSet.TYPE_SCROLL_SENSITIVE
* @return <code>true if updates are visible for the given result set type;
* <code>false otherwise
* @exception SQLException if a database access error occurs
* @since JDK 1.2 (JDK 1.1.x developers: read the new overview
* for jdbcDatabaseMetaData)
*/
public boolean ownUpdatesAreVisible(int type) throws SQLException {
return false;
}
/**
* Retrieves whether a result set's own deletes are visible. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support updateable
* result sets; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @param type the <code>ResultSet type; one of
* <code>ResultSet.TYPE_FORWARD_ONLY,
* <code>ResultSet.TYPE_SCROLL_INSENSITIVE, or
* <code>ResultSet.TYPE_SCROLL_SENSITIVE
* @return <code>true if deletes are visible for the given result set type;
* <code>false otherwise
* @exception SQLException if a database access error occurs
* @since JDK 1.2 (JDK 1.1.x developers: read the new overview
* for jdbcDatabaseMetaData)
*/
public boolean ownDeletesAreVisible(int type) throws SQLException {
return false;
}
/**
* Retrieves whether a result set's own inserts are visible. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support updateable
* result sets; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @param type the <code>ResultSet type; one of
* <code>ResultSet.TYPE_FORWARD_ONLY,
* <code>ResultSet.TYPE_SCROLL_INSENSITIVE, or
* <code>ResultSet.TYPE_SCROLL_SENSITIVE
* @return <code>true if inserts are visible for the given result set type;
* <code>false otherwise
* @exception SQLException if a database access error occurs
* @since JDK 1.2 (JDK 1.1.x developers: read the new overview
* for jdbcDatabaseMetaData)
*/
public boolean ownInsertsAreVisible(int type) throws SQLException {
return false;
}
/**
* Retrieves whether updates made by others are visible. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support updateable
* result sets; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @param type the <code>ResultSet type; one of
* <code>ResultSet.TYPE_FORWARD_ONLY,
* <code>ResultSet.TYPE_SCROLL_INSENSITIVE, or
* <code>ResultSet.TYPE_SCROLL_SENSITIVE
* @return <code>true if updates made by others
* are visible for the given result set type;
* <code>false otherwise
* @exception SQLException if a database access error occurs
* @since JDK 1.2 (JDK 1.1.x developers: read the new overview
* for jdbcDatabaseMetaData)
*/
public boolean othersUpdatesAreVisible(int type) throws SQLException {
return false;
}
/**
* Retrieves whether deletes made by others are visible. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support updateable
* result sets; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @param type the <code>ResultSet type; one of
* <code>ResultSet.TYPE_FORWARD_ONLY,
* <code>ResultSet.TYPE_SCROLL_INSENSITIVE, or
* <code>ResultSet.TYPE_SCROLL_SENSITIVE
* @return <code>true if deletes made by others
* are visible for the given result set type;
* <code>false otherwise
* @exception SQLException if a database access error occurs
* @since JDK 1.2 (JDK 1.1.x developers: read the new overview
* for jdbcDatabaseMetaData)
*/
public boolean othersDeletesAreVisible(int type) throws SQLException {
return false;
}
/**
* Retrieves whether inserts made by others are visible. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support updateable
* result sets; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @param type the <code>ResultSet type; one of
* <code>ResultSet.TYPE_FORWARD_ONLY,
* <code>ResultSet.TYPE_SCROLL_INSENSITIVE, or
* <code>ResultSet.TYPE_SCROLL_SENSITIVE
* @return <code>true if inserts made by others
* are visible for the given result set type;
* <code>false otherwise
* @exception SQLException if a database access error occurs
* @since JDK 1.2 (JDK 1.1.x developers: read the new overview
* for jdbcDatabaseMetaData)
*/
public boolean othersInsertsAreVisible(int type) throws SQLException {
return false;
}
/**
* Retrieves whether or not a visible row update can be detected by
* calling the method <code>ResultSet.rowUpdated.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support updateable
* result sets; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @param type the <code>ResultSet type; one of
* <code>ResultSet.TYPE_FORWARD_ONLY,
* <code>ResultSet.TYPE_SCROLL_INSENSITIVE, or
* <code>ResultSet.TYPE_SCROLL_SENSITIVE
* @return <code>true if changes are detected by the result set type;
* <code>false otherwise
* @exception SQLException if a database access error occurs
* @since JDK 1.2 (JDK 1.1.x developers: read the new overview
* for jdbcDatabaseMetaData)
*/
public boolean updatesAreDetected(int type) throws SQLException {
return false;
}
/**
* Retrieves whether or not a visible row delete can be detected by
* calling the method <code>ResultSet.rowDeleted. If the method
* <code>deletesAreDetected returns false
, it means that
* deleted rows are removed from the result set. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Including 1.7.2, HSQLDB does not support updateable
* result sets; this method <em>always returns false
.
* </div>
* <!-- end release-specific documentation -->
*
*
* @param type the <code>ResultSet type; one of
* <code>ResultSet.TYPE_FORWARD_ONLY,
* <code>ResultSet.TYPE_SCROLL_INSENSITIVE, or
* <code>ResultSet.TYPE_SCROLL_SENSITIVE
* @return <code>true if deletes are detected by the given result set type;
* <code>false otherwise
* @exception SQLException if a database access error occurs
* @since JDK 1.2 (JDK 1.1.x developers: read the new overview
* for jdbcDatabaseMetaData)
*/
public boolean deletesAreDetected(int type) throws SQLException {
return false;
}
/**
* Retrieves whether or not a visible row insert can be detected
* by calling the method <code>ResultSet.rowInserted.
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support updateable
* result sets; this method always returns <code>false.
* </div>
* <!-- end release-specific documentation -->
* @param type the <code>ResultSet type; one of
* <code>ResultSet.TYPE_FORWARD_ONLY,
* <code>ResultSet.TYPE_SCROLL_INSENSITIVE, or
* <code>ResultSet.TYPE_SCROLL_SENSITIVE
* @return <code>true if changes are detected by the specified result
* set type; <code>false otherwise
* @exception SQLException if a database access error occurs
* @since JDK 1.2 (JDK 1.1.x developers: read the new overview
* for jdbcDatabaseMetaData)
*/
public boolean insertsAreDetected(int type) throws SQLException {
return false;
}
/**
* Retrieves whether this database supports batch updates. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Starting with 1.7.2, HSQLDB supports batch updates;
* this method always returns <code>true.
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if this database supports batch upcates;
* <code>false otherwise
* @exception SQLException if a database access error occurs
* @since JDK 1.2 (JDK 1.1.x developers: read the new overview
* for jdbcDatabaseMetaData)
*/
public boolean supportsBatchUpdates() throws SQLException {
return true;
}
/**
* Retrieves a description of the user-defined types (UDTs) defined
* in a particular schema. Schema-specific UDTs may have type
* <code>JAVA_OBJECT, STRUCT
,
* or <code>DISTINCT.
*
* <P>Only types matching the catalog, schema, type name and type
* criteria are returned. They are ordered by DATA_TYPE, TYPE_SCHEM
* and TYPE_NAME. The type name parameter may be a fully-qualified
* name. In this case, the catalog and schemaPattern parameters are
* ignored.
*
* <P>Each type description has the following columns:
* <OL>
* <LI>TYPE_CAT String => the type's catalog (may be null
)
* <LI>TYPE_SCHEM String => type's schema (may be null
)
* <LI>TYPE_NAME String => type name
* <LI>CLASS_NAME String => Java class name
* <LI>DATA_TYPE String => type value defined in java.sql.Types.
* One of JAVA_OBJECT, STRUCT, or DISTINCT
* <LI>REMARKS String => explanatory comment on the type
* <LI>BASE_TYPE short => type code of the source type of a
* DISTINCT type or the type that implements the user-generated
* reference type of the SELF_REFERENCING_COLUMN of a structured
* type as defined in java.sql.Types (<code>null if DATA_TYPE is not
* DISTINCT or not STRUCT with REFERENCE_GENERATION = USER_DEFINED)
* </OL>
*
* <P>Note: If the driver does not support UDTs, an empty
* result set is returned. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* Up to and including 1.7.1, HSQLDB does not support UDTs and
* thus produces an empty result. <p>
*
* Starting with 1.7.2, there is an option to support this feature
* to greater or lesser degrees. See the documentation specific to the
* selected system table provider implementation. The default implementation
* is org.hsqldb.DatabaseInformationFull.
* </div>
* <!-- end release-specific documentation -->
* @param catalog a catalog name; must match the catalog name as it
* is stored in the database; "" retrieves those without a catalog;
* <code>null means that the catalog name should not be used
* to narrow the search
* @param schemaPattern a schema pattern name; must match the schema name
* as it is stored in the database; "" retrieves those without a
* schema; <code>null means that the schema name should not be
* used to narrow the search
* @param typeNamePattern a type name pattern; must match the type name
* as it is stored in the database; may be a fully qualified name
* @param types a list of user-defined types (JAVA_OBJECT,
* STRUCT, or DISTINCT) to include; <code>null returns
* all types
* @return <code>ResultSet object in which each row describes a UDT
* @exception SQLException if a database access error occurs
* @since JDK 1.2 (JDK 1.1.x developers: read the new overview
* for jdbcDatabaseMetaData)
*/
public ResultSet getUDTs(String catalog, String schemaPattern,
String typeNamePattern,
int[] types) throws SQLException {
if (wantsIsNull(typeNamePattern)
|| (types != null && types.length == 0)) {
executeSelect("SYSTEM_UDTS", "0=1");
}
schemaPattern = translateSchema(schemaPattern);
StringBuffer select =
toQueryPrefix("SYSTEM_UDTS").append(and("TYPE_CAT", "=",
catalog)).append(and("TYPE_SCHEM", "LIKE",
schemaPattern)).append(and("TYPE_NAME",
"LIKE", typeNamePattern));
if (types == null) {
// do not use to narrow search
} else {
select.append(" AND DATA_TYPE IN (").append(
StringUtil.getList(types, ",", "'")).append(')');
}
// By default, the query already returns a result ordered by
// DATA_TYPE, TYPE_SCHEM, and TYPE_NAME...
return execute(select.toString());
}
/**
* Retrieves the connection that produced this metadata object. <p>
*
* @return the connection that produced this metadata object
* @exception SQLException if a database access error occurs
* @since JDK 1.2 (JDK 1.1.x developers: read the new overview
* for jdbcDatabaseMetaData)
*/
public Connection getConnection() throws SQLException {
return connection;
}
// boucherb@users 20020426 - javadocs for all JDBC 3 methods
// boucherb@users 20020426 - todos
// ------------------- JDBC 3.0 -------------------------
/**
* Retrieves whether this database supports savepoints. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Beginning with 1.7.2, this SQL feature is supported
* through JDBC as well as SQL. <p>
*
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if savepoints are supported;
* <code>false otherwise
* @exception SQLException if a database access error occurs
* @since JDK 1.4, HSQLDB 1.7
*/
//#ifdef JAVA4
public boolean supportsSavepoints() throws SQLException {
return true;
}
//#endif JAVA4
/**
* Retrieves whether this database supports named parameters to callable
* statements. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Starting with 1.7.2, HSQLDB supports JDBC named parameters to
* callable statements; this method returns true. <p>
*
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if named parameters are supported;
* <code>false otherwise
* @exception SQLException if a database access error occurs
* @since JDK 1.4, HSQLDB 1.7
*/
//#ifdef JAVA4
public boolean supportsNamedParameters() throws SQLException {
return true;
}
//#endif JAVA4
/**
* Retrieves whether it is possible to have multiple <code>ResultSet
* objects returned from a <code>CallableStatement object
* simultaneously. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support multiple ResultSet
* objects returned from a <code>CallableStatement object at all;
* this method always returns <code>false.
*
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if a CallableStatement
object
* can return multiple <code>ResultSet objects
* simultaneously; <code>false otherwise
* @exception SQLException if a database access error occurs
* @since JDK 1.4, HSQLDB 1.7
*/
//#ifdef JAVA4
public boolean supportsMultipleOpenResults() throws SQLException {
return false;
}
//#endif JAVA4
/**
* Retrieves whether auto-generated keys can be retrieved after
* a statement has been executed. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support retrieving
* autogenerated keys through the JDBC interface at all, although
* it is possible to retrieve them in a proprietary fashion;
* this method always returns <code>false.
*
* </div>
* <!-- end release-specific documentation -->
* @return <code>true if auto-generated keys can be retrieved
* after a statement has executed; <code>false otherwise
* @exception SQLException if a database access error occurs
* @since JDK 1.4, HSQLDB 1.7
*/
//#ifdef JAVA4
public boolean supportsGetGeneratedKeys() throws SQLException {
return false;
}
//#endif JAVA4
/**
* Retrieves a description of the user-defined type (UDT) hierarchies defined in a
* particular schema in this database. Only the immediate super type
* sub type relationship is modeled.
* <P>
* Only supertype information for UDTs matching the catalog,
* schema, and type name is returned. The type name parameter
* may be a fully-qualified name. When the UDT name supplied is a
* fully-qualified name, the catalog and schemaPattern parameters are
* ignored.
* <P>
* If a UDT does not have a direct super type, it is not listed here.
* A row of the <code>ResultSet object returned by this method
* describes the designated UDT and a direct supertype. A row has the following
* columns:
* <OL>
* <LI>TYPE_CAT String => the UDT's catalog (may be null
)
* <LI>TYPE_SCHEM String => UDT's schema (may be null
)
* <LI>TYPE_NAME String => type name of the UDT
* <LI>SUPERTYPE_CAT String => the direct super type's catalog
* (may be <code>null)
* <LI>SUPERTYPE_SCHEM String => the direct super type's schema
* (may be <code>null)
* <LI>SUPERTYPE_NAME String => the direct super type's name
* </OL>
*
* <P>Note: If the driver does not support type hierarchies, an
* empty result set is returned. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* Including 1.7.1, this JDBC feature is not supported; calling
* this method throws a SQLException stating that the operation
* is not supported. <p>
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @param catalog a catalog name; "" retrieves those without a catalog;
* <code>null means drop catalog name from the selection
* criteria
* @param schemaPattern a schema name pattern; "" retrieves those
* without a schema
* @param typeNamePattern a UDT name pattern; may be a fully-qualified
* name
* @return a <code>ResultSet object in which a row gives information
* about the designated UDT
* @throws SQLException if a database access error occurs
* @since JDK 1.4, HSQLDB 1.7
*/
//#ifdef JAVA4
public ResultSet getSuperTypes(String catalog, String schemaPattern,
String typeNamePattern)
throws SQLException {
if (wantsIsNull(typeNamePattern)) {
return executeSelect("SYSTEM_SUPERTYPES", "0=1");
}
schemaPattern = translateSchema(schemaPattern);
StringBuffer select =
toQueryPrefix("SYSTEM_SUPERTYPES").append(and("TYPE_CAT", "=",
catalog)).append(and("TYPE_SCHEM", "LIKE",
schemaPattern)).append(and("TYPE_NAME",
"LIKE", typeNamePattern));
return execute(select.toString());
}
//#endif JAVA4
/**
* Retrieves a description of the table hierarchies defined in a particular
* schema in this database.
*
* <P>Only supertable information for tables matching the catalog, schema
* and table name are returned. The table name parameter may be a fully-
* qualified name, in which case, the catalog and schemaPattern parameters
* are ignored. If a table does not have a super table, it is not listed here.
* Supertables have to be defined in the same catalog and schema as the
* sub tables. Therefore, the type description does not need to include
* this information for the supertable.
*
* <P>Each type description has the following columns:
* <OL>
* <LI>TABLE_CAT String => the type's catalog (may be null
)
* <LI>TABLE_SCHEM String => type's schema (may be null
)
* <LI>TABLE_NAME String => type name
* <LI>SUPERTABLE_NAME String => the direct super type's name
* </OL>
*
* <P>Note: If the driver does not support type hierarchies, an
* empty result set is returned. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @param catalog a catalog name; "" retrieves those without a catalog;
* <code>null means drop catalog name from the selection
* criteria
* @param schemaPattern a schema name pattern; "" retrieves those
* without a schema
* @param tableNamePattern a table name pattern; may be a fully-qualified
* name
* @return a <code>ResultSet object in which each row is a type
* description
* @throws SQLException if a database access error occurs
* @since JDK 1.4, HSQLDB 1.7
*/
//#ifdef JAVA4
public ResultSet getSuperTables(String catalog, String schemaPattern,
String tableNamePattern)
throws SQLException {
if (wantsIsNull(tableNamePattern)) {
return executeSelect("SYSTEM_SUPERTABLES", "0=1");
}
schemaPattern = translateSchema(schemaPattern);
StringBuffer select =
toQueryPrefix("SYSTEM_SUPERTABLES").append(and("TABLE_CAT", "=",
catalog)).append(and("TABLE_SCHEM", "LIKE",
schemaPattern)).append(and("TABLE_NAME",
"LIKE", tableNamePattern));
return execute(select.toString());
}
//#endif JAVA4
/**
* Retrieves a description of the given attribute of the given type
* for a user-defined type (UDT) that is available in the given schema
* and catalog.
* <P>
* Descriptions are returned only for attributes of UDTs matching the
* catalog, schema, type, and attribute name criteria. They are ordered by
* TYPE_SCHEM, TYPE_NAME and ORDINAL_POSITION. This description
* does not contain inherited attributes.
* <P>
* The <code>ResultSet object that is returned has the following
* columns:
* <OL>
* <LI>TYPE_CAT String => type catalog (may be null
)
* <LI>TYPE_SCHEM String => type schema (may be null
)
* <LI>TYPE_NAME String => type name
* <LI>ATTR_NAME String => attribute name
* <LI>DATA_TYPE short => attribute type SQL type from java.sql.Types
* <LI>ATTR_TYPE_NAME String => Data source dependent type name.
* For a UDT, the type name is fully qualified. For a REF, the type name is
* fully qualified and represents the target type of the reference type.
* <LI>ATTR_SIZE int => column size. For char or date
* types this is the maximum number of characters; for numeric or
* decimal types this is precision.
* <LI>DECIMAL_DIGITS int => the number of fractional digits
* <LI>NUM_PREC_RADIX int => Radix (typically either 10 or 2)
* <LI>NULLABLE int => whether NULL is allowed
* <UL>
* <LI> attributeNoNulls - might not allow NULL values
* <LI> attributeNullable - definitely allows NULL values
* <LI> attributeNullableUnknown - nullability unknown
* </UL>
* <LI>REMARKS String => comment describing column (may be null
)
* <LI>ATTR_DEF String => default value (may be null
)
* <LI>SQL_DATA_TYPE int => unused
* <LI>SQL_DATETIME_SUB int => unused
* <LI>CHAR_OCTET_LENGTH int => for char types the
* maximum number of bytes in the column
* <LI>ORDINAL_POSITION int => index of column in table
* (starting at 1)
* <LI>IS_NULLABLE String => "NO" means column definitely
* does not allow NULL values; "YES" means the column might
* allow NULL values. An empty string means unknown.
* <LI>SCOPE_CATALOG String => catalog of table that is the
* scope of a reference attribute (<code>null if DATA_TYPE isn't REF)
* <LI>SCOPE_SCHEMA String => schema of table that is the
* scope of a reference attribute (<code>null if DATA_TYPE isn't REF)
* <LI>SCOPE_TABLE String => table name that is the scope of a
* reference attribute (<code>null if the DATA_TYPE isn't REF)
* <LI>SOURCE_DATA_TYPE short => source type of a distinct type or user-generated
* Ref type,SQL type from java.sql.Types (<code>null if DATA_TYPE
* isn't DISTINCT or user-generated REF)
* </OL>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* HSQLDB treats unquoted identifiers as case insensitive in SQL but stores
* them in upper case; it treats quoted identifiers as case sensitive and
* stores them verbatim. All jdbcDatabaseMetaData methods perform
* case-sensitive comparison between name (pattern) arguments and the
* corresponding identifier values as they are stored in the database.
* Therefore, care must be taken to specify name arguments precisely
* (including case) as they are stored in the database. <p>
*
* Including 1.7.1, this JDBC feature is not supported; calling
* this method throws a SQLException stating that the operation
* is not supported. <p>
*
* Since 1.7.2, this feature is supported by default. If the jar is
* compiled without org.hsqldb.DatabaseInformationFull or
* org.hsqldb.DatabaseInformationMain, the feature is
* not supported. The default implementation is
* {@link org.hsqldb.DatabaseInformationFull}.
* </div>
* <!-- end release-specific documentation -->
*
* @param catalog a catalog name; must match the catalog name as it
* is stored in the database; "" retrieves those without a catalog;
* <code>null means that the catalog name should not be used
* to narrow the search
* @param schemaPattern a schema name pattern; must match the schema name
* as it is stored in the database; "" retrieves those without a
* schema; <code>null means that the schema name should not be
* used to narrow the search
* @param typeNamePattern a type name pattern; must match the
* type name as it is stored in the database
* @param attributeNamePattern an attribute name pattern; must match the
* attribute name as it is declared in the database
* @return a <code>ResultSet object in which each row is an
* attribute description
* @exception SQLException if a database access error occurs
* @since JDK 1.4, HSQLDB 1.7
*/
//#ifdef JAVA4
public ResultSet getAttributes(String catalog, String schemaPattern,
String typeNamePattern,
String attributeNamePattern)
throws SQLException {
if (wantsIsNull(typeNamePattern)
|| wantsIsNull(attributeNamePattern)) {
return executeSelect("SYSTEM_UDTATTRIBUTES", "0=1");
}
schemaPattern = translateSchema(schemaPattern);
StringBuffer select = toQueryPrefix("SYSTEM_UDTATTRIBUTES").append(
and("TYPE_CAT", "=", catalog)).append(
and("TYPE_SCHEM", "LIKE", schemaPattern)).append(
and("TYPE_NAME", "LIKE", typeNamePattern)).append(
and("ATTR_NAME", "LIKE", attributeNamePattern));
return execute(select.toString());
}
//#endif JAVA4
/**
* Retrieves whether this database supports the given result
* set holdability. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Starting with 1.7.2, HSQLDB returns true for
* HOLD_CURSORS_OVER_COMMIT, else false. <p>
*
* </div>
* <!-- end release-specific documentation -->
* @param holdability one of the following constants:
* <code>ResultSet.HOLD_CURSORS_OVER_COMMIT or
* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT
* @return <code>true if so; false
otherwise
* @exception SQLException if a database access error occurs
* @see jdbcConnection
* @since JDK 1.4, HSQLDB 1.7
*/
//#ifdef JAVA4
public boolean supportsResultSetHoldability(int holdability)
throws SQLException {
return holdability == jdbcResultSet.HOLD_CURSORS_OVER_COMMIT;
}
//#endif JAVA4
/**
* Retrieves the default holdability of this <code>ResultSet
* object. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Starting with HSQLDB 1.7.2, this JDBC feature is supported. <p>
*
* Calling this method returns HOLD_CURSORS_OVER_COMMIT, since HSQLDB
* ResultSet objects are never closed as the result of an implicit
* or explicit commit operation. <p>
*
* </div>
* <!-- end release-specific documentation -->
*
* @return the default holdability; either
* <code>ResultSet.HOLD_CURSORS_OVER_COMMIT or
* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT
* @exception SQLException if a database access error occurs
* @since JDK 1.4, HSQLDB 1.7
*/
//#ifdef JAVA4
public int getResultSetHoldability() throws SQLException {
// JDBC 3.0 fr spec:
// 14.1.3 ResultSet Holdability
//
// Calling the method Connection.commit can close the ResultSet objects that
// have been created during the current transaction. In some cases, however,
// this may not be the desired behaviour. The ResultSet property holdability
// gives the application control over whether ResultSet objects (cursors) are
// closed when a commit operation is implicity or explictly performed.
// The following ResultSet constants may be supplied to the Connection methods
// createStatement, prepareStatement, and prepareCall:
//
// 1. HOLD_CURSORS_OVER_COMMIT
//
// * ResultSet objects (cursors) are not closed; they are held open when a
// commit operation is implicity or explicity performed.
//
// 2. CLOSE_CURSORS_AT_COMMIT
//
// * ResultSet objects (cursors) are closed when a commit operation is
// implicity or explicity performed. Closing cursors at commit can result
// in better performance for some applications.
//
// The default holdability of ResultSet objects is implementation defined.
// The DatabaseMetaData method getResultSetHoldability can be called to
// determine the default holdability of result sets returned by the
// underlying data source.
// --
// boucherb@users 20030819
// Our ResultSet objects are never closed as the result of a commit
return jdbcResultSet.HOLD_CURSORS_OVER_COMMIT;
}
//#endif JAVA4
/**
* Retrieves the major version number of the underlying database. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Starting with 1.7.2, the feature is supported under JDK14 builds. <p>
*
* This value is retrieved through an SQL call to the new
* {@link Library#getDatabaseMajorVersion} method which allows
* correct determination of the database major version for both local
* and remote database instances.
* </div>
* <!-- end release-specific documentation -->
* @return the underlying database's major version
* @exception SQLException if a database access error occurs
* @since JDK 1.4, HSQLDB 1.7
*/
//#ifdef JAVA4
public int getDatabaseMajorVersion() throws SQLException {
ResultSet rs =
execute("call \"org.hsqldb.Library.getDatabaseMajorVersion\"()");
rs.next();
int result = rs.getInt(1);
rs.close();
return result;
}
//#endif JAVA4
/**
* Retrieves the minor version number of the underlying database. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Starting with 1.7.2, the feature is supported under JDK14 builds. <p>
*
* This value is retrieved through an SQL call to the new
* {@link Library#getDatabaseMinorVersion} method which allows
* correct determination of the database minor version for both local
* and remote database instances.
* </div>
* <!-- end release-specific documentation -->
* @return underlying database's minor version
* @exception SQLException if a database access error occurs
* @since JDK 1.4, HSQLDB 1.7
*/
//#ifdef JAVA4
public int getDatabaseMinorVersion() throws SQLException {
ResultSet rs =
execute("call \"org.hsqldb.Library.getDatabaseMinorVersion\"()");
rs.next();
int result = rs.getInt(1);
rs.close();
return result;
}
//#endif JAVA4
/**
* Retrieves the major JDBC version number for this
* driver. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Starting with 1.7.2, the feature is supported under JDK14 builds.
* </div>
* <!-- end release-specific documentation -->
*
* @return JDBC version major number
* @exception SQLException if a database access error occurs
* @since JDK 1.4, HSQLDB 1.7
*/
//#ifdef JAVA4
public int getJDBCMajorVersion() throws SQLException {
return 3;
}
//#endif JAVA4
/**
* Retrieves the minor JDBC version number for this
* driver. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Starting with 1.7.2, the feature is supported under JDK14 builds.
* </div>
* <!-- end release-specific documentation -->
* @return JDBC version minor number
* @exception SQLException if a database access error occurs
* @since JDK 1.4, HSQLDB 1.7
*/
//#ifdef JAVA4
public int getJDBCMinorVersion() throws SQLException {
return 0;
}
//#endif JAVA4
/**
* @todo fredt@users we haven't checked it all but should aim at
* sqlStateSQL99; Need to review the codes.
*/
/**
* Indicates whether the SQLSTATEs returned by
* <code>SQLException.getSQLState is X/Open (now known as Open Group)
* SQL CLI or SQL99. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Starting with 1.7.2, HSQLDB returns <code>sqlStateSQL99.
* </div>
* <!-- end release-specific documentation -->
* @return the type of SQLSTATEs, one of:
* sqlStateXOpen or
* sqlStateSQL99
* @throws SQLException if a database access error occurs
* @since JDK 1.4, HSQLDB 1.7
*/
//#ifdef JAVA4
public int getSQLStateType() throws SQLException {
return sqlStateSQL99;
}
//#endif JAVA4
/**
* Indicates whether updates made to a LOB are made on a copy or directly
* to the LOB. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB updates the LOB directly. This
* method return false.
* </div>
* <!-- end release-specific documentation -->
*
* @return <code>true if updates are made to a copy of the LOB;
* <code>false if updates are made directly to the LOB
* @throws SQLException if a database access error occurs
* @since JDK 1.4, HSQLDB 1.7
*/
//#ifdef JAVA4
public boolean locatorsUpdateCopy() throws SQLException {
return false;
}
//#endif JAVA4
/**
* Retrieves whether this database supports statement pooling. <p>
*
* <!-- start release-specific documentation -->
* <div class="ReleaseSpecificDocumentation">
* <h3>HSQLDB-Specific Information:
*
* Up to and including 1.7.2, HSQLDB does not support statement pooling.
* This method returns false.
* </div>
* <!-- end release-specific documentation -->
*
* @return <code>true is so;
* <code>false otherwise
* @throws SQLException if a database access error occurs
* @since JDK 1.4, HSQLDB 1.7
*/
//#ifdef JAVA4
public boolean supportsStatementPooling() throws SQLException {
return false;
}
//#endif JAVA4
//----------------------- Internal Implementation --------------------------
/**
* Constructs a new <code>jdbcDatabaseMetaData object using the
* specified connection. This contructor is used by <code>jdbcConnection
* when producing a <code>DatabaseMetaData object from a call to
* {@link jdbcConnection#getMetaData() getMetaData}.
* @param c the connection this object will use to retrieve
* instance-specific metadata
* @throws SQLException never - reserved for future use
*/
jdbcDatabaseMetaData(jdbcConnection c) throws SQLException {
// PRE: is non-null and not closed
connection = c;
if (c.connProperties != null) {
useSchemaDefault =
c.connProperties.isPropertyTrue("default_schema");
}
}
/**
* Retrieves an "AND" predicate based on the (column) <code>id,
* <code>op(erator) andval
(ue) arguments to be
* included in an SQL "WHERE" clause, using the conventions laid out for
* JDBC DatabaseMetaData filter parameter values. <p>
*
* @return an "AND" predicate built from the arguments
* @param id the simple, non-quoted identifier of a system table
* column upon which to filter. <p>
*
* No checking is done for column name validity. <br>
* It is assumed the system table column name is correct. <p>
*
* @param op the conditional operation to perform using the system table
* column name value and the <code>val argument.
*
* @param val an object representing the value to use in some conditional
* operation, op, between the column identified by the id argument
* and this argument. <p>
*
* <UL>
* <LI>null causes the empty string to be returned.
*
* <LI>toString().length() == 0 causes the returned expression
* to be built so that the IS NULL operation will occur
* against the specified column. <p>
*
* <LI>instanceof String causes the returned expression to be
* built so that the specified operation will occur between
* the specified column and the specified value, converted to
* an SQL string (single quoted, with internal single quotes
* escaped by doubling). If <code>op is "LIKE" and
* <code>val does not contain any "%" or "_" wild
* card characters, then <code>op is silently
* converted to "=". <p>
*
* <LI>!instanceof String causes an expression to built so that
* the specified operation will occur between the specified
* column and <code>String.valueOf(val).
*
* </UL>
*/
private static String and(String id, String op, Object val) {
// The JDBC standard for pattern arguments seems to be:
//
// - pass null to mean ignore (do not include in query),
// - pass "" to mean filter on <column-ident> IS NULL,
// - pass "%" to filter on <column-ident> IS NOT NULL.
// - pass sequence with "%" and "_" for wildcard matches
// - when searching on values reported directly from DatabaseMetaData
// results, typically an exact match is desired. In this case, it
// is the client's responsibility to escape any reported "%" and "_"
// characters using whatever DatabaseMetaData returns from
// getSearchEscapeString(). In our case, this is the standard escape
// character: '\'. Typically, '%' will rarely be encountered, but
// certainly '_' is to be expected on a regular basis.
// - checkme: what about the (silly) case where an identifier
// has been declared such as: 'create table "xxx\_yyy"(...)'?
// Must the client still escape the Java string like this:
// "xxx\\\\_yyy"?
// Yes: because otherwise the driver is expected to
// construct something like:
// select ... where ... like 'xxx\_yyy' escape '\'
// which will try to match 'xxx_yyy', not 'xxx\_yyy'
// Testing indicates that indeed, higher quality popular JDBC
// database browsers do the escapes "properly."
if (val == null) {
return "";
}
StringBuffer sb = new StringBuffer();
boolean isStr = (val instanceof String);
if (isStr && ((String) val).length() == 0) {
return sb.append(" AND ").append(id).append(" IS NULL").toString();
}
String v = isStr ? Column.createSQLString((String) val)
: String.valueOf(val);
sb.append(" AND ").append(id).append(' ');
// add the escape to like if required
if (isStr && "LIKE".equalsIgnoreCase(op)) {
if (v.indexOf('_') < 0 && v.indexOf('%') < 0) {
// then we can optimize.
sb.append("=").append(' ').append(v);
} else {
sb.append("LIKE").append(' ').append(v);
if ((v.indexOf("\\_") >= 0) || (v.indexOf("\\%") >= 0)) {
// then client has requested at least one escape.
sb.append(" ESCAPE '\\'");
}
}
} else {
sb.append(op).append(' ').append(v);
}
return sb.toString();
}
/**
* The main SQL statement executor. All SQL destined for execution
* ultimately goes through this method. <p>
*
* The sqlStatement field for the result is set autoClose to comply with
* ResultSet.getStatement() semantics for result sets that are not from
* a user supplied Statement object. (fredt) <p>
*
* @param sql SQL statement to execute
* @return the result of issuing the statement
* @throws SQLException is a database error occurs
*/
private ResultSet execute(String sql) throws SQLException {
// NOTE:
// Need to create a jdbcStatement here so jdbcResultSet can return
// its Statement object on call to getStatement().
// The native jdbcConnection.execute() method does not
// automatically assign a Statement object for the ResultSet, but
// jdbcStatement does. That is, without this, there is no way for the
// jdbcResultSet to find its way back to its Connection (or Statement)
// Also, cannot use single, shared jdbcStatement object, as each
// fetchResult() closes any old jdbcResultSet before fetching the
// next, causing the jdbcResultSet's Result object to be nullified
final int scroll = jdbcResultSet.TYPE_SCROLL_INSENSITIVE;
final int concur = jdbcResultSet.CONCUR_READ_ONLY;
ResultSet r = connection.createStatement(scroll,
concur).executeQuery(sql);
((jdbcResultSet) r).autoClose = true;
return r;
}
/**
* An SQL statement executor that knows how to create a "SELECT
* * FROM" statement, given a table name and a <em>where clause.
*
* If the <em>where clause is null, it is ommited.
*
* It is assumed that the table name is non-null, since this is a private
* method. No check is performed. <p>
*
* @return the result of executing "SELECT * FROM " + table " " + where
* @param table the name of a table to "select * from"
* @param where the where condition for the select
* @throws SQLException if database error occurs
*/
private ResultSet executeSelect(String table,
String where) throws SQLException {
String select = selstar + table;
if (where != null) {
select += " WHERE " + where;
}
return execute(select);
}
/**
* Retrieves "SELECT * FROM <table> WHERE 1=1" in string
* buffer form. <p>
*
* This is a convenience method provided because, for most
* <code>DatabaseMetaData queries, this is the most suitable
* thing upon which to start building. <p>
*
* @return an StringBuffer whose content is:
* "SELECT * FROM <table> WHERE 1=1"
* @param t the name of the table
*/
private StringBuffer toQueryPrefix(String t) {
StringBuffer sb = new StringBuffer(255);
return sb.append(selstar).append(t).append(whereTrue);
}
/**
* Retrieves whether the JDBC <code>DatabaseMetaData contract
* specifies that the argument <code>scode> is filter parameter
* value that requires a corresponding IS NULL predicate. <p>
*
* @param s the filter parameter to test
* @return true if the argument, s, is filter paramter value that
* requires a corresponding IS NULL predicate
*/
private static boolean wantsIsNull(String s) {
return (s != null && s.length() == 0);
}
/**
* For compatibility, when the connection property "default_schame=true"
* is present, any DatabaseMetaData call with an empty string as the
* schema parameter will use the default schema (noramlly "PUBLIC").
*/
private String translateSchema(String schemaName) throws SQLException {
if (useSchemaDefault && schemaName != null
&& schemaName.length() == 0) {
ResultSet rs = executeSelect("SYSTEM_SCHEMAS", "IS_DEFAULT=TRUE");
if (rs.next()) {
return rs.getString(1);
}
return schemaName;
}
return schemaName;
}
//#ifdef JAVA6
/*
public RowIdLifetime getRowIdLifetime() throws SQLException
{
throw new UnsupportedOperationException("Not supported yet.");
}
public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException
{
throw new UnsupportedOperationException("Not supported yet.");
}
public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException
{
throw new UnsupportedOperationException("Not supported yet.");
}
public boolean autoCommitFailureClosesAllResultSets() throws SQLException
{
throw new UnsupportedOperationException("Not supported yet.");
}
public ResultSet getClientInfoProperties() throws SQLException
{
throw new UnsupportedOperationException("Not supported yet.");
}
public ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern) throws SQLException
{
throw new UnsupportedOperationException("Not supported yet.");
}
public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern) throws SQLException
{
throw new UnsupportedOperationException("Not supported yet.");
}
public <T> T unwrap(Class iface) throws SQLException
{
throw new UnsupportedOperationException("Not supported yet.");
}
public boolean isWrapperFor(Class<?> iface) throws SQLException
{
throw new UnsupportedOperationException("Not supported yet.");
}
*/
//#endif JAVA6
}