1 /* Copyright (c) 2001-2016, The HSQL Development Group 2 * All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * Redistributions of source code must retain the above copyright notice, this 8 * list of conditions and the following disclaimer. 9 * 10 * Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * 14 * Neither the name of the HSQL Development Group nor the names of its 15 * contributors may be used to endorse or promote products derived from this 16 * software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG, 22 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 32 package org.hsqldb.jdbc; 33 34 import java.sql.Connection; 35 import java.sql.DatabaseMetaData; 36 import java.sql.ResultSet; 37 38 //#ifdef JAVA6 39 import java.sql.RowIdLifetime; 40 41 //#endif JAVA6 42 import java.sql.SQLException; 43 44 import org.hsqldb.FunctionCustom; 45 import org.hsqldb.lib.StringConverter; 46 import org.hsqldb.lib.StringUtil; 47 import org.hsqldb.persist.HsqlDatabaseProperties; 48 import org.hsqldb.types.Type; 49 50 /* $Id: JDBCDatabaseMetaData.java 5571 2016-03-24 01:01:45Z fredt $ */ 51 52 // fredt@users 20020320 - patch 1.7.0 - JDBC 2 support and error trapping 53 // JDBC 2 methods can now be called from jdk 1.1.x - see javadoc comments 54 // 55 // boucherb & 20020409 - extensive review and update of docs and behaviour 56 // fredt@users - 20020505 to comply with previous and latest java.sql 57 // specification 58 // boucherb@users 20020509 - update to JDK 1.4 / JDBC3 methods and docs 59 // boucherb@users 2002 - extensive rewrite to support new 60 // - 20030121 1.7.2 system table and metadata features. 61 // boucherb@users 20040422 - doc 1.7.2 - javadoc updates toward 1.7.2 final 62 // fredt@users 20050505 - patch 1.8.0 - enforced JDBC rules for non-pattern params 63 // boucherb@users 20051207 - update to JDK 1.6 JDBC 4.0 methods and docs 64 // - 20060709 65 // fredt@users 20080805 - full review and update to doc and method return values 66 67 /** 68 * @todo 1.9.0 - fredt - revise all selects from system tables to use 69 * SQL/SCHEMATA views with column renaming to JDBC spec 70 */ 71 // Revision 1.20 2006/07/12 12:06:54 boucherb 72 // patch 1.9.0 73 // - java.sql.Wrapper implementation section title added 74 // Revision 1.19 2006/07/09 07:07:01 boucherb 75 // - getting the CVS Log variable output format right 76 // 77 // Revision 1.18 2006/07/09 07:02:38 boucherb 78 // - patch 1.9.0 full synch up to Mustang Build 90 79 // - getColumns() (finally!!!) officially includes IS_AUTOINCREMENT 80 // 81 82 /** 83 * Comprehensive information about the database as a whole. 84 * <P> 85 * This interface is implemented by driver vendors to let users know the capabilities 86 * of a Database Management System (DBMS) in combination with 87 * the driver based on JDBC<sup><font size=-2>TM</font></sup> technology 88 * ("JDBC driver") that is used with it. Different relational DBMSs often support 89 * different features, implement features in different ways, and use different 90 * data types. In addition, a driver may implement a feature on top of what the 91 * DBMS offers. Information returned by methods in this interface applies 92 * to the capabilities of a particular driver and a particular DBMS working 93 * together. Note that as used in this documentation, the term "database" is 94 * used generically to refer to both the driver and DBMS. 95 * <P> 96 * A user for this interface is commonly a tool that needs to discover how to 97 * deal with the underlying DBMS. This is especially true for applications 98 * that are intended to be used with more than one DBMS. For example, a tool might use the method 99 * <code>getTypeInfo</code> to find out what data types can be used in a 100 * <code>CREATE TABLE</code> statement. Or a user might call the method 101 * <code>supportsCorrelatedSubqueries</code> to see if it is possible to use 102 * a correlated subquery or <code>supportsBatchUpdates</code> to see if it is 103 * possible to use batch updates. 104 * <P> 105 * Some <code>DatabaseMetaData</code> methods return lists of information 106 * in the form of <code>ResultSet</code> objects. 107 * Regular <code>ResultSet</code> methods, such as 108 * <code>getString</code> and <code>getInt</code>, can be used 109 * to retrieve the data from these <code>ResultSet</code> objects. If 110 * a given form of metadata is not available, an empty <code>ResultSet</code> 111 * will be returned. Additional columns beyond the columns defined to be 112 * returned by the <code>ResultSet</code> object for a given method 113 * can be defined by the JDBC driver vendor and must be accessed 114 * by their <B>column label</B>. 115 * <P> 116 * Some <code>DatabaseMetaData</code> methods take arguments that are 117 * String patterns. These arguments all have names such as fooPattern. 118 * Within a pattern String, "%" means match any substring of 0 or more 119 * characters, and "_" means match any one character. Only metadata 120 * entries matching the search pattern are returned. If a search pattern 121 * argument is set to <code>null</code>, that argument's criterion will 122 * be dropped from the search. 123 * <P> 124 * A method that gets information about a feature that the driver does not 125 * support will throw an <code>SQLException</code>. 126 * In the case of methods that return a <code>ResultSet</code> 127 * object, either a <code>ResultSet</code> object (which may be empty) is 128 * returned or an <code>SQLException</code> is thrown. 129 * 130 * <!-- start release-specific documentation --> 131 * <div class="ReleaseSpecificDocumentation"> 132 * <h3>HSQLDB-Specific Information:</h3> <p> 133 * 134 * <h4>Metadata Table Production</h4> 135 * 136 * Starting with HSQLDB 1.7.2, the metadata table (a.k.a system table) production 137 * implementation provided in the default build filters metadata based on each 138 * SQL session user's access rights which in turn lifts the pre-HSQLDB 1.7.2 139 * restriction that only users with the DBA role 140 * ('admin' users in older HSQLDB parlance) could expect trouble-free access to 141 * all metadata.<p> 142 * 143 * Also starting with HSQLDB 1.7.2, the metadata table production implementation 144 * classes are loaded dynamically, using a precedence policy to find and load 145 * the richest producer available at runtime. In the event that no better 146 * alternative is found, the default minimal (completely restricted) provider 147 * is selected. Under this scheme, it is possible for third party packagers to 148 * create custom distributions targeted at supporting full (design-time), 149 * custom-written (proprietary / micro environment), minimal (production-time) 150 * or completely-restricted (space-constrained | device embedded | real-time | 151 * hostile environment) metadata table production scenarios. To learn more 152 * about this option, interested parties can review the documentation and source 153 * code for the <code>org.hsqldb.dbinfo.DatabaseInformation class</code>.<p> 154 * 155 * Please also note that in addition to the metadata tables produced to 156 * directly support this class, starting with HSQLDB 1.7.2, the default build 157 * provides many additional tables covering all or most HSQLDB features, such 158 * as descriptions of the triggers and aliases defined in the database. <p> 159 * 160 * For instance, in the default build, a fairly comprehensive description of 161 * each INFORMATION_SCHEMA table and each INFORMATION_SCHEMA table 162 * column is included in the REMARKS column of the {@link #getTables( 163 * java.lang.String, java.lang.String, java.lang.String, java.lang.String[]) 164 * getTables(...)} and {@link #getColumns(java.lang.String, java.lang.String, 165 * java.lang.String, java.lang.String) getColumns(...)} results, which derive 166 * from INFORMATION_SCHEMA.SYSTEM_TABLES and INFORMATION_SCHEMA.SYSTEM_COLUMNS, 167 * respectively.<p> 168 * 169 * <h4>Schema Metadata</h4> 170 * 171 * The SQL SCHEMA concept became fully supported in the HSQLDB 1.8.x series and 172 * this fact is reflected in the all subsequent versions of this class. 173 * 174 * <h4>Catalog Metadata</h4> 175 * 176 * Starting with HSQLDB 2.0, SQL standards compliance up to SQL:2008 and beyond 177 * is a major theme which is reflected in the provision of the majority of the 178 * standard-defined full-name INFORMATION_SCHEMA views. <p> 179 * 180 * However, just as CATALOG semantics and handling are still considered to be 181 * implementation defined by the most recent SQL standard (SQL:2008), so is the 182 * HSQLDB CATALOG concept still in the process of being defined and refined in 183 * HSQLDB 2.x. and beyond.<p> 184 * 185 * Previous to HSQLDB 2.x, there were, at various points in time, experimental 186 * features provided to turn on pseudo catalog (and before that, pseudo-schema) 187 * reporting in the system tables, using the database properties 188 * 'hsqldb.catalogs' and 'hsqldb.schemas', respectively.<p> 189 * 190 * However, once the engine fully supported the SQL SCHEMA concept, the 191 * experimental 'hsqldb.schemas' * database property was retired. <p> 192 * 193 * Similarly, starting with HSQLDB 2.x, the 'hsqldb.catalogs' database property 194 * has been retired and replaced with the convention that, from the perspective 195 * of SQL identification, an HSQLDB JDBC URL connects to a single HSQLDB 196 * database instance which consists of a single, default CATALOG 197 * named PUBLIC in which each SCHEMA instance of the database resides. The name of 198 * this catalog can be changed with the ALTER CATALOG <name> RENAME TO statement. 199 * As of version 2.1.0, HSQLDB supports qualification by the containing CATALOG of 200 * database objects at the syntactic level, but does not yet support operations 201 * such as opening, manipulating or querying against multiple database 202 * catalogs within a single session, not even in a one-at-a-time fashion.<p> 203 * 204 * <h4>Index Metadata</h4> 205 * 206 * It must still be noted that as of the most recent release, HSQLDB continues 207 * to ignore the <code>approximate</code> argument of {@link #getIndexInfo 208 * getIndexInfo()} which continues to be simply indicative of absence of a fully 209 * statistics-driven cost-based SQL plan optimization facility. When, 210 * such a facility is implemented, corresponding improvements to 211 * <code>getIndexInfo</code> will be provided. <p> 212 * 213 * <h4>Notes for developers extending metadata table production</h4> 214 * 215 * Note that in the absence of an ORDER BY clause, queries against the metadata 216 * tables that directly support this class are expected to return rows in JDBC 217 * contract order. The reason for this is that results typically come 218 * back much faster when no "ORDER BY" clause is used. <p> 219 * 220 * As such, when adding, extending or replacing a JDBC database metadata table 221 * production routine, developers need to be aware of this fact and either add the 222 * contract "ORDER BY" clause to the driving SQL or, when possible, 223 * preferably maintain rows in the contract order by correctly coding the 224 * primary index definition in the table producer class.<p> 225 * 226 * <hr> 227 * 228 * <b>JRE 1.1.x Notes:</b> <p> 229 * 230 * In general, JDBC 2 support requires Java 1.2 and above, and JDBC3 requires 231 * Java 1.4 and above. In HSQLDB, support for methods introduced in different 232 * versions of JDBC depends on the JDK version used for compiling and building 233 * HSQLDB.<p> 234 * 235 * Since 1.7.0, it is possible to build the product so that 236 * all JDBC 2 methods can be called while executing under the version 1.1.x 237 * <em>Java Runtime Environment</em><sup><font size="-2">TM</font></sup>. 238 * However, some of these method calls require <code>int</code> values that 239 * are defined only in the JDBC 2 or greater version of the 240 * {@link java.sql.ResultSet ResultSet} interface. For this reason, when the 241 * product is compiled under JDK 1.1.x, these values are defined in 242 * {@link JDBCResultSet JDBCResultSet}.<p> 243 * 244 * In a JRE 1.1.x environment, calling JDBC 2 methods that take or return the 245 * JDBC2-only <code>ResultSet</code> values can be achieved by referring 246 * to them in parameter specifications and return value comparisons, 247 * respectively, as follows: <p> 248 * 249 * <pre class="JavaCodeExample"> 250 * JDBCResultSet.FETCH_FORWARD 251 * JDBCResultSet.TYPE_FORWARD_ONLY 252 * JDBCResultSet.TYPE_SCROLL_INSENSITIVE 253 * JDBCResultSet.CONCUR_READ_ONLY 254 * // etc 255 * </pre> 256 * 257 * However, please note that code written in such a manner will not be 258 * compatible for use with other JDBC 2 drivers, since they expect and use 259 * <code>ResultSet</code>, rather than <code>JDBCResultSet</code>. Also 260 * note, this feature is offered solely as a convenience to developers 261 * who must work under JDK 1.1.x due to operating constraints, yet wish to 262 * use some of the more advanced features available under the JDBC 2 263 * specification.<p> 264 * 265 * (fredt@users)<br> 266 * (boucherb@users) 267 * </div> 268 * <!-- end release-specific documentation --> 269 * 270 * @author Campbell Burnet (boucherb@users dot sourceforge.net) 271 * @author Fred Toussi (fredt@users dot sourceforge.net) 272 * @version 2.3.4 273 * @revised JDK 1.6, HSQLDB 2.0 274 * @revised JDK 1.7, HSQLDB 2.0.1 275 * @see org.hsqldb.dbinfo.DatabaseInformation 276 * @see org.hsqldb.dbinfo.DatabaseInformationMain 277 * @see org.hsqldb.dbinfo.DatabaseInformationFull 278 */ 279 //#ifdef JAVA6 280 public class JDBCDatabaseMetaData implements DatabaseMetaData, 281 java.sql.Wrapper { 282 283 //#else 284 /* 285 public class JDBCDatabaseMetaData implements DatabaseMetaData { 286 */ 287 288 //#endif 289 //---------------------------------------------------------------------- 290 // First, a variety of minor information about the target database. 291 292 /** 293 * Retrieves whether the current user can call all the procedures 294 * returned by the method <code>getProcedures</code>. 295 * 296 * <!-- start release-specific documentation --> 297 * <div class="ReleaseSpecificDocumentation"> 298 * <h3>HSQLDB-Specific Information:</h3> <p> 299 * 300 * This method <em>always</em> returns 301 * <code>true because the listed procedures are those which 302 * the current user can use</code>. <p> 303 * </div> 304 * <!-- end release-specific documentation --> 305 * 306 * @return <code>true</code> if so; <code>false</code> otherwise 307 * @exception SQLException if a database access error occurs 308 */ allProceduresAreCallable()309 public boolean allProceduresAreCallable() throws SQLException { 310 return true; 311 } 312 313 /** 314 * Retrieves whether the current user can use all the tables returned 315 * by the method <code>getTables</code> in a <code>SELECT</code> 316 * statement. 317 * 318 * <!-- start release-specific documentation --> 319 * <div class="ReleaseSpecificDocumentation"> 320 * <h3>HSQLDB-Specific Information:</h3> <p> 321 * 322 * HSQLDB always reports <code>true</code>.<p> 323 * 324 * The <code>getTables</code> call returns the list of tables to which the 325 * invoking user has some access rights. <p> 326 * 327 * </div> 328 * <!-- end release-specific documentation --> 329 * 330 * @return <code>true</code> if so; <code>false</code> otherwise 331 * @exception SQLException if a database access error occurs 332 */ allTablesAreSelectable()333 public boolean allTablesAreSelectable() throws SQLException { 334 return true; 335 } 336 337 /** 338 * Retrieves the URL for this DBMS. 339 * 340 * @return the URL for this DBMS or <code>null</code> if it cannot be 341 * generated 342 * @exception SQLException if a database access error occurs 343 */ getURL()344 public String getURL() throws SQLException { 345 return connection.getURL(); 346 } 347 348 /** 349 * Retrieves the user name as known to this database. 350 * 351 * @return the database user name 352 * @exception SQLException if a database access error occurs 353 */ getUserName()354 public String getUserName() throws SQLException { 355 356 ResultSet rs = execute("CALL USER()"); 357 358 rs.next(); 359 360 String result = rs.getString(1); 361 362 rs.close(); 363 364 return result; 365 } 366 367 /** 368 * Retrieves whether this database is in read-only mode. 369 * 370 * <!-- start release-specific documentation --> 371 * <div class="ReleaseSpecificDocumentation"> 372 * <h3>HSQLDB-Specific Information:</h3> <p> 373 * 374 * This makes an SQL call to the isReadOnlyDatabase function 375 * which provides correct determination of the read-only status for 376 * both local and remote database instances. 377 * </div> 378 * <!-- end release-specific documentation --> 379 * @return <code>true</code> if so; <code>false</code> otherwise 380 * @exception SQLException if a database access error occurs 381 */ isReadOnly()382 public boolean isReadOnly() throws SQLException { 383 384 ResultSet rs = execute("CALL IS_READONLY_DATABASE()"); 385 386 rs.next(); 387 388 boolean result = rs.getBoolean(1); 389 390 rs.close(); 391 392 return result; 393 } 394 395 /** 396 * Retrieves whether <code>NULL</code> values are sorted high. 397 * Sorted high means that <code>NULL</code> values 398 * sort higher than any other value in a domain. In an ascending order, 399 * if this method returns <code>true</code>, <code>NULL</code> values 400 * will appear at the end. By contrast, the method 401 * <code>nullsAreSortedAtEnd</code> indicates whether <code>NULL</code> values 402 * are sorted at the end regardless of sort order. 403 * 404 * <!-- start release-specific documentation --> 405 * <div class="ReleaseSpecificDocumentation"> 406 * <h3>HSQLDB-Specific Information:</h3> <p> 407 * 408 * By default HSQLDB sorts null at start and 409 * this method returns <code>false</code>. 410 * But a different value is returned if <code>sql.nulls_first</code> or 411 * <code>sql.nulls_lasst</code> properties have a non-default value. 412 * </div> 413 * <!-- end release-specific documentation --> 414 * 415 * @return <code>true</code> if so; <code>false</code> otherwise 416 * @exception SQLException if a database access error occurs 417 */ nullsAreSortedHigh()418 public boolean nullsAreSortedHigh() throws SQLException { 419 setCurrentProperties(); 420 return !nullsFirst && !nullsOrder; 421 } 422 423 /** 424 * Retrieves whether <code>NULL</code> values are sorted low. 425 * Sorted low means that <code>NULL</code> values 426 * sort lower than any other value in a domain. In an ascending order, 427 * if this method returns <code>true</code>, <code>NULL</code> values 428 * will appear at the beginning. By contrast, the method 429 * <code>nullsAreSortedAtStart</code> indicates whether <code>NULL</code> values 430 * are sorted at the beginning regardless of sort order. 431 * 432 * <!-- start release-specific documentation --> 433 * <div class="ReleaseSpecificDocumentation"> 434 * <h3>HSQLDB-Specific Information:</h3> <p> 435 * 436 * By default HSQLDB sorts null at start and 437 * this method returns <code>false</code>. 438 * But a different value is returned if <code>sql.nulls_first</code> or 439 * <code>sql.nulls_lasst</code> properties have a non-default value. 440 * </div> 441 * <!-- end release-specific documentation --> 442 * 443 * 444 * @return <code>true</code> if so; <code>false</code> otherwise 445 * @exception SQLException if a database access error occurs 446 */ nullsAreSortedLow()447 public boolean nullsAreSortedLow() throws SQLException { 448 setCurrentProperties(); 449 return nullsFirst && !nullsOrder; 450 } 451 452 /** 453 * Retrieves whether <code>NULL</code> values are sorted at the start regardless 454 * of sort order. 455 * 456 * <!-- start release-specific documentation --> 457 * <div class="ReleaseSpecificDocumentation"> 458 * <h3>HSQLDB-Specific Information:</h3> <p> 459 * 460 * By default HSQLDB sorts null at start and 461 * this method returns <code>true</code>. 462 * But a different value is returned if <code>sql.nulls_first</code> or 463 * <code>sql.nulls_last</code> properties have a non-default value.<p> 464 * Use NULLS LAST in the ORDER BY clause to sort null at the end. 465 * </div> 466 * <!-- end release-specific documentation --> 467 * 468 * @return <code>true</code> if so; <code>false</code> otherwise 469 * @exception SQLException if a database access error occurs 470 */ nullsAreSortedAtStart()471 public boolean nullsAreSortedAtStart() throws SQLException { 472 setCurrentProperties(); 473 return nullsFirst && nullsOrder; 474 } 475 476 /** 477 * Retrieves whether <code>NULL</code> values are sorted at the end regardless of 478 * sort order. 479 * 480 * <!-- start release-specific documentation --> 481 * <div class="ReleaseSpecificDocumentation"> 482 * <h3>HSQLDB-Specific Information:</h3> <p> 483 * 484 * By default HSQLDB sorts null at start and 485 * this method returns <code>false</code>. 486 * But a different value is returned if <code>sql.nulls_first</code> or 487 * <code>sql.nulls_last</code> properties have a non-default value.<p> 488 * Use NULLS LAST in the ORDER BY clause to sort null at the end. 489 * </div> 490 * <!-- end release-specific documentation --> 491 * 492 * @return <code>true</code> if so; <code>false</code> otherwise 493 * @exception SQLException if a database access error occurs 494 */ nullsAreSortedAtEnd()495 public boolean nullsAreSortedAtEnd() throws SQLException { 496 setCurrentProperties(); 497 return !nullsFirst && nullsOrder; 498 } 499 500 /** 501 * Retrieves the name of this database product. 502 * 503 * <div class="ReleaseSpecificDocumentation"> 504 * <h3>HSQLDB-Specific Information:</h3> <p> 505 * 506 * Returns the name of the HSQLDB engine. 507 * </div> <p> 508 * 509 * @return database product name 510 * @exception SQLException if a database access error occurs 511 */ getDatabaseProductName()512 public String getDatabaseProductName() throws SQLException { 513 return HsqlDatabaseProperties.PRODUCT_NAME; 514 } 515 516 /** 517 * Retrieves the version number of this database product. 518 * 519 * <div class="ReleaseSpecificDocumentation"> 520 * <h3>HSQLDB-Specific Information:</h3> <p> 521 * 522 * Returns the full version string. 523 * </div> <p> 524 * 525 * @return database version number 526 * @exception SQLException if a database access error occurs 527 */ getDatabaseProductVersion()528 public String getDatabaseProductVersion() throws SQLException { 529 530 ResultSet rs = execute("call database_version()"); 531 532 rs.next(); 533 534 return rs.getString(1); 535 } 536 537 /** 538 * Retrieves the name of this JDBC driver. 539 * 540 * @return JDBC driver name 541 * @exception SQLException if a database access error occurs 542 */ getDriverName()543 public String getDriverName() throws SQLException { 544 return HsqlDatabaseProperties.PRODUCT_NAME + " Driver"; 545 } 546 547 /** 548 * Retrieves the version number of this JDBC driver as a <code>String</code>. 549 * 550 * @return JDBC driver version 551 * @exception SQLException if a database access error occurs 552 */ getDriverVersion()553 public String getDriverVersion() throws SQLException { 554 return HsqlDatabaseProperties.THIS_VERSION; 555 } 556 557 /** 558 * Retrieves this JDBC driver's major version number. 559 * 560 * @return JDBC driver major version 561 */ getDriverMajorVersion()562 public int getDriverMajorVersion() { 563 return HsqlDatabaseProperties.MAJOR; 564 } 565 566 /** 567 * Retrieves this JDBC driver's minor version number. 568 * 569 * @return JDBC driver minor version number 570 */ getDriverMinorVersion()571 public int getDriverMinorVersion() { 572 return HsqlDatabaseProperties.MINOR; 573 } 574 575 /** 576 * Retrieves whether this database stores tables in a local file. 577 * 578 * <!-- start release-specific documentation --> 579 * <div class="ReleaseSpecificDocumentation"> 580 * <h3>HSQLDB-Specific Information:</h3> <p> 581 * 582 * From HSQLDB 1.7.2 it is assumed that this refers to data being stored 583 * by the JDBC client. This method always returns false. 584 * </div> 585 * <!-- end release-specific documentation --> 586 * @return <code>true</code> if so; <code>false</code> otherwise 587 * @exception SQLException if a database access error occurs 588 */ usesLocalFiles()589 public boolean usesLocalFiles() throws SQLException { 590 return false; 591 } 592 593 /** 594 * Retrieves whether this database uses a file for each table. 595 * 596 * <!-- start release-specific documentation --> 597 * <div class="ReleaseSpecificDocumentation"> 598 * <h3>HSQLDB-Specific Information:</h3> <p> 599 * 600 * HSQLDB does not use a file for each table. 601 * This method always returns <code>false</code>. 602 * </div> 603 * <!-- end release-specific documentation --> 604 * @return <code>true</code> if this database uses a local file for each table; 605 * <code>false</code> otherwise 606 * @exception SQLException if a database access error occurs 607 */ usesLocalFilePerTable()608 public boolean usesLocalFilePerTable() throws SQLException { 609 return false; 610 } 611 612 /** 613 * Retrieves whether this database treats mixed case unquoted SQL identifiers as 614 * case sensitive and as a result stores them in mixed case. 615 * 616 * <!-- start release-specific documentation --> 617 * <div class="ReleaseSpecificDocumentation"> 618 * <h3>HSQLDB-Specific Information:</h3> <p> 619 * 620 * HSQLDB treats unquoted identifiers as case insensitive and stores 621 * them in upper case. It treats quoted identifiers as case sensitive and 622 * stores them verbatim; this method always returns <code>false</code>. 623 * </div> 624 * <!-- end release-specific documentation --> 625 * 626 * 627 * @return <code>true</code> if so; <code>false</code> otherwise 628 * @exception SQLException if a database access error occurs 629 */ supportsMixedCaseIdentifiers()630 public boolean supportsMixedCaseIdentifiers() throws SQLException { 631 return false; 632 } 633 634 /** 635 * Retrieves whether this database treats mixed case unquoted SQL identifiers as 636 * case insensitive and stores them in upper case. 637 * 638 * <!-- start release-specific documentation --> 639 * <div class="ReleaseSpecificDocumentation"> 640 * <h3>HSQLDB-Specific Information:</h3> <p> 641 * 642 * HSQLDB treats unquoted identifiers as case insensitive and stores 643 * them in upper case. It treats quoted identifiers as case sensitive and 644 * stores them verbatim; this method always returns <code>true</code>. 645 * </div> 646 * <!-- end release-specific documentation --> 647 * 648 * 649 * @return <code>true</code> if so; <code>false</code> otherwise 650 * @exception SQLException if a database access error occurs 651 */ storesUpperCaseIdentifiers()652 public boolean storesUpperCaseIdentifiers() throws SQLException { 653 return true; 654 } 655 656 /** 657 * Retrieves whether this database treats mixed case unquoted SQL identifiers as 658 * case insensitive and stores them in lower case. 659 * 660 * <!-- start release-specific documentation --> 661 * <div class="ReleaseSpecificDocumentation"> 662 * <h3>HSQLDB-Specific Information:</h3> <p> 663 * 664 * HSQLDB treats unquoted identifiers as case insensitive and stores 665 * them in upper case. It treats quoted identifiers as case sensitive and 666 * stores them verbatim; this method always returns <code>false</code>. 667 * </div> 668 * <!-- end release-specific documentation --> 669 * 670 * 671 * @return <code>true</code> if so; <code>false</code> otherwise 672 * @exception SQLException if a database access error occurs 673 */ storesLowerCaseIdentifiers()674 public boolean storesLowerCaseIdentifiers() throws SQLException { 675 return false; 676 } 677 678 /** 679 * Retrieves whether this database treats mixed case unquoted SQL identifiers as 680 * case insensitive and stores them in mixed case. 681 * 682 * <!-- start release-specific documentation --> 683 * <div class="ReleaseSpecificDocumentation"> 684 * <h3>HSQLDB-Specific Information:</h3> <p> 685 * 686 * HSQLDB treats unquoted identifiers as case insensitive and stores 687 * them in upper case. It treats quoted identifiers as case sensitive and 688 * stores them verbatim; this method always returns <code>false</code>. 689 * </div> 690 * <!-- end release-specific documentation --> 691 * 692 * 693 * @return <code>true</code> if so; <code>false</code> otherwise 694 * @exception SQLException if a database access error occurs 695 */ storesMixedCaseIdentifiers()696 public boolean storesMixedCaseIdentifiers() throws SQLException { 697 return false; 698 } 699 700 /** 701 * Retrieves whether this database treats mixed case quoted SQL identifiers as 702 * case sensitive and as a result stores them in mixed case. 703 * 704 * <!-- start release-specific documentation --> 705 * <div class="ReleaseSpecificDocumentation"> 706 * <h3>HSQLDB-Specific Information:</h3> <p> 707 * 708 * HSQLDB treats unquoted identifiers as case insensitive and stores 709 * them in upper case. It treats quoted identifiers as case sensitive and 710 * stores them verbatim; this method always returns <code>true</code>. 711 * </div> 712 * <!-- end release-specific documentation --> 713 * 714 * 715 * @return <code>true</code> if so; <code>false</code> otherwise 716 * @exception SQLException if a database access error occurs 717 */ supportsMixedCaseQuotedIdentifiers()718 public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { 719 return true; 720 } 721 722 /** 723 * Retrieves whether this database treats mixed case quoted SQL identifiers as 724 * case insensitive and stores them in upper case. 725 * 726 * <!-- start release-specific documentation --> 727 * <div class="ReleaseSpecificDocumentation"> 728 * <h3>HSQLDB-Specific Information:</h3> <p> 729 * 730 * HSQLDB treats unquoted identifiers as case insensitive and stores 731 * them in upper case. It treats quoted identifiers as case sensitive and 732 * stores them verbatim; this method always returns <code>false</code>. 733 * </div> 734 * <!-- end release-specific documentation --> 735 * 736 * 737 * @return <code>true</code> if so; <code>false</code> otherwise 738 * @exception SQLException if a database access error occurs 739 */ storesUpperCaseQuotedIdentifiers()740 public boolean storesUpperCaseQuotedIdentifiers() throws SQLException { 741 return false; 742 } 743 744 /** 745 * Retrieves whether this database treats mixed case quoted SQL identifiers as 746 * case insensitive and stores them in lower case. 747 * 748 * <!-- start release-specific documentation --> 749 * <div class="ReleaseSpecificDocumentation"> 750 * <h3>HSQLDB-Specific Information:</h3> <p> 751 * 752 * HSQLDB treats unquoted identifiers as case insensitive and stores 753 * them in upper case. It treats quoted identifiers as case sensitive and 754 * stores them verbatim; this method always returns <code>false</code>. 755 * </div> 756 * <!-- end release-specific documentation --> 757 * @return <code>true</code> if so; <code>false</code> otherwise 758 * @exception SQLException if a database access error occurs 759 */ storesLowerCaseQuotedIdentifiers()760 public boolean storesLowerCaseQuotedIdentifiers() throws SQLException { 761 return false; 762 } 763 764 /** 765 * Retrieves whether this database treats mixed case quoted SQL identifiers as 766 * case insensitive and stores them in mixed case. 767 * 768 * <!-- start release-specific documentation --> 769 * <div class="ReleaseSpecificDocumentation"> 770 * <h3>HSQLDB-Specific Information:</h3> <p> 771 * 772 * HSQLDB treats unquoted identifiers as case insensitive and stores 773 * them in upper case. It treats quoted identifiers as case sensitive and 774 * stores them verbatim; this method always returns <code>false</code>. 775 * </div> 776 * <!-- end release-specific documentation --> 777 * 778 * 779 * @return <code>true</code> if so; <code>false</code> otherwise 780 * @exception SQLException if a database access error occurs 781 */ storesMixedCaseQuotedIdentifiers()782 public boolean storesMixedCaseQuotedIdentifiers() throws SQLException { 783 return false; 784 } 785 786 /** 787 * Retrieves the string used to quote SQL identifiers. 788 * This method returns a space " " if identifier quoting is not supported. 789 * 790 * <!-- start release-specific documentation --> 791 * <div class="ReleaseSpecificDocumentation"> 792 * <h3>HSQLDB-Specific Information:</h3> <p> 793 * 794 * HSQLDB uses the standard SQL identifier quote character 795 * (the double quote character); this method always returns <b>"</b>. 796 * </div> 797 * <!-- end release-specific documentation --> 798 * @return the quoting string or a space if quoting is not supported 799 * @exception SQLException if a database access error occurs 800 */ getIdentifierQuoteString()801 public String getIdentifierQuoteString() throws SQLException { 802 return "\""; 803 } 804 805 /** 806 * Retrieves a comma-separated list of all of this database's SQL keywords 807 * that are NOT also SQL:2003 keywords. 808 * (JDBC4 modified => SQL:2003) 809 * 810 * <!-- start release-specific documentation --> 811 * <div class="ReleaseSpecificDocumentation"> 812 * <h3>HSQLDB-Specific Information:</h3> <p> 813 * 814 * The list is empty. However, HSQLDB also supports SQL:2008 keywords 815 * and disallows them for database object names without double quoting. 816 * </div> 817 * <!-- end release-specific documentation --> 818 * 819 * 820 * @return the list of this database's keywords that are not also 821 * SQL:2003 keywords 822 * (JDBC4 modified => SQL:2003) 823 * @exception SQLException if a database access error occurs 824 */ getSQLKeywords()825 public String getSQLKeywords() throws SQLException { 826 return ""; 827 } 828 829 /** 830 * Retrieves a comma-separated list of math functions available with 831 * this database. These are the Open /Open CLI math function names used in 832 * the JDBC function escape clause. 833 * 834 * @return the list of math functions supported by this database 835 * @exception SQLException if a database access error occurs 836 */ getNumericFunctions()837 public String getNumericFunctions() throws SQLException { 838 return StringUtil.getList(FunctionCustom.openGroupNumericFunctions, 839 ",", ""); 840 } 841 842 /** 843 * Retrieves a comma-separated list of string functions available with 844 * this database. These are the Open Group CLI string function names used 845 * in the JDBC function escape clause. 846 * 847 * @return the list of string functions supported by this database 848 * @exception SQLException if a database access error occurs 849 */ getStringFunctions()850 public String getStringFunctions() throws SQLException { 851 return StringUtil.getList(FunctionCustom.openGroupStringFunctions, 852 ",", ""); 853 } 854 855 /** 856 * Retrieves a comma-separated list of system functions available with 857 * this database. These are the Open Group CLI system function names used 858 * in the JDBC function escape clause. 859 * 860 * @return a list of system functions supported by this database 861 * @exception SQLException if a database access error occurs 862 */ getSystemFunctions()863 public String getSystemFunctions() throws SQLException { 864 return StringUtil.getList(FunctionCustom.openGroupSystemFunctions, 865 ",", ""); 866 } 867 868 /** 869 * Retrieves a comma-separated list of the time and date functions available 870 * with this database. 871 * 872 * @return the list of time and date functions supported by this database 873 * @exception SQLException if a database access error occurs 874 */ getTimeDateFunctions()875 public String getTimeDateFunctions() throws SQLException { 876 return StringUtil.getList(FunctionCustom.openGroupDateTimeFunctions, 877 ",", ""); 878 } 879 880 /** 881 * Retrieves the string that can be used to escape wildcard characters. 882 * This is the string that can be used to escape '_' or '%' in 883 * the catalog search parameters that are a pattern (and therefore use one 884 * of the wildcard characters). 885 * 886 * <P>The '_' character represents any single character; 887 * the '%' character represents any sequence of zero or 888 * more characters. 889 * 890 * <!-- start release-specific documentation --> 891 * <div class="ReleaseSpecificDocumentation"> 892 * <h3>HSQLDB-Specific Information:</h3> <p> 893 * 894 * HSQLDB uses the "\" character to escape wildcard characters. 895 * </div> 896 * <!-- end release-specific documentation --> 897 * 898 * 899 * @return the string used to escape wildcard characters 900 * @exception SQLException if a database access error occurs 901 */ getSearchStringEscape()902 public String getSearchStringEscape() throws SQLException { 903 return "\\"; 904 } 905 906 /** 907 * Retrieves all the "extra" characters that can be used in unquoted 908 * identifier names (those beyond a-z, A-Z, 0-9 and _). 909 * 910 * <!-- start release-specific documentation --> 911 * <div class="ReleaseSpecificDocumentation"> 912 * <h3>HSQLDB-Specific Information:</h3> <p> 913 * 914 * By default HSQLDB does not support using any "extra" characters in 915 * unquoted identifier names; this method always returns the empty String. 916 * </div> 917 * <!-- end release-specific documentation --> 918 * 919 * 920 * @return the string containing the extra characters 921 * @exception SQLException if a database access error occurs 922 */ getExtraNameCharacters()923 public String getExtraNameCharacters() throws SQLException { 924 return ""; 925 } 926 927 //-------------------------------------------------------------------- 928 // Functions describing which features are supported. 929 930 /** 931 * Retrieves whether this database supports <code>ALTER TABLE</code> 932 * with add column. 933 * 934 * <!-- start release-specific documentation --> 935 * <div class="ReleaseSpecificDocumentation"> 936 * <h3>HSQLDB-Specific Information:</h3> <p> 937 * 938 * From 1.7.0, HSQLDB supports this type of 939 * <code>ALTER TABLE</code> statement; this method always 940 * returns <code>true</code>. 941 * </div> 942 * <!-- end release-specific documentation --> 943 * @return <code>true</code> if so; <code>false</code> otherwise 944 * @exception SQLException if a database access error occurs 945 */ supportsAlterTableWithAddColumn()946 public boolean supportsAlterTableWithAddColumn() throws SQLException { 947 return true; 948 } 949 950 /** 951 * Retrieves whether this database supports <code>ALTER TABLE</code> 952 * with drop column. 953 * 954 * <!-- start release-specific documentation --> 955 * <div class="ReleaseSpecificDocumentation"> 956 * <h3>HSQLDB-Specific Information:</h3> <p> 957 * 958 * From 1.7.0, HSQLDB supports this type of 959 * <code>ALTER TABLE</code> statement; this method always 960 * returns <code>true</code>. 961 * </div> 962 * <!-- end release-specific documentation --> 963 * @return <code>true</code> if so; <code>false</code> otherwise 964 * @exception SQLException if a database access error occurs 965 */ supportsAlterTableWithDropColumn()966 public boolean supportsAlterTableWithDropColumn() throws SQLException { 967 return true; 968 } 969 970 /** 971 * Retrieves whether this database supports column aliasing. 972 * 973 * <P>If so, the SQL AS clause can be used to provide names for 974 * computed columns or to provide alias names for columns as 975 * required. 976 * 977 * <!-- start release-specific documentation --> 978 * <div class="ReleaseSpecificDocumentation"> 979 * <h3>HSQLDB-Specific Information:</h3> <p> 980 * 981 * HSQLDB supports column aliasing; this method always 982 * returns <code>true</code>. 983 * </div> 984 * <!-- end release-specific documentation --> 985 * 986 * 987 * @return <code>true</code> if so; <code>false</code> otherwise 988 * @exception SQLException if a database access error occurs 989 */ supportsColumnAliasing()990 public boolean supportsColumnAliasing() throws SQLException { 991 return true; 992 } 993 994 /** 995 * Retrieves whether this database supports concatenations between 996 * <code>NULL</code> and non-<code>NULL</code> values being 997 * <code>NULL</code>. 998 * 999 * <!-- start release-specific documentation --> 1000 * <div class="ReleaseSpecificDocumentation"> 1001 * <h3>HSQLDB-Specific Information:</h3> <p> 1002 * 1003 * By default HSQLDB returns NULL when NULL and non-NULL values 1004 * are concatenated. 1005 * By default this method returns <code>false</code>. 1006 * But a different value is returned if the <code>sql.concat_nulls</code> 1007 * property has a non-default value.<p> 1008 * </div> 1009 * <!-- end release-specific documentation --> 1010 * 1011 * 1012 * @return <code>true</code> if so; <code>false</code> otherwise 1013 * @exception SQLException if a database access error occurs 1014 */ nullPlusNonNullIsNull()1015 public boolean nullPlusNonNullIsNull() throws SQLException { 1016 return concatNulls; 1017 } 1018 1019 /** 1020 * (JDBC4 clarification:) 1021 * Retrieves whether this database supports the JDBC scalar function 1022 * <code>CONVERT</code> for the conversion of one JDBC type to another. 1023 * The JDBC types are the generic SQL data types defined 1024 * in <code>java.sql.Types</code>. 1025 * 1026 * <!-- start release-specific documentation --> 1027 * <div class="ReleaseSpecificDocumentation"> 1028 * <h3>HSQLDB-Specific Information:</h3> <p> 1029 * 1030 * HSQLDB supports conversions; this method always 1031 * returns <code>true</code>. 1032 * </div> 1033 * <!-- end release-specific documentation --> 1034 * 1035 * 1036 * @return <code>true</code> if so; <code>false</code> otherwise 1037 * @exception SQLException if a database access error occurs 1038 */ supportsConvert()1039 public boolean supportsConvert() throws SQLException { 1040 return true; 1041 } 1042 1043 /** @todo needs the full conversion matrix here. Should use org.hsqldb.types */ 1044 1045 /** 1046 * (JDBC4 clarification:) 1047 * Retrieves whether this database supports the JDBC scalar function 1048 * <code>CONVERT</code> for conversions between the JDBC types <i>fromType</i> 1049 * and <i>toType</i>. The JDBC types are the generic SQL data types defined 1050 * in <code>java.sql.Types</code>. 1051 * 1052 * <!-- start release-specific documentation --> 1053 * <div class="ReleaseSpecificDocumentation"> 1054 * <h3>HSQLDB-Specific Information:</h3> <p> 1055 * 1056 * HSQLDB 2.0 supports conversion according to SQL standards. In addition, 1057 * it supports conversion between values of BOOLEAN and BIT types. 1058 * </div> 1059 * <!-- end release-specific documentation --> 1060 * 1061 * 1062 * @param fromType the type to convert from; one of the type codes from 1063 * the class <code>java.sql.Types</code> 1064 * @param toType the type to convert to; one of the type codes from 1065 * the class <code>java.sql.Types</code> 1066 * @return <code>true</code> if so; <code>false</code> otherwise 1067 * @exception SQLException if a database access error occurs 1068 * @see java.sql.Types 1069 */ supportsConvert(int fromType, int toType)1070 public boolean supportsConvert(int fromType, 1071 int toType) throws SQLException { 1072 1073 Type from = 1074 Type.getDefaultTypeWithSize(Type.getHSQLDBTypeCode(fromType)); 1075 Type to = Type.getDefaultTypeWithSize(Type.getHSQLDBTypeCode(toType)); 1076 1077 if (from == null || to == null) { 1078 return false; 1079 } 1080 1081 if (fromType == java.sql.Types.NULL 1082 && toType == java.sql.Types.ARRAY) { 1083 return true; 1084 } 1085 1086 return to.canConvertFrom(from); 1087 } 1088 1089 /** 1090 * Retrieves whether this database supports table correlation names. 1091 * 1092 * <!-- start release-specific documentation --> 1093 * <div class="ReleaseSpecificDocumentation"> 1094 * <h3>HSQLDB-Specific Information:</h3> <p> 1095 * 1096 * HSQLDB supports table correlation names; this method always 1097 * returns <code>true</code>. 1098 * </div> 1099 * <!-- end release-specific documentation --> 1100 * 1101 * 1102 * @return <code>true</code> if so; <code>false</code> otherwise 1103 * @exception SQLException if a database access error occurs 1104 */ supportsTableCorrelationNames()1105 public boolean supportsTableCorrelationNames() throws SQLException { 1106 return true; 1107 } 1108 1109 /** 1110 * Retrieves whether, when table correlation names are supported, they 1111 * are restricted to being different from the names of the tables. 1112 * 1113 * <!-- start release-specific documentation --> 1114 * <div class="ReleaseSpecificDocumentation"> 1115 * <h3>HSQLDB-Specific Information:</h3> <p> 1116 * 1117 * HSQLDB does not require that table correlation names are different from the 1118 * names of the tables; this method always returns <code>false</code>. 1119 * </div> 1120 * <!-- end release-specific documentation --> 1121 * 1122 * 1123 * @return <code>true</code> if so; <code>false</code> otherwise 1124 * @exception SQLException if a database access error occurs 1125 */ supportsDifferentTableCorrelationNames()1126 public boolean supportsDifferentTableCorrelationNames() throws SQLException { 1127 return false; 1128 } 1129 1130 /** 1131 * Retrieves whether this database supports expressions in 1132 * <code>ORDER BY</code> lists. 1133 * 1134 * <!-- start release-specific documentation --> 1135 * <div class="ReleaseSpecificDocumentation"> 1136 * <h3>HSQLDB-Specific Information:</h3> <p> 1137 * 1138 * HSQLDB supports expressions in <code>ORDER BY</code> lists; this 1139 * method always returns <code>true</code>. 1140 * </div> 1141 * <!-- end release-specific documentation --> 1142 * 1143 * 1144 * @return <code>true</code> if so; <code>false</code> otherwise 1145 * @exception SQLException if a database access error occurs 1146 */ supportsExpressionsInOrderBy()1147 public boolean supportsExpressionsInOrderBy() throws SQLException { 1148 return true; 1149 } 1150 1151 /** 1152 * Retrieves whether this database supports using a column that is 1153 * not in the <code>SELECT</code> statement in an 1154 * <code>ORDER BY</code> clause. 1155 * 1156 * <!-- start release-specific documentation --> 1157 * <div class="ReleaseSpecificDocumentation"> 1158 * <h3>HSQLDB-Specific Information:</h3> <p> 1159 * 1160 * HSQLDB supports using a column that is not in the <code>SELECT</code> 1161 * statement in an <code>ORDER BY</code> clause; this method always 1162 * returns <code>true</code>. 1163 * </div> 1164 * <!-- end release-specific documentation --> 1165 * 1166 * 1167 * @return <code>true</code> if so; <code>false</code> otherwise 1168 * @exception SQLException if a database access error occurs 1169 */ supportsOrderByUnrelated()1170 public boolean supportsOrderByUnrelated() throws SQLException { 1171 return true; 1172 } 1173 1174 /** 1175 * Retrieves whether this database supports some form of 1176 * <code>GROUP BY</code> clause. 1177 * 1178 * <!-- start release-specific documentation --> 1179 * <div class="ReleaseSpecificDocumentation"> 1180 * <h3>HSQLDB-Specific Information:</h3> <p> 1181 * 1182 * HSQLDB supports using the <code>GROUP BY</code> clause; this method 1183 * always returns <code>true</code>. 1184 * </div> 1185 * <!-- end release-specific documentation --> 1186 * 1187 * 1188 * @return <code>true</code> if so; <code>false</code> otherwise 1189 * @exception SQLException if a database access error occurs 1190 */ supportsGroupBy()1191 public boolean supportsGroupBy() throws SQLException { 1192 return true; 1193 } 1194 1195 /** 1196 * Retrieves whether this database supports using a column that is 1197 * not in the <code>SELECT</code> statement in a 1198 * <code>GROUP BY</code> clause. 1199 * 1200 * <!-- start release-specific documentation --> 1201 * <div class="ReleaseSpecificDocumentation"> 1202 * <h3>HSQLDB-Specific Information:</h3> <p> 1203 * 1204 * HSQLDB supports using a column that is 1205 * not in the <code>SELECT</code> statement in a 1206 * <code>GROUP BY</code> clause; this method 1207 * always returns <code>true</code>. 1208 * </div> 1209 * <!-- end release-specific documentation --> 1210 * 1211 * 1212 * @return <code>true</code> if so; <code>false</code> otherwise 1213 * @exception SQLException if a database access error occurs 1214 */ supportsGroupByUnrelated()1215 public boolean supportsGroupByUnrelated() throws SQLException { 1216 return true; 1217 } 1218 1219 /** 1220 * Retrieves whether this database supports using columns not included in 1221 * the <code>SELECT</code> statement in a <code>GROUP BY</code> clause 1222 * provided that all of the columns in the <code>SELECT</code> statement 1223 * are included in the <code>GROUP BY</code> clause. 1224 * 1225 * <!-- start release-specific documentation --> 1226 * <div class="ReleaseSpecificDocumentation"> 1227 * <h3>HSQLDB-Specific Information:</h3> <p> 1228 * 1229 * HSQLDB supports using columns not included in 1230 * the <code>SELECT</code> statement in a <code>GROUP BY</code> clause 1231 * provided that all of the columns in the <code>SELECT</code> statement 1232 * are included in the <code>GROUP BY</code> clause; this method 1233 * always returns <code>true</code>. 1234 * </div> 1235 * <!-- end release-specific documentation --> 1236 * 1237 * 1238 * @return <code>true</code> if so; <code>false</code> otherwise 1239 * @exception SQLException if a database access error occurs 1240 */ supportsGroupByBeyondSelect()1241 public boolean supportsGroupByBeyondSelect() throws SQLException { 1242 return true; 1243 } 1244 1245 /** 1246 * Retrieves whether this database supports specifying a 1247 * <code>LIKE</code> escape clause. 1248 * 1249 * <!-- start release-specific documentation --> 1250 * <div class="ReleaseSpecificDocumentation"> 1251 * <h3>HSQLDB-Specific Information:</h3> <p> 1252 * 1253 * HSQLDB supports specifying a 1254 * <code>LIKE</code> escape clause; this method 1255 * always returns <code>true</code>. 1256 * </div> 1257 * <!-- end release-specific documentation --> 1258 * 1259 * 1260 * @return <code>true</code> if so; <code>false</code> otherwise 1261 * @exception SQLException if a database access error occurs 1262 */ supportsLikeEscapeClause()1263 public boolean supportsLikeEscapeClause() throws SQLException { 1264 return true; 1265 } 1266 1267 /** 1268 * Retrieves whether this database supports getting multiple 1269 * <code>ResultSet</code> objects from a single call to the 1270 * method <code>execute</code>. 1271 * 1272 * <!-- start release-specific documentation --> 1273 * <div class="ReleaseSpecificDocumentation"> 1274 * <h3>HSQLDB-Specific Information:</h3> <p> 1275 * 1276 * HSQLDB 2.0 supports getting multiple 1277 * <code>ResultSet</code> objects from a single call to the method 1278 * <code>execute</code> of the CallableStatement interface; 1279 * this method returns <code>true</code>.<p> 1280 * 1281 * </div> 1282 * <!-- end release-specific documentation --> 1283 * @return <code>true</code> if so; <code>false</code> otherwise 1284 * @exception SQLException if a database access error occurs 1285 */ supportsMultipleResultSets()1286 public boolean supportsMultipleResultSets() throws SQLException { 1287 return true; 1288 } 1289 1290 /** 1291 * Retrieves whether this database allows having multiple 1292 * transactions open at once (on different connections). 1293 * 1294 * <!-- start release-specific documentation --> 1295 * <div class="ReleaseSpecificDocumentation"> 1296 * <h3>HSQLDB-Specific Information:</h3> <p> 1297 * 1298 * HSQLDB allows having multiple 1299 * transactions open at once (on different connections); this method 1300 * always returns <code>true</code>. 1301 * </div> 1302 * <!-- end release-specific documentation --> 1303 * 1304 * 1305 * @return <code>true</code> if so; <code>false</code> otherwise 1306 * @exception SQLException if a database access error occurs 1307 */ supportsMultipleTransactions()1308 public boolean supportsMultipleTransactions() throws SQLException { 1309 return true; 1310 } 1311 1312 /** 1313 * Retrieves whether columns in this database may be defined as non-nullable. 1314 * 1315 * <!-- start release-specific documentation --> 1316 * <div class="ReleaseSpecificDocumentation"> 1317 * <h3>HSQLDB-Specific Information:</h3> <p> 1318 * 1319 * HSQLDB supports the specification of non-nullable columns; this method 1320 * always returns <code>true</code>. 1321 * </div> 1322 * <!-- end release-specific documentation --> 1323 * 1324 * 1325 * @return <code>true</code> if so; <code>false</code> otherwise 1326 * @exception SQLException if a database access error occurs 1327 */ supportsNonNullableColumns()1328 public boolean supportsNonNullableColumns() throws SQLException { 1329 return true; 1330 } 1331 1332 /** 1333 * Retrieves whether this database supports the ODBC Minimum SQL grammar. 1334 * 1335 * <!-- start release-specific documentation --> 1336 * <div class="ReleaseSpecificDocumentation"> 1337 * <h3>HSQLDB-Specific Information:</h3> <p> 1338 * 1339 * From 2.0, HSQLDB supports the ODBC Minimum SQL grammar; 1340 * this method always returns <code>true</code>. 1341 * </div> 1342 * <!-- end release-specific documentation --> 1343 * @return <code>true</code> if so; <code>false</code> otherwise 1344 * @exception SQLException if a database access error occurs 1345 */ supportsMinimumSQLGrammar()1346 public boolean supportsMinimumSQLGrammar() throws SQLException { 1347 return true; 1348 } 1349 1350 /** 1351 * Retrieves whether this database supports the ODBC Core SQL grammar. 1352 * 1353 * <!-- start release-specific documentation --> 1354 * <div class="ReleaseSpecificDocumentation"> 1355 * <h3>HSQLDB-Specific Information:</h3> <p> 1356 * 1357 * From 2.0, HSQLDB supports the ODBC Core SQL grammar; 1358 * this method always returns <code>true</code>. 1359 * </div> 1360 * <!-- end release-specific documentation --> 1361 * @return <code>true</code> if so; <code>false</code> otherwise 1362 * @exception SQLException if a database access error occurs 1363 */ supportsCoreSQLGrammar()1364 public boolean supportsCoreSQLGrammar() throws SQLException { 1365 return true; 1366 } 1367 1368 /** 1369 * Retrieves whether this database supports the ODBC Extended SQL grammar. 1370 * 1371 * <!-- start release-specific documentation --> 1372 * <div class="ReleaseSpecificDocumentation"> 1373 * <h3>HSQLDB-Specific Information:</h3> <p> 1374 * 1375 * From 2.0, HSQLDB supports the ODBC Extended SQL grammar; 1376 * this method always returns <code>true</code>. 1377 * </div> 1378 * <!-- end release-specific documentation --> 1379 * @return <code>true</code> if so; <code>false</code> otherwise 1380 * @exception SQLException if a database access error occurs 1381 */ supportsExtendedSQLGrammar()1382 public boolean supportsExtendedSQLGrammar() throws SQLException { 1383 return true; 1384 } 1385 1386 /** 1387 * Retrieves whether this database supports the ANSI92 entry level SQL 1388 * grammar. 1389 * 1390 * <!-- start release-specific documentation --> 1391 * <div class="ReleaseSpecificDocumentation"> 1392 * <h3>HSQLDB-Specific Information:</h3> <p> 1393 * 1394 * From 2.0, HSQLDB supports the ANSI92 entry level SQL grammar; 1395 * this method always returns <code>true</code>. 1396 * </div> 1397 * <!-- end release-specific documentation --> 1398 * @return <code>true</code> if so; <code>false</code> otherwise 1399 * @exception SQLException if a database access error occurs 1400 */ supportsANSI92EntryLevelSQL()1401 public boolean supportsANSI92EntryLevelSQL() throws SQLException { 1402 return true; 1403 } 1404 1405 /** 1406 * Retrieves whether this database supports the ANSI92 intermediate SQL grammar supported. 1407 * 1408 * <!-- start release-specific documentation --> 1409 * <div class="ReleaseSpecificDocumentation"> 1410 * <h3>HSQLDB-Specific Information:</h3> <p> 1411 * 1412 * From 2.0, HSQLDB supports the ANSI92 intermediate SQL grammar; 1413 * this method always returns <code>true</code>. 1414 * <p> 1415 * </div> 1416 * <!-- end release-specific documentation --> 1417 * @return <code>true</code> if so; <code>false</code> otherwise 1418 * @exception SQLException if a database access error occurs 1419 */ supportsANSI92IntermediateSQL()1420 public boolean supportsANSI92IntermediateSQL() throws SQLException { 1421 return true; 1422 } 1423 1424 /** 1425 * Retrieves whether this database supports the ANSI92 full SQL grammar supported. 1426 * 1427 * <!-- start release-specific documentation --> 1428 * <div class="ReleaseSpecificDocumentation"> 1429 * <h3>HSQLDB-Specific Information:</h3> <p> 1430 * 1431 * From 2.0, HSQLDB supports the ANSI92 full SQL grammar. The exceptions, 1432 * such as support for ASSERTION, are not considered grammar issues. 1433 * This method always returns <code>true</code>. <p> 1434 * </div> 1435 * <!-- end release-specific documentation --> 1436 * @return <code>true</code> if so; <code>false</code> otherwise 1437 * @exception SQLException if a database access error occurs 1438 */ supportsANSI92FullSQL()1439 public boolean supportsANSI92FullSQL() throws SQLException { 1440 return true; 1441 } 1442 1443 /** 1444 * Retrieves whether this database supports the SQL Integrity 1445 * Enhancement Facility. 1446 * 1447 * <!-- start release-specific documentation --> 1448 * <div class="ReleaseSpecificDocumentation"> 1449 * <h3>HSQLDB-Specific Information:</h3> <p> 1450 * 1451 * This method always returns <code>true</code>. 1452 * </div> 1453 * <!-- end release-specific documentation --> 1454 * @return <code>true</code> if so; <code>false</code> otherwise 1455 * @exception SQLException if a database access error occurs 1456 */ supportsIntegrityEnhancementFacility()1457 public boolean supportsIntegrityEnhancementFacility() throws SQLException { 1458 return true; 1459 } 1460 1461 /** 1462 * Retrieves whether this database supports some form of outer join. 1463 * 1464 * <!-- start release-specific documentation --> 1465 * <div class="ReleaseSpecificDocumentation"> 1466 * <h3>HSQLDB-Specific Information:</h3> <p> 1467 * 1468 * HSQLDB supports outer joins; this method always returns 1469 * <code>true</code>. 1470 * </div> 1471 * <!-- end release-specific documentation --> 1472 * 1473 * 1474 * @return <code>true</code> if so; <code>false</code> otherwise 1475 * @exception SQLException if a database access error occurs 1476 */ supportsOuterJoins()1477 public boolean supportsOuterJoins() throws SQLException { 1478 return true; 1479 } 1480 1481 /** 1482 * Retrieves whether this database supports full nested outer joins. 1483 * 1484 * <!-- start release-specific documentation --> 1485 * <div class="ReleaseSpecificDocumentation"> 1486 * <h3>HSQLDB-Specific Information:</h3> <p> 1487 * 1488 * From 2.0, HSQLDB supports full nested outer 1489 * joins; this method always returns <code>true</code>. <p> 1490 * </div> 1491 * <!-- end release-specific documentation --> 1492 * @return <code>true</code> if so; <code>false</code> otherwise 1493 * @exception SQLException if a database access error occurs 1494 */ supportsFullOuterJoins()1495 public boolean supportsFullOuterJoins() throws SQLException { 1496 return true; 1497 } 1498 1499 /** 1500 * Retrieves whether this database provides limited support for outer 1501 * joins. (This will be <code>true</code> if the method 1502 * <code>supportsFullOuterJoins</code> returns <code>true</code>). 1503 * 1504 * <!-- start release-specific documentation --> 1505 * <div class="ReleaseSpecificDocumentation"> 1506 * <h3>HSQLDB-Specific Information:</h3> <p> 1507 * 1508 * HSQLDB supports the LEFT OUTER join syntax; 1509 * this method always returns <code>true</code>. 1510 * </div> 1511 * <!-- end release-specific documentation --> 1512 * @return <code>true</code> if so; <code>false</code> otherwise 1513 * @exception SQLException if a database access error occurs 1514 */ supportsLimitedOuterJoins()1515 public boolean supportsLimitedOuterJoins() throws SQLException { 1516 return true; 1517 } 1518 1519 /** 1520 * Retrieves the database vendor's preferred term for "schema". 1521 * 1522 * <!-- start release-specific documentation --> 1523 * <div class="ReleaseSpecificDocumentation"> 1524 * <h3>HSQLDB-Specific Information:</h3> <p> 1525 * 1526 * Starting with 1.8.0, HSQLDB supports schemas. 1527 * </div> 1528 * <!-- end release-specific documentation --> 1529 * @return the vendor term for "schema" 1530 * @exception SQLException if a database access error occurs 1531 */ getSchemaTerm()1532 public String getSchemaTerm() throws SQLException { 1533 return "SCHEMA"; 1534 } 1535 1536 /** 1537 * Retrieves the database vendor's preferred term for "procedure". 1538 * 1539 * <!-- start release-specific documentation --> 1540 * <div class="ReleaseSpecificDocumentation"> 1541 * <h3>HSQLDB-Specific Information:</h3> <p> 1542 * 1543 * From 2.0, HSQLDB supports declaration of 1544 * functions or procedures directly in SQL.<p> 1545 * </div> 1546 * <!-- end release-specific documentation --> 1547 * @return the vendor term for "procedure" 1548 * @exception SQLException if a database access error occurs 1549 */ getProcedureTerm()1550 public String getProcedureTerm() throws SQLException { 1551 return "PROCEDURE"; 1552 } 1553 1554 /** 1555 * Retrieves the database vendor's preferred term for "catalog". 1556 * 1557 * <!-- start release-specific documentation --> 1558 * <div class="ReleaseSpecificDocumentation"> 1559 * <h3>HSQLDB-Specific Information:</h3> <p> 1560 * 1561 * HSQLDB uses the standard name CATALOG. 1562 * </div> 1563 * <!-- end release-specific documentation --> 1564 * 1565 * @return the vendor term for "catalog" 1566 * @exception SQLException if a database access error occurs 1567 */ getCatalogTerm()1568 public String getCatalogTerm() throws SQLException { 1569 return "CATALOG"; 1570 } 1571 1572 /** 1573 * Retrieves whether a catalog appears at the start of a fully qualified 1574 * table name. If not, the catalog appears at the end. 1575 * 1576 * <!-- start release-specific documentation --> 1577 * <div class="ReleaseSpecificDocumentation"> 1578 * <h3>HSQLDB-Specific Information:</h3> <p> 1579 * 1580 * When allowed, a catalog appears at the start of a fully qualified 1581 * table name; this method always returns <code>true</code>. 1582 * </div> 1583 * <!-- end release-specific documentation --> 1584 * @return <code>true</code> if the catalog name appears at the beginning 1585 * of a fully qualified table name; <code>false</code> otherwise 1586 * @exception SQLException if a database access error occurs 1587 */ isCatalogAtStart()1588 public boolean isCatalogAtStart() throws SQLException { 1589 return true; 1590 } 1591 1592 /** 1593 * Retrieves the <code>String</code> that this database uses as the 1594 * separator between a catalog and table name. 1595 * 1596 * <!-- start release-specific documentation --> 1597 * <div class="ReleaseSpecificDocumentation"> 1598 * <h3>HSQLDB-Specific Information:</h3> <p> 1599 * 1600 * When used, a catalog name is separated with period; 1601 * this method <em>always</em> returns a period 1602 * </div> 1603 * <!-- end release-specific documentation --> 1604 * 1605 * @return the separator string 1606 * @exception SQLException if a database access error occurs 1607 */ getCatalogSeparator()1608 public String getCatalogSeparator() throws SQLException { 1609 return "."; 1610 } 1611 1612 /** 1613 * Retrieves whether a schema name can be used in a data manipulation statement. 1614 * 1615 * <!-- start release-specific documentation --> 1616 * <div class="ReleaseSpecificDocumentation"> 1617 * <h3>HSQLDB-Specific Information:</h3> <p> 1618 * 1619 * From 2.0, HSQLDB supports schemas where allowed by the standard; 1620 * this method always returns <code>true</code>. 1621 * 1622 * </div> 1623 * <!-- end release-specific documentation --> 1624 * @return <code>true</code> if so; <code>false</code> otherwise 1625 * @exception SQLException if a database access error occurs 1626 */ supportsSchemasInDataManipulation()1627 public boolean supportsSchemasInDataManipulation() throws SQLException { 1628 1629 // false for OOo client server compatibility 1630 // otherwise schema name is used by OOo in column references 1631 return !useSchemaDefault; 1632 } 1633 1634 /** 1635 * Retrieves whether a schema name can be used in a procedure call statement. 1636 * 1637 * <!-- start release-specific documentation --> 1638 * <div class="ReleaseSpecificDocumentation"> 1639 * <h3>HSQLDB-Specific Information:</h3> <p> 1640 * 1641 * From 2.0, HSQLDB supports schemas where allowed by the standard; 1642 * this method always returns <code>true</code>. 1643 * </div> 1644 * <!-- end release-specific documentation --> 1645 * @return <code>true</code> if so; <code>false</code> otherwise 1646 * @exception SQLException if a database access error occurs 1647 */ supportsSchemasInProcedureCalls()1648 public boolean supportsSchemasInProcedureCalls() throws SQLException { 1649 1650 // false for OOo client server compatibility 1651 // otherwise schema name is used by OOo in column references 1652 return !useSchemaDefault; 1653 } 1654 1655 /** 1656 * Retrieves whether a schema name can be used in a table definition statement. 1657 * 1658 * <!-- start release-specific documentation --> 1659 * <div class="ReleaseSpecificDocumentation"> 1660 * <h3>HSQLDB-Specific Information:</h3> <p> 1661 * 1662 * From 2.0, HSQLDB supports schemas where allowed by the standard; 1663 * this method always returns <code>true</code>. 1664 * 1665 * </div> 1666 * <!-- end release-specific documentation --> 1667 * @return <code>true</code> if so; <code>false</code> otherwise 1668 * @exception SQLException if a database access error occurs 1669 */ supportsSchemasInTableDefinitions()1670 public boolean supportsSchemasInTableDefinitions() throws SQLException { 1671 1672 // false for OOo client server compatibility 1673 // otherwise schema name is used by OOo in column references 1674 return !useSchemaDefault; 1675 } 1676 1677 /** 1678 * Retrieves whether a schema name can be used in an index definition statement. 1679 * 1680 * <!-- start release-specific documentation --> 1681 * <div class="ReleaseSpecificDocumentation"> 1682 * <h3>HSQLDB-Specific Information:</h3> <p> 1683 * 1684 * From 2.0, HSQLDB supports schemas where allowed by the standard; 1685 * this method always returns <code>true</code>. 1686 * 1687 * </div> 1688 * <!-- end release-specific documentation --> 1689 * @return <code>true</code> if so; <code>false</code> otherwise 1690 * @exception SQLException if a database access error occurs 1691 */ supportsSchemasInIndexDefinitions()1692 public boolean supportsSchemasInIndexDefinitions() throws SQLException { 1693 1694 // false for OOo client server compatibility 1695 // otherwise schema name is used by OOo in column references 1696 return !useSchemaDefault; 1697 } 1698 1699 /** 1700 * Retrieves whether a schema name can be used in a privilege definition statement. 1701 * 1702 * <!-- start release-specific documentation --> 1703 * <div class="ReleaseSpecificDocumentation"> 1704 * <h3>HSQLDB-Specific Information:</h3> <p> 1705 * 1706 * From 2.0, HSQLDB supports schemas where allowed by the standard; 1707 * this method always returns <code>true</code>. 1708 * 1709 * </div> 1710 * <!-- end release-specific documentation --> 1711 * @return <code>true</code> if so; <code>false</code> otherwise 1712 * @exception SQLException if a database access error occurs 1713 */ supportsSchemasInPrivilegeDefinitions()1714 public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException { 1715 1716 // false for OOo client server compatibility 1717 // otherwise schema name is used by OOo in column references 1718 return !useSchemaDefault; 1719 } 1720 1721 /** 1722 * Retrieves whether a catalog name can be used in a data manipulation statement. 1723 * 1724 * <!-- start release-specific documentation --> 1725 * <div class="ReleaseSpecificDocumentation"> 1726 * <h3>HSQLDB-Specific Information:</h3> <p> 1727 * 1728 * From 2.0, HSQLDB supports catalog names where allowed by the standard; 1729 * this method always returns <code>true</code>. 1730 * </div> 1731 * <!-- end release-specific documentation --> 1732 * @return <code>true</code> if so; <code>false</code> otherwise 1733 * @exception SQLException if a database access error occurs 1734 */ supportsCatalogsInDataManipulation()1735 public boolean supportsCatalogsInDataManipulation() throws SQLException { 1736 1737 // false for OOo client server compatibility 1738 // otherwise catalog name is used by OOo in column references 1739 return !useSchemaDefault; 1740 } 1741 1742 /** 1743 * Retrieves whether a catalog name can be used in a procedure call statement. 1744 * 1745 * <!-- start release-specific documentation --> 1746 * <div class="ReleaseSpecificDocumentation"> 1747 * <h3>HSQLDB-Specific Information:</h3> <p> 1748 * 1749 * From 2.0, HSQLDB supports catalog names where allowed by the standard; 1750 * this method always returns <code>true</code>. 1751 * </div> 1752 * <!-- end release-specific documentation --> 1753 * @return <code>true</code> if so; <code>false</code> otherwise 1754 * @exception SQLException if a database access error occurs 1755 */ supportsCatalogsInProcedureCalls()1756 public boolean supportsCatalogsInProcedureCalls() throws SQLException { 1757 1758 // false for OOo client server compatibility 1759 // otherwise catalog name is used by OOo in column references 1760 return !useSchemaDefault; 1761 } 1762 1763 /** 1764 * Retrieves whether a catalog name can be used in a table definition statement. 1765 * 1766 * <!-- start release-specific documentation --> 1767 * <div class="ReleaseSpecificDocumentation"> 1768 * <h3>HSQLDB-Specific Information:</h3> <p> 1769 * 1770 * From 2.0, HSQLDB supports catalog names where allowed by the standard; 1771 * this method always returns <code>true</code>. 1772 * </div> 1773 * <!-- end release-specific documentation --> 1774 * @return <code>true</code> if so; <code>false</code> otherwise 1775 * @exception SQLException if a database access error occurs 1776 */ supportsCatalogsInTableDefinitions()1777 public boolean supportsCatalogsInTableDefinitions() throws SQLException { 1778 1779 // false for OOo client server compatibility 1780 // otherwise catalog name is used by OOo in column references 1781 return !useSchemaDefault; 1782 } 1783 1784 /** 1785 * Retrieves whether a catalog name can be used in an index definition statement. 1786 * 1787 * <!-- start release-specific documentation --> 1788 * <div class="ReleaseSpecificDocumentation"> 1789 * <h3>HSQLDB-Specific Information:</h3> <p> 1790 * 1791 * From 2.0, HSQLDB supports catalog names where allowed by the standard; 1792 * this method always returns <code>true</code>. 1793 * </div> 1794 * <!-- end release-specific documentation --> 1795 * @return <code>true</code> if so; <code>false</code> otherwise 1796 * @exception SQLException if a database access error occurs 1797 */ supportsCatalogsInIndexDefinitions()1798 public boolean supportsCatalogsInIndexDefinitions() throws SQLException { 1799 1800 // false for OOo client server compatibility 1801 // otherwise catalog name is used by OOo in column references 1802 return !useSchemaDefault; 1803 } 1804 1805 /** 1806 * Retrieves whether a catalog name can be used in a privilege definition statement. 1807 * 1808 * <!-- start release-specific documentation --> 1809 * <div class="ReleaseSpecificDocumentation"> 1810 * <h3>HSQLDB-Specific Information:</h3> <p> 1811 * 1812 * From 2.0, HSQLDB supports catalog names where allowed by the standard; 1813 * this method always returns <code>true</code>. 1814 * </div> 1815 * <!-- end release-specific documentation --> 1816 * @return <code>true</code> if so; <code>false</code> otherwise 1817 * @exception SQLException if a database access error occurs 1818 */ supportsCatalogsInPrivilegeDefinitions()1819 public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException { 1820 1821 // false for OOo client server compatibility 1822 // otherwise catalog name is used by OOo in column references 1823 return !useSchemaDefault; 1824 } 1825 1826 /** 1827 * Retrieves whether this database supports positioned <code>DELETE</code> 1828 * statements. 1829 * 1830 * <!-- start release-specific documentation --> 1831 * <div class="ReleaseSpecificDocumentation"> 1832 * <h3>HSQLDB-Specific Information:</h3> <p> 1833 * 1834 * HSQLDB 2.0 supports updatable result sets; 1835 * this method always returns <code>true</code>. 1836 * </div> 1837 * <!-- end release-specific documentation --> 1838 * @return <code>true</code> if so; <code>false</code> otherwise 1839 * @exception SQLException if a database access error occurs 1840 */ supportsPositionedDelete()1841 public boolean supportsPositionedDelete() throws SQLException { 1842 return true; 1843 } 1844 1845 /** 1846 * Retrieves whether this database supports positioned <code>UPDATE</code> 1847 * statements. 1848 * 1849 * <!-- start release-specific documentation --> 1850 * <div class="ReleaseSpecificDocumentation"> 1851 * <h3>HSQLDB-Specific Information:</h3> <p> 1852 * 1853 * HSQLDB 2.0 supports updatable result sets; 1854 * this method always returns <code>true</code>. 1855 * </div> 1856 * <!-- end release-specific documentation --> 1857 * @return <code>true</code> if so; <code>false</code> otherwise 1858 * @exception SQLException if a database access error occurs 1859 */ supportsPositionedUpdate()1860 public boolean supportsPositionedUpdate() throws SQLException { 1861 return true; 1862 } 1863 1864 /** 1865 * Retrieves whether this database supports <code>SELECT FOR UPDATE</code> 1866 * statements. 1867 * 1868 * <!-- start release-specific documentation --> 1869 * <div class="ReleaseSpecificDocumentation"> 1870 * <h3>HSQLDB-Specific Information:</h3> <p> 1871 * 1872 * HSQLDB 2.0 supports updatable result sets; 1873 * this method always returns <code>true</code>. 1874 * </div> 1875 * <!-- end release-specific documentation --> 1876 * @return <code>true</code> if so; <code>false</code> otherwise 1877 * @exception SQLException if a database access error occurs 1878 */ supportsSelectForUpdate()1879 public boolean supportsSelectForUpdate() throws SQLException { 1880 return true; 1881 } 1882 1883 /** 1884 * Retrieves whether this database supports stored procedure calls 1885 * that use the stored procedure escape syntax. 1886 * 1887 * <!-- start release-specific documentation --> 1888 * <div class="ReleaseSpecificDocumentation"> 1889 * <h3>HSQLDB-Specific Information:</h3> <p> 1890 * 1891 * HSQLDB supports calling public static Java methods in the context of SQL 1892 * Stored Procedures; this method always returns <code>true</code>. 1893 * </div> 1894 * <!-- end release-specific documentation --> 1895 * @return <code>true</code> if so; <code>false</code> otherwise 1896 * @exception SQLException if a database access error occurs 1897 * @see JDBCParameterMetaData 1898 * @see JDBCConnection#prepareCall 1899 */ supportsStoredProcedures()1900 public boolean supportsStoredProcedures() throws SQLException { 1901 return true; 1902 } 1903 1904 /** 1905 * Retrieves whether this database supports subqueries in comparison 1906 * expressions. 1907 * 1908 * <!-- start release-specific documentation --> 1909 * <div class="ReleaseSpecificDocumentation"> 1910 * <h3>HSQLDB-Specific Information:</h3> <p> 1911 * 1912 * HSQLDB has always supported subqueries in comparison expressions; 1913 * this method always returns <code>true</code>. 1914 * </div> 1915 * <!-- end release-specific documentation --> 1916 * 1917 * 1918 * @return <code>true</code> if so; <code>false</code> otherwise 1919 * @exception SQLException if a database access error occurs 1920 */ supportsSubqueriesInComparisons()1921 public boolean supportsSubqueriesInComparisons() throws SQLException { 1922 return true; 1923 } 1924 1925 /** 1926 * Retrieves whether this database supports subqueries in 1927 * <code>EXISTS</code> expressions. 1928 * 1929 * <!-- start release-specific documentation --> 1930 * <div class="ReleaseSpecificDocumentation"> 1931 * <h3>HSQLDB-Specific Information:</h3> <p> 1932 * 1933 * HSQLDB has always supported subqueries in <code>EXISTS</code> 1934 * expressions; this method always returns <code>true</code>. 1935 * </div> 1936 * <!-- end release-specific documentation --> 1937 * 1938 * 1939 * @return <code>true</code> if so; <code>false</code> otherwise 1940 * @exception SQLException if a database access error occurs 1941 */ supportsSubqueriesInExists()1942 public boolean supportsSubqueriesInExists() throws SQLException { 1943 return true; 1944 } 1945 1946 /** 1947 * (JDBC4 correction:) 1948 * Retrieves whether this database supports subqueries in 1949 * <code>IN</code> expressions. 1950 * 1951 * <!-- start release-specific documentation --> 1952 * <div class="ReleaseSpecificDocumentation"> 1953 * <h3>HSQLDB-Specific Information:</h3> <p> 1954 * 1955 * HSQLDB has always supported subqueries in <code>IN</code> 1956 * statements; this method always returns <code>true</code>. 1957 * </div> 1958 * <!-- end release-specific documentation --> 1959 * 1960 * 1961 * @return <code>true</code> if so; <code>false</code> otherwise 1962 * @exception SQLException if a database access error occurs 1963 */ supportsSubqueriesInIns()1964 public boolean supportsSubqueriesInIns() throws SQLException { 1965 return true; 1966 } 1967 1968 /** 1969 * Retrieves whether this database supports subqueries in quantified 1970 * expressions. 1971 * 1972 * <!-- start release-specific documentation --> 1973 * <div class="ReleaseSpecificDocumentation"> 1974 * <h3>HSQLDB-Specific Information:</h3> <p> 1975 * 1976 * HSQLDB has always supported subqueries in quantified 1977 * expressions; this method always returns <code>true</code>. 1978 * </div> 1979 * <!-- end release-specific documentation --> 1980 * 1981 * 1982 * @return <code>true</code> if so; <code>false</code> otherwise 1983 * @exception SQLException if a database access error occurs 1984 */ supportsSubqueriesInQuantifieds()1985 public boolean supportsSubqueriesInQuantifieds() throws SQLException { 1986 return true; 1987 } 1988 1989 /** 1990 * Retrieves whether this database supports correlated subqueries. 1991 * 1992 * <!-- start release-specific documentation --> 1993 * <div class="ReleaseSpecificDocumentation"> 1994 * <h3>HSQLDB-Specific Information:</h3> <p> 1995 * 1996 * HSQLDB has always supported correlated subqueries; 1997 * this method always returns <code>true</code>. 1998 * </div> 1999 * <!-- end release-specific documentation --> 2000 * 2001 * 2002 * @return <code>true</code> if so; <code>false</code> otherwise 2003 * @exception SQLException if a database access error occurs 2004 */ supportsCorrelatedSubqueries()2005 public boolean supportsCorrelatedSubqueries() throws SQLException { 2006 return true; 2007 } 2008 2009 /** 2010 * Retrieves whether this database supports SQL <code>UNION</code>. 2011 * 2012 * <!-- start release-specific documentation --> 2013 * <div class="ReleaseSpecificDocumentation"> 2014 * <h3>HSQLDB-Specific Information:</h3> <p> 2015 * 2016 * HSQLDB supports SQL <code>UNION</code>; 2017 * this method always returns <code>true</code>. 2018 * </div> 2019 * <!-- end release-specific documentation --> 2020 * 2021 * 2022 * @return <code>true</code> if so; <code>false</code> otherwise 2023 * @exception SQLException if a database access error occurs 2024 */ supportsUnion()2025 public boolean supportsUnion() throws SQLException { 2026 return true; 2027 } 2028 2029 /** 2030 * Retrieves whether this database supports SQL <code>UNION ALL</code>. 2031 * 2032 * <!-- start release-specific documentation --> 2033 * <div class="ReleaseSpecificDocumentation"> 2034 * <h3>HSQLDB-Specific Information:</h3> <p> 2035 * 2036 * HSQLDB supports SQL <code>UNION ALL</code>; 2037 * this method always returns <code>true</code>. 2038 * </div> 2039 * <!-- end release-specific documentation --> 2040 * 2041 * 2042 * @return <code>true</code> if so; <code>false</code> otherwise 2043 * @exception SQLException if a database access error occurs 2044 */ supportsUnionAll()2045 public boolean supportsUnionAll() throws SQLException { 2046 return true; 2047 } 2048 2049 /** 2050 * Retrieves whether this database supports keeping cursors open 2051 * across commits. 2052 * 2053 * <!-- start release-specific documentation --> 2054 * <div class="ReleaseSpecificDocumentation"> 2055 * <h3>HSQLDB-Specific Information:</h3> <p> 2056 * 2057 * HSQLDB 2.0 supports keeping cursors open across commits. 2058 * This method always returns <code>true</code>. 2059 * </div> 2060 * <!-- end release-specific documentation --> 2061 * @return <code>true</code> if cursors always remain open; 2062 * <code>false</code> if they might not remain open 2063 * @exception SQLException if a database access error occurs 2064 */ supportsOpenCursorsAcrossCommit()2065 public boolean supportsOpenCursorsAcrossCommit() throws SQLException { 2066 return true; 2067 } 2068 2069 /** 2070 * Retrieves whether this database supports keeping cursors open 2071 * across rollbacks. 2072 * 2073 * <!-- start release-specific documentation --> 2074 * <div class="ReleaseSpecificDocumentation"> 2075 * <h3>HSQLDB-Specific Information:</h3> <p> 2076 * 2077 * HSQLDB 2.0 closes open cursors at rollback. 2078 * This method always returns <code>false</code>. 2079 * </div> 2080 * <!-- end release-specific documentation --> 2081 * @return <code>true</code> if cursors always remain open; 2082 * <code>false</code> if they might not remain open 2083 * @exception SQLException if a database access error occurs 2084 */ supportsOpenCursorsAcrossRollback()2085 public boolean supportsOpenCursorsAcrossRollback() throws SQLException { 2086 return false; 2087 } 2088 2089 /** 2090 * Retrieves whether this database supports keeping statements open 2091 * across commits. 2092 * 2093 * <!-- start release-specific documentation --> 2094 * <div class="ReleaseSpecificDocumentation"> 2095 * <h3>HSQLDB-Specific Information:</h3> <p> 2096 * 2097 * HSQLDB supports keeping statements open across commits; 2098 * this method always returns <code>true</code>. 2099 * </div> 2100 * <!-- end release-specific documentation --> 2101 * 2102 * 2103 * @return <code>true</code> if statements always remain open; 2104 * <code>false</code> if they might not remain open 2105 * @exception SQLException if a database access error occurs 2106 */ supportsOpenStatementsAcrossCommit()2107 public boolean supportsOpenStatementsAcrossCommit() throws SQLException { 2108 return true; 2109 } 2110 2111 /** 2112 * Retrieves whether this database supports keeping statements open 2113 * across rollbacks. 2114 * 2115 * <!-- start release-specific documentation --> 2116 * <div class="ReleaseSpecificDocumentation"> 2117 * <h3>HSQLDB-Specific Information:</h3> <p> 2118 * 2119 * HSQLDB supports keeping statements open across rollbacks; 2120 * this method always returns <code>true</code>. 2121 * </div> 2122 * <!-- end release-specific documentation --> 2123 * 2124 * 2125 * @return <code>true</code> if statements always remain open; 2126 * <code>false</code> if they might not remain open 2127 * @exception SQLException if a database access error occurs 2128 */ supportsOpenStatementsAcrossRollback()2129 public boolean supportsOpenStatementsAcrossRollback() throws SQLException { 2130 return true; 2131 } 2132 2133 //---------------------------------------------------------------------- 2134 // The following group of methods exposes various limitations 2135 // based on the target database with the current driver. 2136 // Unless otherwise specified, a result of zero means there is no 2137 // limit, or the limit is not known. 2138 2139 /** 2140 * Retrieves the maximum number of hex characters this database allows in an 2141 * inline binary literal. 2142 * 2143 * <!-- start release-specific documentation --> 2144 * <div class="ReleaseSpecificDocumentation"> 2145 * <h3>HSQLDB-Specific Information:</h3> <p> 2146 * 2147 * HSQLDB does not impose a "known" limit. The limit is subject to 2148 * memory availability; this method always returns <code>0</code>. 2149 * </div> 2150 * <!-- end release-specific documentation --> 2151 * 2152 * 2153 * @return max the maximum length (in hex characters) for a binary literal; 2154 * a result of zero means that there is no limit or the limit 2155 * is not known 2156 * @exception SQLException if a database access error occurs 2157 */ getMaxBinaryLiteralLength()2158 public int getMaxBinaryLiteralLength() throws SQLException { 2159 2160 // hard limit is Integer.MAX_VALUE 2161 return 0; 2162 } 2163 2164 /** 2165 * Retrieves the maximum number of characters this database allows 2166 * for a character literal. 2167 * 2168 * <!-- start release-specific documentation --> 2169 * <div class="ReleaseSpecificDocumentation"> 2170 * <h3>HSQLDB-Specific Information:</h3> <p> 2171 * 2172 * HSQLDB does not impose a "known" limit. The limit is subject to 2173 * memory availability; this method always returns <code>0</code>. 2174 * </div> 2175 * <!-- end release-specific documentation --> 2176 * 2177 * @return the maximum number of characters allowed for a character literal; 2178 * a result of zero means that there is no limit or the limit is 2179 * not known 2180 * @exception SQLException if a database access error occurs 2181 */ getMaxCharLiteralLength()2182 public int getMaxCharLiteralLength() throws SQLException { 2183 return 0; 2184 } 2185 2186 /** 2187 * Retrieves the maximum number of characters this database allows 2188 * for a column name. 2189 * 2190 * <!-- start release-specific documentation --> 2191 * <div class="ReleaseSpecificDocumentation"> 2192 * <h3>HSQLDB-Specific Information:</h3> <p> 2193 * 2194 * Starting with 2.0, HSQLDB implements the SQL standard, which is 128 for 2195 * all names. 2196 * </div> 2197 * <!-- end release-specific documentation --> 2198 * 2199 * @return the maximum number of characters allowed for a column name; 2200 * a result of zero means that there is no limit or the limit 2201 * is not known 2202 * @exception SQLException if a database access error occurs 2203 */ getMaxColumnNameLength()2204 public int getMaxColumnNameLength() throws SQLException { 2205 return 128; 2206 } 2207 2208 /** 2209 * Retrieves the maximum number of columns this database allows in a 2210 * <code>GROUP BY</code> clause. 2211 * 2212 * <!-- start release-specific documentation --> 2213 * <div class="ReleaseSpecificDocumentation"> 2214 * <h3>HSQLDB-Specific Information:</h3> <p> 2215 * 2216 * HSQLDB does not impose a "known" limit. The limit is subject to 2217 * memory availability; this method always returns <code>0</code>. 2218 * </div> 2219 * <!-- end release-specific documentation --> 2220 * 2221 * @return the maximum number of columns allowed; 2222 * a result of zero means that there is no limit or the limit 2223 * is not known 2224 * @exception SQLException if a database access error occurs 2225 */ getMaxColumnsInGroupBy()2226 public int getMaxColumnsInGroupBy() throws SQLException { 2227 return 0; 2228 } 2229 2230 /** 2231 * Retrieves the maximum number of columns this database allows in an index. 2232 * 2233 * <!-- start release-specific documentation --> 2234 * <div class="ReleaseSpecificDocumentation"> 2235 * <h3>HSQLDB-Specific Information:</h3> <p> 2236 * 2237 * HSQLDB does not impose a "known" limit. The limit is subject to 2238 * memory availability; this method always returns <code>0</code>. 2239 * </div> 2240 * <!-- end release-specific documentation --> 2241 * 2242 * @return the maximum number of columns allowed; 2243 * a result of zero means that there is no limit or the limit 2244 * is not known 2245 * @exception SQLException if a database access error occurs 2246 */ getMaxColumnsInIndex()2247 public int getMaxColumnsInIndex() throws SQLException { 2248 return 0; 2249 } 2250 2251 /** 2252 * Retrieves the maximum number of columns this database allows in an 2253 * <code>ORDER BY</code> clause. 2254 * 2255 * <!-- start release-specific documentation --> 2256 * <div class="ReleaseSpecificDocumentation"> 2257 * <h3>HSQLDB-Specific Information:</h3> <p> 2258 * 2259 * HSQLDB does not impose a "known" limit. The limit is subject to 2260 * memory availability; this method always returns <code>0</code>. 2261 * </div> 2262 * <!-- end release-specific documentation --> 2263 * 2264 * @return the maximum number of columns allowed; 2265 * a result of zero means that there is no limit or the limit 2266 * is not known 2267 * @exception SQLException if a database access error occurs 2268 */ getMaxColumnsInOrderBy()2269 public int getMaxColumnsInOrderBy() throws SQLException { 2270 return 0; 2271 } 2272 2273 /** 2274 * Retrieves the maximum number of columns this database allows in a 2275 * <code>SELECT</code> list. 2276 * 2277 * <!-- start release-specific documentation --> 2278 * <div class="ReleaseSpecificDocumentation"> 2279 * <h3>HSQLDB-Specific Information:</h3> <p> 2280 * 2281 * HSQLDB does not impose a "known" limit. The limit is subject to 2282 * memory availability; this method always returns <code>0</code>. 2283 * </div> 2284 * <!-- end release-specific documentation --> 2285 * 2286 * @return the maximum number of columns allowed; 2287 * a result of zero means that there is no limit or the limit 2288 * is not known 2289 * @exception SQLException if a database access error occurs 2290 */ getMaxColumnsInSelect()2291 public int getMaxColumnsInSelect() throws SQLException { 2292 return 0; 2293 } 2294 2295 /** 2296 * Retrieves the maximum number of columns this database allows in a table. 2297 * 2298 * <!-- start release-specific documentation --> 2299 * <div class="ReleaseSpecificDocumentation"> 2300 * <h3>HSQLDB-Specific Information:</h3> <p> 2301 * 2302 * HSQLDB does not impose a "known" limit. The limit is subject to 2303 * memory availability; this method always returns <code>0</code>. 2304 * </div> 2305 * <!-- end release-specific documentation --> 2306 * 2307 * @return the maximum number of columns allowed; 2308 * a result of zero means that there is no limit or the limit 2309 * is not known 2310 * @exception SQLException if a database access error occurs 2311 */ getMaxColumnsInTable()2312 public int getMaxColumnsInTable() throws SQLException { 2313 return 0; 2314 } 2315 2316 /** 2317 * Retrieves the maximum number of concurrent connections to this 2318 * database that are possible. 2319 * 2320 * <!-- start release-specific documentation --> 2321 * <div class="ReleaseSpecificDocumentation"> 2322 * <h3>HSQLDB-Specific Information:</h3> <p> 2323 * 2324 * HSQLDB does not impose a "known" limit. The limit is subject to 2325 * memory availability; this method always returns <code>0</code>. 2326 * </div> 2327 * <!-- end release-specific documentation --> 2328 * 2329 * @return the maximum number of active connections possible at one time; 2330 * a result of zero means that there is no limit or the limit 2331 * is not known 2332 * @exception SQLException if a database access error occurs 2333 */ getMaxConnections()2334 public int getMaxConnections() throws SQLException { 2335 return 0; 2336 } 2337 2338 /** 2339 * Retrieves the maximum number of characters that this database allows in a 2340 * cursor name. 2341 * 2342 * <!-- start release-specific documentation --> 2343 * <div class="ReleaseSpecificDocumentation"> 2344 * <h3>HSQLDB-Specific Information:</h3> <p> 2345 * 2346 * Starting with 2.0, HSQLDB implements the SQL standard, which is 128 for 2347 * all names. 2348 * </div> 2349 * <!-- end release-specific documentation --> 2350 * 2351 * @return the maximum number of characters allowed in a cursor name; 2352 * a result of zero means that there is no limit or the limit 2353 * is not known 2354 * @exception SQLException if a database access error occurs 2355 */ getMaxCursorNameLength()2356 public int getMaxCursorNameLength() throws SQLException { 2357 return 128; 2358 } 2359 2360 /** 2361 * Retrieves the maximum number of bytes this database allows for an 2362 * index, including all of the parts of the index. 2363 * 2364 * <!-- start release-specific documentation --> 2365 * <div class="ReleaseSpecificDocumentation"> 2366 * <h3>HSQLDB-Specific Information:</h3> <p> 2367 * 2368 * HSQLDB does not impose a "known" limit. The limit is subject to 2369 * memory and disk availability; this method always returns <code>0</code>. 2370 * </div> 2371 * <!-- end release-specific documentation --> 2372 * 2373 * @return the maximum number of bytes allowed; this limit includes the 2374 * composite of all the constituent parts of the index; 2375 * a result of zero means that there is no limit or the limit 2376 * is not known 2377 * @exception SQLException if a database access error occurs 2378 */ getMaxIndexLength()2379 public int getMaxIndexLength() throws SQLException { 2380 return 0; 2381 } 2382 2383 /** 2384 * Retrieves the maximum number of characters that this database allows in a 2385 * schema name. 2386 * 2387 * <!-- start release-specific documentation --> 2388 * <div class="ReleaseSpecificDocumentation"> 2389 * <h3>HSQLDB-Specific Information:</h3> <p> 2390 * 2391 * Starting with 2.0, HSQLDB implements the SQL standard, which is 128 for 2392 * all names. 2393 * </div> 2394 * <!-- end release-specific documentation --> 2395 * @return the maximum number of characters allowed in a schema name; 2396 * a result of zero means that there is no limit or the limit 2397 * is not known 2398 * @exception SQLException if a database access error occurs 2399 */ getMaxSchemaNameLength()2400 public int getMaxSchemaNameLength() throws SQLException { 2401 return 128; 2402 } 2403 2404 /** 2405 * Retrieves the maximum number of characters that this database allows in a 2406 * procedure name. 2407 * 2408 * <!-- start release-specific documentation --> 2409 * <div class="ReleaseSpecificDocumentation"> 2410 * <h3>HSQLDB-Specific Information:</h3> <p> 2411 * 2412 * Starting with 2.0, HSQLDB implements the SQL standard, which is 128 for 2413 * all names. 2414 * </div> 2415 * <!-- end release-specific documentation --> 2416 * 2417 * @return the maximum number of characters allowed in a procedure name; 2418 * a result of zero means that there is no limit or the limit 2419 * is not known 2420 * @exception SQLException if a database access error occurs 2421 */ getMaxProcedureNameLength()2422 public int getMaxProcedureNameLength() throws SQLException { 2423 return 128; 2424 } 2425 2426 /** 2427 * Retrieves the maximum number of characters that this database allows in a 2428 * catalog name. 2429 * 2430 * <!-- start release-specific documentation --> 2431 * <div class="ReleaseSpecificDocumentation"> 2432 * <h3>HSQLDB-Specific Information:</h3> <p> 2433 * 2434 * Starting with 2.0, HSQLDB implements the SQL standard, which is 128 for 2435 * all names. 2436 * </div> 2437 * <!-- end release-specific documentation --> 2438 * 2439 * @return the maximum number of characters allowed in a catalog name; 2440 * a result of zero means that there is no limit or the limit 2441 * is not known 2442 * @exception SQLException if a database access error occurs 2443 */ getMaxCatalogNameLength()2444 public int getMaxCatalogNameLength() throws SQLException { 2445 return 128; 2446 } 2447 2448 /** 2449 * Retrieves the maximum number of bytes this database allows in 2450 * a single row. 2451 * 2452 * <!-- start release-specific documentation --> 2453 * <div class="ReleaseSpecificDocumentation"> 2454 * <h3>HSQLDB-Specific Information:</h3> <p> 2455 * 2456 * HSQLDB does not impose a "known" limit. The limit is subject to 2457 * memory and disk availability; this method always returns <code>0</code>. 2458 * </div> 2459 * <!-- end release-specific documentation --> 2460 * 2461 * @return the maximum number of bytes allowed for a row; a result of 2462 * zero means that there is no limit or the limit is not known 2463 * @exception SQLException if a database access error occurs 2464 */ getMaxRowSize()2465 public int getMaxRowSize() throws SQLException { 2466 return 0; 2467 } 2468 2469 /** 2470 * Retrieves whether the return value for the method 2471 * <code>getMaxRowSize</code> includes the SQL data types 2472 * <code>LONGVARCHAR</code> and <code>LONGVARBINARY</code>. 2473 * 2474 * <!-- start release-specific documentation --> 2475 * <div class="ReleaseSpecificDocumentation"> 2476 * <h3>HSQLDB-Specific Information:</h3><p> 2477 * 2478 * Including 2.0, {@link #getMaxRowSize} <em>always</em> returns 2479 * 0, indicating that the maximum row size is unknown or has no limit. 2480 * This applies to the above types as well; this method <em>always</em> 2481 * returns <code>true</code>. 2482 * </div> 2483 * <!-- end release-specific documentation --> 2484 * 2485 * 2486 * @return <code>true</code> if so; <code>false</code> otherwise 2487 * @exception SQLException if a database access error occurs 2488 */ doesMaxRowSizeIncludeBlobs()2489 public boolean doesMaxRowSizeIncludeBlobs() throws SQLException { 2490 return true; 2491 } 2492 2493 /** 2494 * Retrieves the maximum number of characters this database allows in 2495 * an SQL statement. 2496 * 2497 * <!-- start release-specific documentation --> 2498 * <div class="ReleaseSpecificDocumentation"> 2499 * <h3>HSQLDB-Specific Information:</h3> <p> 2500 * 2501 * HSQLDB does not impose a "known" limit. The limit is subject to 2502 * memory availability; this method always returns <code>0</code>. 2503 * </div> 2504 * <!-- end release-specific documentation --> 2505 * 2506 * @return the maximum number of characters allowed for an SQL statement; 2507 * a result of zero means that there is no limit or the limit 2508 * is not known 2509 * @exception SQLException if a database access error occurs 2510 */ getMaxStatementLength()2511 public int getMaxStatementLength() throws SQLException { 2512 return 0; 2513 } 2514 2515 /** 2516 * Retrieves the maximum number of active statements to this database 2517 * that can be open at the same time. 2518 * 2519 * <!-- start release-specific documentation --> 2520 * <div class="ReleaseSpecificDocumentation"> 2521 * <h3>HSQLDB-Specific Information:</h3> <p> 2522 * 2523 * HSQLDB does not impose a "known" limit. The limit is subject to 2524 * memory availability; this method always returns <code>0</code>. 2525 * </div> 2526 * <!-- end release-specific documentation --> 2527 * 2528 * @return the maximum number of statements that can be open at one time; 2529 * a result of zero means that there is no limit or the limit 2530 * is not known 2531 * @exception SQLException if a database access error occurs 2532 */ getMaxStatements()2533 public int getMaxStatements() throws SQLException { 2534 return 0; 2535 } 2536 2537 /** 2538 * Retrieves the maximum number of characters this database allows in 2539 * a table name. 2540 * 2541 * <!-- start release-specific documentation --> 2542 * <div class="ReleaseSpecificDocumentation"> 2543 * <h3>HSQLDB-Specific Information:</h3> <p> 2544 * 2545 * Up to and including 1.8.0.x, HSQLDB did not impose a "known" limit. Th 2546 * hard limit was the maximum length of a java.lang.String 2547 * (java.lang.Integer.MAX_VALUE); this method always returned 2548 * <code>0</code>. 2549 * 2550 * Starting with 2.0, HSQLDB implements the SQL standard, which is 128 for 2551 * all names. 2552 * </div> 2553 * <!-- end release-specific documentation --> 2554 * 2555 * @return the maximum number of characters allowed for a table name; 2556 * a result of zero means that there is no limit or the limit 2557 * is not known 2558 * @exception SQLException if a database access error occurs 2559 */ getMaxTableNameLength()2560 public int getMaxTableNameLength() throws SQLException { 2561 return 128; 2562 } 2563 2564 /** 2565 * Retrieves the maximum number of tables this database allows in a 2566 * <code>SELECT</code> statement. 2567 * 2568 * <!-- start release-specific documentation --> 2569 * <div class="ReleaseSpecificDocumentation"> 2570 * <h3>HSQLDB-Specific Information:</h3> <p> 2571 * 2572 * HSQLDB does not impose a "known" limit. The limit is subject to 2573 * memory availability; this method always returns <code>0</code>. 2574 * </div> 2575 * <!-- end release-specific documentation --> 2576 * 2577 * @return the maximum number of tables allowed in a <code>SELECT</code> 2578 * statement; a result of zero means that there is no limit or 2579 * the limit is not known 2580 * @exception SQLException if a database access error occurs 2581 */ getMaxTablesInSelect()2582 public int getMaxTablesInSelect() throws SQLException { 2583 return 0; 2584 } 2585 2586 /** 2587 * Retrieves the maximum number of characters this database allows in 2588 * a user name. 2589 * 2590 * <!-- start release-specific documentation --> 2591 * <div class="ReleaseSpecificDocumentation"> 2592 * <h3>HSQLDB-Specific Information:</h3> <p> 2593 * 2594 * Starting with 2.0, HSQLDB implements the SQL standard, which is 128 for 2595 * all names. 2596 * </div> 2597 * <!-- end release-specific documentation --> 2598 * 2599 * @return the maximum number of characters allowed for a user name; 2600 * a result of zero means that there is no limit or the limit 2601 * is not known 2602 * @exception SQLException if a database access error occurs 2603 */ getMaxUserNameLength()2604 public int getMaxUserNameLength() throws SQLException { 2605 return 128; 2606 } 2607 2608 //---------------------------------------------------------------------- 2609 2610 /** 2611 * Retrieves this database's default transaction isolation level. The 2612 * possible values are defined in <code>java.sql.Connection</code>. 2613 * 2614 * <!-- start release-specific documentation --> 2615 * <div class="ReleaseSpecificDocumentation"> 2616 * <h3>HSQLDB-Specific Information</h3> 2617 * 2618 * Default isolation mode in version 2.0 is TRANSACTION_READ_COMMITTED. 2619 * </div> 2620 * <!-- end release-specific documentation --> 2621 * 2622 * @return the default isolation level 2623 * @exception SQLException if a database access error occurs 2624 * @see JDBCConnection 2625 */ getDefaultTransactionIsolation()2626 public int getDefaultTransactionIsolation() throws SQLException { 2627 2628 ResultSet rs = execute("CALL DATABASE_ISOLATION_LEVEL()"); 2629 2630 rs.next(); 2631 2632 String result = rs.getString(1); 2633 2634 rs.close(); 2635 2636 if (result.startsWith("READ COMMITTED")) { 2637 return Connection.TRANSACTION_READ_COMMITTED; 2638 } 2639 2640 if (result.startsWith("READ UNCOMMITTED")) { 2641 return Connection.TRANSACTION_READ_UNCOMMITTED; 2642 } 2643 2644 if (result.startsWith("SERIALIZABLE")) { 2645 return Connection.TRANSACTION_SERIALIZABLE; 2646 } 2647 2648 return Connection.TRANSACTION_READ_COMMITTED; 2649 } 2650 2651 /** 2652 * Retrieves whether this database supports transactions. If not, invoking the 2653 * method <code>commit</code> is a noop, and the isolation level is 2654 * <code>TRANSACTION_NONE</code>. 2655 * 2656 * <!-- start release-specific documentation --> 2657 * <div class="ReleaseSpecificDocumentation"> 2658 * <h3>HSQLDB-Specific Information:</h3> <p> 2659 * 2660 * HSQLDB supports transactions; 2661 * this method always returns <code>true</code>. 2662 * </div> 2663 * <!-- end release-specific documentation --> 2664 * @return <code>true</code> if transactions are supported; 2665 * <code>false</code> otherwise 2666 * @exception SQLException if a database access error occurs 2667 */ supportsTransactions()2668 public boolean supportsTransactions() throws SQLException { 2669 return true; 2670 } 2671 2672 /** @todo update javadoc */ 2673 2674 /** 2675 * Retrieves whether this database supports the given transaction isolation level. 2676 * 2677 * <!-- start release-specific documentation --> 2678 * <div class="ReleaseSpecificDocumentation"> 2679 * <h3>HSQLDB-Specific Information</h3> 2680 * HSQLDB supports all levels. 2681 * </div> 2682 * <!-- end release-specific documentation --> 2683 * 2684 * 2685 * @param level one of the transaction isolation levels defined in 2686 * <code>java.sql.Connection</code> 2687 * @return <code>true</code> if so; <code>false</code> otherwise 2688 * @exception SQLException if a database access error occurs 2689 * @see JDBCConnection 2690 */ supportsTransactionIsolationLevel( int level)2691 public boolean supportsTransactionIsolationLevel( 2692 int level) throws SQLException { 2693 2694 return level == Connection.TRANSACTION_READ_UNCOMMITTED 2695 || level == Connection.TRANSACTION_READ_COMMITTED 2696 || level == Connection.TRANSACTION_REPEATABLE_READ 2697 || level == Connection.TRANSACTION_SERIALIZABLE; 2698 } 2699 2700 /** 2701 * Retrieves whether this database supports both data definition and 2702 * data manipulation statements within a transaction. 2703 * 2704 * <!-- start release-specific documentation --> 2705 * <div class="ReleaseSpecificDocumentation"> 2706 * <h3>HSQLDB-Specific Information:</h3> <p> 2707 * 2708 * HSQLDB does not support a mix of both data definition and 2709 * data manipulation statements within a transaction. DDL commits the 2710 * current transaction before proceeding; 2711 * this method always returns <code>false</code>. 2712 * </div> 2713 * <!-- end release-specific documentation --> 2714 * 2715 * 2716 * @return <code>true</code> if so; <code>false</code> otherwise 2717 * @exception SQLException if a database access error occurs 2718 */ supportsDataDefinitionAndDataManipulationTransactions()2719 public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException { 2720 return false; 2721 } 2722 2723 /** 2724 * Retrieves whether this database supports only data manipulation 2725 * statements within a transaction. 2726 * 2727 * <!-- start release-specific documentation --> 2728 * <div class="ReleaseSpecificDocumentation"> 2729 * <h3>HSQLDB-Specific Information:</h3> <p> 2730 * 2731 * HSQLDB supports only data manipulation 2732 * statements within a transaction. DDL commits the 2733 * current transaction before proceeding, while DML does not; 2734 * this method always returns <code>true</code>. 2735 * </div> 2736 * <!-- end release-specific documentation --> 2737 * 2738 * 2739 * @return <code>true</code> if so; <code>false</code> otherwise 2740 * @exception SQLException if a database access error occurs 2741 */ supportsDataManipulationTransactionsOnly()2742 public boolean supportsDataManipulationTransactionsOnly() throws SQLException { 2743 return true; 2744 } 2745 2746 /** 2747 * Retrieves whether a data definition statement within a transaction forces 2748 * the transaction to commit. 2749 * 2750 * <!-- start release-specific documentation --> 2751 * <div class="ReleaseSpecificDocumentation"> 2752 * <h3>HSQLDB-Specific Information:</h3> <p> 2753 * 2754 * Including 2.0, a data definition statement within a transaction forces 2755 * the transaction to commit; this method always returns <code>true</code>. 2756 * </div> 2757 * <!-- end release-specific documentation --> 2758 * 2759 * 2760 * @return <code>true</code> if so; <code>false</code> otherwise 2761 * @exception SQLException if a database access error occurs 2762 */ dataDefinitionCausesTransactionCommit()2763 public boolean dataDefinitionCausesTransactionCommit() throws SQLException { 2764 return true; 2765 } 2766 2767 /** 2768 * Retrieves whether this database ignores a data definition statement 2769 * within a transaction. 2770 * 2771 * <!-- start release-specific documentation --> 2772 * <div class="ReleaseSpecificDocumentation"> 2773 * <h3>HSQLDB-Specific Information:</h3> <p> 2774 * 2775 * Including 2.0, a data definition statement is not ignored within a 2776 * transaction. Rather, a data definition statement within a 2777 * transaction forces the transaction to commit; this method 2778 * <em>always</em> returns <code>false</code>. 2779 * </div> 2780 * <!-- end release-specific documentation --> 2781 * 2782 * 2783 * @return <code>true</code> if so; <code>false</code> otherwise 2784 * @exception SQLException if a database access error occurs 2785 */ dataDefinitionIgnoredInTransactions()2786 public boolean dataDefinitionIgnoredInTransactions() throws SQLException { 2787 return false; 2788 } 2789 2790 /** 2791 * Retrieves a description of the stored procedures available in the given 2792 * catalog. 2793 * <P> 2794 * Only procedure descriptions matching the schema and 2795 * procedure name criteria are returned. They are ordered by 2796 * JDBC 4.1[<code>PROCEDURE_CAT</code>,] <code>PROCEDURE_SCHEM</code>, 2797 * <code>PROCEDURE_NAME</code> and (new to JDBC4)[<code>SPECIFIC_ NAME</code>]. 2798 * 2799 * <P>Each procedure description has the the following columns: 2800 * <OL> 2801 * <LI><B>PROCEDURE_CAT</B> String => procedure catalog (may be <code>null</code>) 2802 * <LI><B>PROCEDURE_SCHEM</B> String => procedure schema (may be <code>null</code>) 2803 * <LI><B>PROCEDURE_NAME</B> String => procedure name 2804 * <LI> reserved for future use 2805 * (HSQLDB-specific: NUM_INPUT_PARAMS) 2806 * <LI> reserved for future use 2807 * (HSQLDB-specific: NUM_OUTPUT_PARAMS) 2808 * <LI> reserved for future use 2809 * (HSQLDB-specific: NUM_RESULT_SETS) 2810 * <LI><B>REMARKS</B> String => explanatory comment on the procedure 2811 * <LI><B>PROCEDURE_TYPE</B> short => kind of procedure: 2812 * <UL> 2813 * <LI> procedureResultUnknown - (JDBC4 clarification:) Cannot determine if a return value 2814 * will be returned 2815 * <LI> procedureNoResult - (JDBC4 clarification:) Does not return a return value 2816 * <LI> procedureReturnsResult - (JDBC4 clarification:) Returns a return value 2817 * </UL> 2818 * <LI><B>SPECIFIC_NAME</B> String => (JDBC4 new:) The name which uniquely identifies this 2819 * procedure within its schema. 2820 * </OL> 2821 * <p> 2822 * A user may not have permissions to execute any of the procedures that are 2823 * returned by <code>getProcedures</code> 2824 * 2825 * <!-- start release-specific documentation --> 2826 * <div class="ReleaseSpecificDocumentation"> 2827 * <h3>HSQLDB-Specific Information:</h3> <p> 2828 * 2829 * HSQLDB supports the SQL Standard. It treats unquoted identifiers as 2830 * case insensitive in SQL and stores 2831 * them in upper case; it treats quoted identifiers as case sensitive and 2832 * stores them verbatim. All JDBCDatabaseMetaData methods perform 2833 * case-sensitive comparison between name (pattern) arguments and the 2834 * corresponding identifier values as they are stored in the database. 2835 * Therefore, care must be taken to specify name arguments precisely 2836 * (including case) as they are stored in the database. <p> 2837 * 2838 * In version 1.9, the rows returned by this method are based on rows in 2839 * the INFORMATION_SCHEMA.ROUTINES table. 2840 * </div> 2841 * <!-- end release-specific documentation --> 2842 * 2843 * @param catalog a catalog name; must match the catalog name as it 2844 * is stored in the database; "" retrieves those without a catalog; 2845 * <code>null</code> means that the catalog name should not be used to narrow 2846 * the search 2847 * @param schemaPattern a schema name pattern; must match the schema name 2848 * as it is stored in the database; "" retrieves those without a schema; 2849 * <code>null</code> means that the schema name should not be used to narrow 2850 * the search 2851 * @param procedureNamePattern a procedure name pattern; must match the 2852 * procedure name as it is stored in the database 2853 * @return <code>ResultSet</code> - each row is a procedure description 2854 * @exception SQLException if a database access error occurs 2855 * @see #getSearchStringEscape 2856 */ getProcedures( String catalog, String schemaPattern, String procedureNamePattern)2857 public ResultSet getProcedures( 2858 String catalog, String schemaPattern, 2859 String procedureNamePattern) throws SQLException { 2860 2861 if (wantsIsNull(procedureNamePattern)) { 2862 return executeSelect("SYSTEM_PROCEDURES", "0=1"); 2863 } 2864 catalog = translateCatalog(catalog); 2865 schemaPattern = translateSchema(schemaPattern); 2866 2867 StringBuffer select = 2868 toQueryPrefix("SYSTEM_PROCEDURES").append(and("PROCEDURE_CAT", 2869 "=", catalog)).append(and("PROCEDURE_SCHEM", "LIKE", 2870 schemaPattern)).append(and("PROCEDURE_NAME", "LIKE", 2871 procedureNamePattern)); 2872 2873 // By default, query already returns the result ordered by 2874 // PROCEDURE_SCHEM, PROCEDURE_NAME... 2875 return execute(select.toString()); 2876 } 2877 2878 /** 2879 * Indicates that it is not known whether the procedure returns 2880 * a result. 2881 * <P> 2882 * A possible value for column <code>PROCEDURE_TYPE</code> in the 2883 * <code>ResultSet</code> object returned by the method 2884 * <code>getProcedures</code>. 2885 */ 2886 2887 // int procedureResultUnknown = 0; 2888 2889 /** 2890 * Indicates that the procedure does not return a result. 2891 * <P> 2892 * A possible value for column <code>PROCEDURE_TYPE</code> in the 2893 * <code>ResultSet</code> object returned by the method 2894 * <code>getProcedures</code>. 2895 */ 2896 // int procedureNoResult = 1; 2897 2898 /** 2899 * Indicates that the procedure returns a result. 2900 * <P> 2901 * A possible value for column <code>PROCEDURE_TYPE</code> in the 2902 * <code>ResultSet</code> object returned by the method 2903 * <code>getProcedures</code>. 2904 */ 2905 // int procedureReturnsResult = 2; 2906 2907 /** 2908 * Retrieves a description of the given catalog's stored procedure parameter 2909 * and result columns. 2910 * 2911 * <P>Only descriptions matching the schema, procedure and 2912 * parameter name criteria are returned. They are ordered by 2913 * JDBC 4.1[PROCEDURE_CAT,] PROCEDURE_SCHEM, PROCEDURE_NAME and SPECIFIC_NAME. Within this, the return value, 2914 * if any, is first. Next are the parameter descriptions in call 2915 * order. The column descriptions follow in column number order. 2916 * 2917 * <P>Each row in the <code>ResultSet</code> is a parameter description or 2918 * column description with the following fields: 2919 * <OL> 2920 * <LI><B>PROCEDURE_CAT</B> String => procedure catalog (may be <code>null</code>) 2921 * <LI><B>PROCEDURE_SCHEM</B> String => procedure schema (may be <code>null</code>) 2922 * <LI><B>PROCEDURE_NAME</B> String => procedure name 2923 * <LI><B>COLUMN_NAME</B> String => column/parameter name 2924 * <LI><B>COLUMN_TYPE</B> Short => kind of column/parameter: 2925 * <UL> 2926 * <LI> procedureColumnUnknown - nobody knows 2927 * <LI> procedureColumnIn - IN parameter 2928 * <LI> procedureColumnInOut - INOUT parameter 2929 * <LI> procedureColumnOut - OUT parameter 2930 * <LI> procedureColumnReturn - procedure return value 2931 * <LI> procedureColumnResult - result column in <code>ResultSet</code> 2932 * </UL> 2933 * <LI><B>DATA_TYPE</B> int => SQL type from java.sql.Types 2934 * <LI><B>TYPE_NAME</B> String => SQL type name, for a UDT type the 2935 * type name is fully qualified 2936 * <LI><B>PRECISION</B> int => precision 2937 * <LI><B>LENGTH</B> int => length in bytes of data 2938 * <LI><B>SCALE</B> short => scale - null is returned for data types where 2939 * SCALE is not applicable. 2940 * <LI><B>RADIX</B> short => radix 2941 * <LI><B>NULLABLE</B> short => can it contain NULL. 2942 * <UL> 2943 * <LI> procedureNoNulls - does not allow NULL values 2944 * <LI> procedureNullable - allows NULL values 2945 * <LI> procedureNullableUnknown - nullability unknown 2946 * </UL> 2947 * <LI><B>REMARKS</B> String => comment describing parameter/column 2948 * <LI><B>COLUMN_DEF</B> String => default value for the column, which should be interpreted as a string when the value is enclosed in single quotes (may be <code>null</code>) 2949 * <UL> 2950 * <LI> The string NULL (not enclosed in quotes) - if NULL was specified as the default value 2951 * <LI> TRUNCATE (not enclosed in quotes) - if the specified default value cannot be represented without truncation 2952 * <LI> NULL - if a default value was not specified 2953 * </UL> 2954 * <LI><B>SQL_DATA_TYPE</B> int => (JDBC4 new:) Reserved for future use 2955 * 2956 * <p>HSQLDB-specific: CLI type from SQL 2003 Table 37, 2957 * tables 6-9 Annex A1, and/or addenda in other 2958 * documents, such as:<br> 2959 * SQL 2003 Part 9: Management of External Data (SQL/MED) : DATALINK<br> 2960 * SQL 2003 Part 14: XML-Related Specifications (SQL/XML) : XML<p> 2961 * 2962 * <LI><B>SQL_DATETIME_SUB</B> int => (JDBC4 new:) reserved for future use 2963 * 2964 * <p>HSQLDB-specific: CLI SQL_DATETIME_SUB from SQL 2003 Table 37 2965 * 2966 * <LI><B>CHAR_OCTET_LENGTH</B> int => (JDBC4 new:) the maximum length of binary and character based columns. For any other datatype the returned value is a 2967 * NULL 2968 * <LI><B>ORDINAL_POSITION</B> int => (JDBC4 new:) the ordinal position, starting from 1, for the input and output parameters for a procedure. A value of 0 2969 * is returned if this row describes the procedure's return value. JDBC 4.1[For result set columns, it is the 2970 * ordinal position of the column in the result set starting from 1. If there are 2971 * multiple result sets, the column ordinal positions are implementation 2972 * defined.] 2973 * <LI><B>IS_NULLABLE</B> String => ISO rules are used to determine the nullability for a column. 2974 * <UL> 2975 * <LI> YES --- if the parameter or result column can include NULLs 2976 * <LI> NO --- if the parameter or result column cannot include NULLs 2977 * <LI> empty string --- if the nullability for the 2978 * parameter or result column is unknown 2979 * </UL> 2980 * <LI><B>SPECIFIC_NAME</B> String => (JDBC4 new:) the name which uniquely identifies this procedure within its schema. 2981 * </OL> 2982 * 2983 * <P><B>Note:</B> Some databases may not return the column 2984 * descriptions for a procedure. Additional columns beyond (JDBC4 modified:) 2985 * SPECIFIC_NAME can be defined by the database and must be accessed by their <B>column name</B>. 2986 * 2987 * <p>(JDBC4 clarification:) 2988 * <p>The PRECISION column represents the specified column size for the given column. 2989 * For numeric data, this is the maximum precision. For character data, this is the [declared or implicit maximum] length in characters. 2990 * For datetime datatypes, this is the [maximum] length in characters of the String representation (assuming the 2991 * maximum allowed precision of the fractional seconds component). For binary data, this is the [maximum] length in bytes. For the ROWID datatype, 2992 * this is the length in bytes[, as returned by the implementation-specific java.sql.RowId.getBytes() method]. JDBC 4.1 Deleted[0] JDBC 4.1 Added[Null] is returned for data types where the 2993 * column size is not applicable. 2994 * 2995 * <!-- start release-specific documentation --> 2996 * <div class="ReleaseSpecificDocumentation"> 2997 * <h3>HSQLDB-Specific Information:</h3> <p> 2998 * 2999 * HSQLDB supports the SQL Standard. It treats unquoted identifiers as 3000 * case insensitive in SQL and stores 3001 * them in upper case; it treats quoted identifiers as case sensitive and 3002 * stores them verbatim. All JDBCDatabaseMetaData methods perform 3003 * case-sensitive comparison between name (pattern) arguments and the 3004 * corresponding identifier values as they are stored in the database. 3005 * Therefore, care must be taken to specify name arguments precisely 3006 * (including case) as they are stored in the database. <p> 3007 * 3008 * Since 1.7.2, this feature is supported by default. If the jar is 3009 * compiled without org.hsqldb.dbinfo.DatabaseInformationMain, the feature is 3010 * not supported. The default implementation is 3011 * {@link org.hsqldb.dbinfo.DatabaseInformationFull}. 3012 * </div> 3013 * <!-- end release-specific documentation --> 3014 * 3015 * @param catalog a catalog name; must match the catalog name as it 3016 * is stored in the database; "" retrieves those without a catalog; 3017 * <code>null</code> means that the catalog name should not be used to narrow 3018 * the search 3019 * @param schemaPattern a schema name pattern; must match the schema name 3020 * as it is stored in the database; "" retrieves those without a schema; 3021 * <code>null</code> means that the schema name should not be used to narrow 3022 * the search 3023 * @param procedureNamePattern a procedure name pattern; must match the 3024 * procedure name as it is stored in the database 3025 * @param columnNamePattern a column name pattern; must match the column name 3026 * as it is stored in the database 3027 * @return <code>ResultSet</code> - each row describes a stored procedure parameter or 3028 * column 3029 * @exception SQLException if a database access error occurs 3030 * @see #getSearchStringEscape 3031 */ getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern)3032 public ResultSet getProcedureColumns(String catalog, String schemaPattern, 3033 String procedureNamePattern, 3034 String columnNamePattern) throws SQLException { 3035 3036 if (wantsIsNull(procedureNamePattern) 3037 || wantsIsNull(columnNamePattern)) { 3038 return executeSelect("SYSTEM_PROCEDURECOLUMNS", "0=1"); 3039 } 3040 catalog = translateCatalog(catalog); 3041 schemaPattern = translateSchema(schemaPattern); 3042 3043 StringBuffer select = toQueryPrefix("SYSTEM_PROCEDURECOLUMNS").append( 3044 and("PROCEDURE_CAT", "=", catalog)).append( 3045 and("PROCEDURE_SCHEM", "LIKE", schemaPattern)).append( 3046 and("PROCEDURE_NAME", "LIKE", procedureNamePattern)).append( 3047 and("COLUMN_NAME", "LIKE", columnNamePattern)); 3048 3049 // By default, query already returns result ordered by 3050 // PROCEDURE_SCHEM and PROCEDURE_NAME... 3051 return execute(select.toString()); 3052 } 3053 3054 /** 3055 * Retrieves a description of the tables available in the given catalog. 3056 * Only table descriptions matching the catalog, schema, table 3057 * name and type criteria are returned. They are ordered by 3058 * <code>TABLE_TYPE</code>, JDBC 4.1[<code>TABLE_CAT</code>,] 3059 * <code>TABLE_SCHEM</code> and <code>TABLE_NAME</code>. 3060 * <P> 3061 * Each table description has the following columns: 3062 * <OL> 3063 * <LI><B>TABLE_CAT</B> String => table catalog (may be <code>null</code>) 3064 * <LI><B>TABLE_SCHEM</B> String => table schema (may be <code>null</code>) 3065 * <LI><B>TABLE_NAME</B> String => table name 3066 * <LI><B>TABLE_TYPE</B> String => table type. Typical types are "TABLE", 3067 * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", 3068 * "LOCAL TEMPORARY", "ALIAS", "SYNONYM". 3069 * <LI><B>REMARKS</B> String => explanatory comment on the table 3070 * <LI><B>TYPE_CAT</B> String => the types catalog (may be <code>null</code>) 3071 * <LI><B>TYPE_SCHEM</B> String => the types schema (may be <code>null</code>) 3072 * <LI><B>TYPE_NAME</B> String => type name (may be <code>null</code>) 3073 * <LI><B>SELF_REFERENCING_COL_NAME</B> String => name of the designated 3074 * "identifier" column of a typed table (may be <code>null</code>) 3075 * <LI><B>REF_GENERATION</B> String => specifies how values in 3076 * SELF_REFERENCING_COL_NAME are created. Values are 3077 * "SYSTEM", "USER", "DERIVED". (may be <code>null</code>) 3078 * </OL> 3079 * 3080 * <P><B>Note:</B> Some databases may not return information for 3081 * all tables. 3082 * 3083 * <!-- start release-specific documentation --> 3084 * <div class="ReleaseSpecificDocumentation"> 3085 * <h3>HSQLDB-Specific Information:</h3> <p> 3086 * 3087 * HSQLDB supports the SQL Standard. It treats unquoted identifiers as 3088 * case insensitive in SQL and stores 3089 * them in upper case; it treats quoted identifiers as case sensitive and 3090 * stores them verbatim. All JDBCDatabaseMetaData methods perform 3091 * case-sensitive comparison between name (pattern) arguments and the 3092 * corresponding identifier values as they are stored in the database. 3093 * Therefore, care must be taken to specify name arguments precisely 3094 * (including case) as they are stored in the database. <p> 3095 * 3096 * HSQLDB returns extra information on TEXT tables in the REMARKS column. <p> 3097 * 3098 * HSQLDB includes the JDBC3 columns TYPE_CAT, TYPE_SCHEM, TYPE_NAME and 3099 * SELF_REFERENCING_COL_NAME in anticipation of JDBC3 compliant tools. <p> 3100 * 3101 * Since 1.7.2, this feature is supported by default. If the jar is 3102 * compiled without org.hsqldb.dbinfo.DatabaseInformationMain, the feature is 3103 * not supported. The default implementation is 3104 * {@link org.hsqldb.dbinfo.DatabaseInformationMain}. 3105 * </div> 3106 * <!-- end release-specific documentation --> 3107 * 3108 * @param catalog a catalog name; must match the catalog name as it 3109 * is stored in the database; "" retrieves those without a catalog; 3110 * <code>null</code> means that the catalog name should not be used to narrow 3111 * the search 3112 * @param schemaPattern a schema name pattern; must match the schema name 3113 * as it is stored in the database; "" retrieves those without a schema; 3114 * <code>null</code> means that the schema name should not be used to narrow 3115 * the search 3116 * @param tableNamePattern a table name pattern; must match the 3117 * table name as it is stored in the database 3118 * @param types a list of table types, which must be from the list of table types 3119 * returned from {@link #getTableTypes},to include; <code>null</code> returns 3120 * all types 3121 * @return <code>ResultSet</code> - each row is a table description 3122 * @exception SQLException if a database access error occurs 3123 * @see #getSearchStringEscape 3124 */ getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types)3125 public ResultSet getTables(String catalog, String schemaPattern, 3126 String tableNamePattern, 3127 String[] types) throws SQLException { 3128 3129 if (wantsIsNull(tableNamePattern) 3130 || (types != null && types.length == 0)) { 3131 return executeSelect("SYSTEM_TABLES", "0=1"); 3132 } 3133 catalog = translateCatalog(catalog); 3134 schemaPattern = translateSchema(schemaPattern); 3135 3136 StringBuffer select = 3137 toQueryPrefix("SYSTEM_TABLES").append(and("TABLE_CAT", "=", 3138 catalog)).append(and("TABLE_SCHEM", "LIKE", 3139 schemaPattern)).append(and("TABLE_NAME", 3140 "LIKE", tableNamePattern)); 3141 3142 if (types == null) { 3143 3144 // do not use to narrow search 3145 } else { 3146 3147 // JDBC4 clarification: 3148 // fredt - we shouldn't impose this test as it breaks compatibility with tools 3149 /* 3150 String[] allowedTypes = new String[] { 3151 "GLOBAL TEMPORARY", "SYSTEM TABLE", "TABLE", "VIEW" 3152 }; 3153 int illegalIndex = 0; 3154 String illegalType = null; 3155 3156 outer_loop: 3157 for (int i = 0; i < types.length; i++) { 3158 for (int j = 0; j < allowedTypes.length; j++) { 3159 if (allowedTypes[j].equals(types[i])) { 3160 continue outer_loop; 3161 } 3162 } 3163 3164 illegalIndex = i; 3165 illegalType = types[illegalIndex]; 3166 3167 break; 3168 } 3169 3170 if (illegalType != null) { 3171 throw Util.sqlException(Trace.JDBC_INVALID_ARGUMENT, 3172 "types[" + illegalIndex + "]=>\"" 3173 + illegalType + "\""); 3174 } 3175 */ 3176 3177 // end JDBC4 clarification 3178 // 3179 select.append(" AND TABLE_TYPE IN (").append( 3180 StringUtil.getList(types, ",", "'")).append(')'); 3181 } 3182 3183 // By default, query already returns result ordered by 3184 // TABLE_TYPE, TABLE_SCHEM and TABLE_NAME... 3185 return execute(select.toString()); 3186 } 3187 3188 /** 3189 * Retrieves the schema names available in this database. The results 3190 * are ordered by JDBC 4.1[<code>TABLE_CATALOG</code>] and 3191 * <code>TABLE_SCHEM</code>. 3192 * 3193 * <P>The schema columns are: 3194 * <OL> 3195 * <LI><B>TABLE_SCHEM</B> String => schema name 3196 * <LI><B>TABLE_CATALOG</B> String => catalog name (may be <code>null</code>) 3197 * </OL> 3198 * 3199 * <!-- start release-specific documentation --> 3200 * <div class="ReleaseSpecificDocumentation"> 3201 * <h3>HSQLDB-Specific Information:</h3> <p> 3202 * 3203 * Starting with 1.8.0, the list of schemas is returned. 3204 * </div> 3205 * <!-- end release-specific documentation --> 3206 * 3207 * @return a <code>ResultSet</code> object in which each row is a 3208 * schema description 3209 * @exception SQLException if a database access error occurs 3210 * 3211 */ getSchemas()3212 public ResultSet getSchemas() throws SQLException { 3213 3214 // By default, query already returns the result in contract order 3215 return executeSelect("SYSTEM_SCHEMAS", null); 3216 } 3217 3218 /** 3219 * Retrieves the catalog names available in this database. The results 3220 * are ordered by catalog name. 3221 * 3222 * <P>The catalog column is: 3223 * <OL> 3224 * <LI><B>TABLE_CAT</B> String => catalog name 3225 * </OL> 3226 * 3227 * <!-- start release-specific documentation --> 3228 * <div class="ReleaseSpecificDocumentation"> 3229 * <h3>HSQLDB-Specific Information:</h3> <p> 3230 * 3231 * Since 1.7.2, this feature is supported by default. If the jar is 3232 * compiled without org.hsqldb.dbinfo.DatabaseInformationMain, the feature is 3233 * not supported. The default implementation is 3234 * {@link org.hsqldb.dbinfo.DatabaseInformationMain}. 3235 * </div> 3236 * <!-- end release-specific documentation --> 3237 * 3238 * @return a <code>ResultSet</code> object in which each row has a 3239 * single <code>String</code> column that is a catalog name 3240 * @exception SQLException if a database access error occurs 3241 */ getCatalogs()3242 public ResultSet getCatalogs() throws SQLException { 3243 3244 String select = 3245 "SELECT CATALOG_NAME AS TABLE_CAT FROM INFORMATION_SCHEMA.INFORMATION_SCHEMA_CATALOG_NAME"; 3246 3247 return execute(select); 3248 } 3249 3250 /** 3251 * Retrieves the table types available in this database. The results 3252 * are ordered by table type. 3253 * 3254 * <P>The table type is: 3255 * <OL> 3256 * <LI><B>TABLE_TYPE</B> String => table type. Typical types are "TABLE", 3257 * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", 3258 * "LOCAL TEMPORARY", "ALIAS", "SYNONYM". 3259 * </OL> 3260 * 3261 * <!-- start release-specific documentation --> 3262 * <div class="ReleaseSpecificDocumentation"> 3263 * <h3>HSQLDB-Specific Information:</h3> <p> 3264 * 3265 * Since 1.7.1, HSQLDB reports: "TABLE", "VIEW" and "GLOBAL TEMPORARY" 3266 * types. 3267 * 3268 * Since 1.7.2, this feature is supported by default. If the jar is 3269 * compiled without org.hsqldb.dbinfo.DatabaseInformationMain, the feature is 3270 * not supported. The default implementation is 3271 * {@link org.hsqldb.dbinfo.DatabaseInformationMain}. 3272 * </div> 3273 * <!-- end release-specific documentation --> 3274 * 3275 * @return a <code>ResultSet</code> object in which each row has a 3276 * single <code>String</code> column that is a table type 3277 * @exception SQLException if a database access error occurs 3278 */ getTableTypes()3279 public ResultSet getTableTypes() throws SQLException { 3280 3281 // system table producer returns rows in contract order 3282 return executeSelect("SYSTEM_TABLETYPES", null); 3283 } 3284 3285 /** 3286 * Retrieves a description of table columns available in 3287 * the specified catalog. 3288 * 3289 * <P>Only column descriptions matching the catalog, schema, table 3290 * and column name criteria are returned. They are ordered by 3291 * JDBC 4.1[<code>TABLE_CAT</code>, ]<code>TABLE_SCHEM</code>, 3292 * <code>TABLE_NAME</code>, and <code>ORDINAL_POSITION</code>. 3293 * 3294 * <P>Each column description has the following columns: 3295 * <OL> 3296 * <LI><B>TABLE_CAT</B> String => table catalog (may be <code>null</code>) 3297 * <LI><B>TABLE_SCHEM</B> String => table schema (may be <code>null</code>) 3298 * <LI><B>TABLE_NAME</B> String => table name 3299 * <LI><B>COLUMN_NAME</B> String => column name 3300 * <LI><B>DATA_TYPE</B> int => SQL type from java.sql.Types 3301 * <LI><B>TYPE_NAME</B> String => Data source dependent type name, 3302 * for a UDT the type name is fully qualified 3303 * <LI><B>COLUMN_SIZE</B> int => column size. 3304 * <LI><B>BUFFER_LENGTH</B> is not used. 3305 * <LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits. Null is returned for data types where 3306 * DECIMAL_DIGITS is not applicable. 3307 * <LI><B>NUM_PREC_RADIX</B> int => Radix (typically either 10 or 2) 3308 * <LI><B>NULLABLE</B> int => is NULL allowed. 3309 * <UL> 3310 * <LI> columnNoNulls - might not allow <code>NULL</code> values 3311 * <LI> columnNullable - definitely allows <code>NULL</code> values 3312 * <LI> columnNullableUnknown - nullability unknown 3313 * </UL> 3314 * <LI><B>REMARKS</B> String => comment describing column (may be <code>null</code>) 3315 * <LI><B>COLUMN_DEF</B> String => (JDBC4 clarification:) default value for the column, which should be interpreted as a string when the value is enclosed in quotes (may be <code>null</code>) 3316 * <LI><B>SQL_DATA_TYPE</B> int => unused 3317 * 3318 * <p>HSQLDB-specific: CLI type from SQL 2003 Table 37, 3319 * tables 6-9 Annex A1, and/or addendums in other 3320 * documents, such as:<br> 3321 * SQL 2003 Part 9: Management of External Data (SQL/MED) : DATALINK<br> 3322 * SQL 2003 Part 14: XML-Related Specifications (SQL/XML) : XML<p> 3323 * 3324 * <LI><B>SQL_DATETIME_SUB</B> int => unused (HSQLDB-specific: SQL 2003 CLI datetime/interval subcode) 3325 * <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the 3326 * maximum number of bytes in the column 3327 * <LI><B>ORDINAL_POSITION</B> int => index of column in table 3328 * (starting at 1) 3329 * <LI><B>IS_NULLABLE</B> String => ISO rules are used to determine the nullability for a column. 3330 * <UL> 3331 * <LI> YES --- if the column can include NULLs 3332 * <LI> NO --- if the column cannot include NULLs 3333 * <LI> empty string --- if the nullability for the 3334 * column is unknown 3335 * </UL> 3336 * <LI>JDBC 4.1 Deleted[<B>SCOPE_CATLOG</B>] JDBC 4.1 Added[<B>SCOPE_CATALOG</B>] String => catalog of table that is the scope 3337 * of a reference attribute (<code>null</code> if DATA_TYPE isn't REF) 3338 * <LI><B>SCOPE_SCHEMA</B> String => schema of table that is the scope 3339 * of a reference attribute (<code>null</code> if the DATA_TYPE isn't REF) 3340 * <LI><B>SCOPE_TABLE</B> String => table name that this the scope 3341 * of a reference attribute (<code>null</code> if the DATA_TYPE isn't REF) 3342 * <LI><B>SOURCE_DATA_TYPE</B> short => source type of a distinct type or user-generated 3343 * Ref type, SQL type from java.sql.Types (<code>null</code> if DATA_TYPE 3344 * isn't DISTINCT or user-generated REF) 3345 * <LI><B>IS_AUTOINCREMENT</B> String => Indicates whether this column is auto incremented 3346 * <UL> 3347 * <LI> YES --- if the column is auto incremented 3348 * <LI> NO --- if the column is not auto incremented 3349 * <LI> empty string --- if it cannot be determined whether the column is auto incremented 3350 * </UL> 3351 * <LI>(JDBC 4.1 New:)<B>IS_GENERATEDCOLUMN</B> String => Indicates whether this is a generated column 3352 * <UL> 3353 * <LI> YES --- if this a generated column 3354 * <LI> NO --- if this not a generated column 3355 * <LI> empty string --- if it cannot be determined whether this is a generated column 3356 * </UL> 3357 * </OL> 3358 * 3359 * <p>(JDBC4 clarification:) The COLUMN_SIZE column represents the specified column size for the given column. 3360 * For numeric data, this is the maximum precision. For character data, this is the [declared or implicit maximum] length in characters. 3361 * For datetime datatypes, this is the [maximum] length in characters of the String representation (assuming the 3362 * maximum allowed precision of the fractional seconds component). For binary data, this is the [maximum] length in bytes. For the ROWID datatype, 3363 * this is the length in bytes[, as returned by the implementation-specific java.sql.RowId.getBytes() method]. JDBC 4.1 Deleted[0] JDBC 4.1 Added[Null] is returned for data types where the 3364 * column size is not applicable. <p> 3365 * 3366 * <!-- start release-specific documentation --> 3367 * <div class="ReleaseSpecificDocumentation"> 3368 * <h3>HSQLDB-Specific Information:</h3> <p> 3369 * 3370 * HSQLDB supports the SQL Standard. It treats unquoted identifiers as 3371 * case insensitive in SQL and stores 3372 * them in upper case; it treats quoted identifiers as case sensitive and 3373 * stores them verbatim. All JDBCDatabaseMetaData methods perform 3374 * case-sensitive comparison between name (pattern) arguments and the 3375 * corresponding identifier values as they are stored in the database. 3376 * Therefore, care must be taken to specify name arguments precisely 3377 * (including case) as they are stored in the database. <p> 3378 * 3379 * This feature is supported by default. If the jar is 3380 * compiled without org.hsqldb.dbinfo.DatabaseInformationMain, the feature is 3381 * not supported. The default implementation is 3382 * {@link org.hsqldb.dbinfo.DatabaseInformationMain}. 3383 * </div> 3384 * <!-- end release-specific documentation --> 3385 * 3386 * @param catalog a catalog name; must match the catalog name as it 3387 * is stored in the database; "" retrieves those without a catalog; 3388 * <code>null</code> means that the catalog name should not be used to narrow 3389 * the search 3390 * @param schemaPattern a schema name pattern; must match the schema name 3391 * as it is stored in the database; "" retrieves those without a schema; 3392 * <code>null</code> means that the schema name should not be used to narrow 3393 * the search 3394 * @param tableNamePattern a table name pattern; must match the 3395 * table name as it is stored in the database 3396 * @param columnNamePattern a column name pattern; must match the column 3397 * name as it is stored in the database 3398 * @return <code>ResultSet</code> - each row is a column description 3399 * @exception SQLException if a database access error occurs 3400 * @see #getSearchStringEscape 3401 */ getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)3402 public ResultSet getColumns(String catalog, String schemaPattern, 3403 String tableNamePattern, 3404 String columnNamePattern) throws SQLException { 3405 3406 if (wantsIsNull(tableNamePattern) || wantsIsNull(columnNamePattern)) { 3407 return executeSelect("SYSTEM_COLUMNS", "0=1"); 3408 } 3409 catalog = translateCatalog(catalog); 3410 schemaPattern = translateSchema(schemaPattern); 3411 3412 StringBuffer select = toQueryPrefix("SYSTEM_COLUMNS").append( 3413 and("TABLE_CAT", "=", catalog)).append( 3414 and("TABLE_SCHEM", "LIKE", schemaPattern)).append( 3415 and("TABLE_NAME", "LIKE", tableNamePattern)).append( 3416 and("COLUMN_NAME", "LIKE", columnNamePattern)); 3417 3418 // by default, query already returns the result ordered 3419 // by TABLE_SCHEM, TABLE_NAME and ORDINAL_POSITION 3420 return execute(select.toString()); 3421 } 3422 3423 /** 3424 * Retrieves a description of the access rights for a table's columns. 3425 * 3426 * <P>Only privileges matching the column name criteria are 3427 * returned. They are ordered by COLUMN_NAME and PRIVILEGE. 3428 * 3429 * <P>Each privilege description has the following columns: 3430 * <OL> 3431 * <LI><B>TABLE_CAT</B> String => table catalog (may be <code>null</code>) 3432 * <LI><B>TABLE_SCHEM</B> String => table schema (may be <code>null</code>) 3433 * <LI><B>TABLE_NAME</B> String => table name 3434 * <LI><B>COLUMN_NAME</B> String => column name 3435 * <LI><B>GRANTOR</B> String => grantor of access (may be <code>null</code>) 3436 * <LI><B>GRANTEE</B> String => grantee of access 3437 * <LI><B>PRIVILEGE</B> String => name of access (SELECT, 3438 * INSERT, UPDATE, REFRENCES, ...) 3439 * <LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted 3440 * to grant to others; "NO" if not; <code>null</code> if unknown 3441 * </OL> 3442 * 3443 * <!-- start release-specific documentation --> 3444 * <div class="ReleaseSpecificDocumentation"> 3445 * <h3>HSQLDB-Specific Information:</h3> <p> 3446 * 3447 * HSQLDB supports the SQL Standard. It treats unquoted identifiers as 3448 * case insensitive in SQL and stores 3449 * them in upper case; it treats quoted identifiers as case sensitive and 3450 * stores them verbatim. All JDBCDatabaseMetaData methods perform 3451 * case-sensitive comparison between name (pattern) arguments and the 3452 * corresponding identifier values as they are stored in the database. 3453 * Therefore, care must be taken to specify name arguments precisely 3454 * (including case) as they are stored in the database. <p> 3455 * 3456 * This feature is supported by default. The default implementation is 3457 * {@link org.hsqldb.dbinfo.DatabaseInformationMain}. 3458 * </div> 3459 * <!-- end release-specific documentation --> 3460 * 3461 * @param catalog a catalog name; must match the catalog name as it 3462 * is stored in the database; "" retrieves those without a catalog; 3463 * <code>null</code> means that the catalog name should not be used to narrow 3464 * the search 3465 * @param schema a schema name; must match the schema name as it is 3466 * stored in the database; "" retrieves those without a schema; 3467 * <code>null</code> means that the schema name should not be used to narrow 3468 * the search 3469 * @param table a table name; must match the table name as it is 3470 * stored in the database 3471 * @param columnNamePattern a column name pattern; must match the column 3472 * name as it is stored in the database 3473 * @return <code>ResultSet</code> - each row is a column privilege description 3474 * @exception SQLException if a database access error occurs 3475 * @see #getSearchStringEscape 3476 */ getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern)3477 public ResultSet getColumnPrivileges(String catalog, String schema, 3478 String table, String columnNamePattern) throws SQLException { 3479 3480 if (table == null) { 3481 throw JDBCUtil.nullArgument("table"); 3482 } 3483 /* 3484 if (wantsIsNull(columnNamePattern)) { 3485 return executeSelect("SYSTEM_COLUMNPRIVILEGES", "0=1"); 3486 } 3487 */ 3488 catalog = translateCatalog(catalog); 3489 schema = translateSchema(schema); 3490 3491 String sql = 3492 "SELECT TABLE_CATALOG TABLE_CAT, TABLE_SCHEMA TABLE_SCHEM," 3493 + "TABLE_NAME, COLUMN_NAME, GRANTOR, GRANTEE, PRIVILEGE_TYPE PRIVILEGE, IS_GRANTABLE " 3494 + "FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES WHERE TRUE " 3495 + and("TABLE_CATALOG", "=", catalog) 3496 + and("TABLE_SCHEMA", "=", schema) + and("TABLE_NAME", "=", table) 3497 + and("COLUMN_NAME", "LIKE", columnNamePattern) 3498 ; 3499 3500 // By default, the query already returns the result 3501 // ordered by column name, privilege... 3502 return execute(sql); 3503 } 3504 3505 /** 3506 * Retrieves a description of the access rights for each table available 3507 * in a catalog. Note that a table privilege applies to one or 3508 * more columns in the table. It would be wrong to assume that 3509 * this privilege applies to all columns (this may be true for 3510 * some systems but is not true for all.) 3511 * 3512 * <P>Only privileges matching the schema and table name 3513 * criteria are returned. They are ordered by 3514 * JDBC 4.1[<code>TABLE_CAT</code>,] 3515 * <code>TABLE_SCHEM</code>, <code>TABLE_NAME</code>, 3516 * and <code>PRIVILEGE</code>. 3517 * 3518 * <P>Each privilege description has the following columns: 3519 * <OL> 3520 * <LI><B>TABLE_CAT</B> String => table catalog (may be <code>null</code>) 3521 * <LI><B>TABLE_SCHEM</B> String => table schema (may be <code>null</code>) 3522 * <LI><B>TABLE_NAME</B> String => table name 3523 * <LI><B>GRANTOR</B> String => grantor of access (may be <code>null</code>) 3524 * <LI><B>GRANTEE</B> String => grantee of access 3525 * <LI><B>PRIVILEGE</B> String => name of access (SELECT, 3526 * INSERT, UPDATE, REFRENCES, ...) 3527 * <LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted 3528 * to grant to others; "NO" if not; <code>null</code> if unknown 3529 * </OL> 3530 * 3531 * <!-- start release-specific documentation --> 3532 * <div class="ReleaseSpecificDocumentation"> 3533 * <h3>HSQLDB-Specific Information:</h3> <p> 3534 * 3535 * HSQLDB supports the SQL Standard. It treats unquoted identifiers as 3536 * case insensitive in SQL and stores 3537 * them in upper case; it treats quoted identifiers as case sensitive and 3538 * stores them verbatim. All JDBCDatabaseMetaData methods perform 3539 * case-sensitive comparison between name (pattern) arguments and the 3540 * corresponding identifier values as they are stored in the database. 3541 * Therefore, care must be taken to specify name arguments precisely 3542 * (including case) as they are stored in the database. <p> 3543 * 3544 * Since 1.7.2, this feature is supported by default. If the jar is 3545 * compiled without org.hsqldb.dbinfo.DatabaseInformationMain, the feature is 3546 * not supported. The default implementation is 3547 * {@link org.hsqldb.dbinfo.DatabaseInformationMain}. 3548 * </div> 3549 * <!-- end release-specific documentation --> 3550 * 3551 * @param catalog a catalog name; must match the catalog name as it 3552 * is stored in the database; "" retrieves those without a catalog; 3553 * <code>null</code> means that the catalog name should not be used to narrow 3554 * the search 3555 * @param schemaPattern a schema name pattern; must match the schema name 3556 * as it is stored in the database; "" retrieves those without a schema; 3557 * <code>null</code> means that the schema name should not be used to narrow 3558 * the search 3559 * @param tableNamePattern a table name pattern; must match the 3560 * table name as it is stored in the database 3561 * @return <code>ResultSet</code> - each row is a table privilege description 3562 * @exception SQLException if a database access error occurs 3563 * @see #getSearchStringEscape 3564 */ getTablePrivileges( String catalog, String schemaPattern, String tableNamePattern)3565 public ResultSet getTablePrivileges( 3566 String catalog, String schemaPattern, 3567 String tableNamePattern) throws SQLException { 3568 3569 catalog = translateCatalog(catalog); 3570 schemaPattern = translateSchema(schemaPattern); 3571 3572 String sql = 3573 "SELECT TABLE_CATALOG TABLE_CAT, TABLE_SCHEMA TABLE_SCHEM," 3574 + "TABLE_NAME, GRANTOR, GRANTEE, PRIVILEGE_TYPE PRIVILEGE, IS_GRANTABLE " 3575 + "FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES WHERE TRUE " 3576 + and("TABLE_CATALOG", "=", catalog) 3577 + and("TABLE_SCHEMA", "LIKE", schemaPattern) 3578 + and("TABLE_NAME", "LIKE", tableNamePattern); 3579 3580 /* 3581 if (wantsIsNull(tableNamePattern)) { 3582 return executeSelect("SYSTEM_TABLEPRIVILEGES", "0=1"); 3583 } 3584 */ 3585 3586 // By default, the query already returns a result ordered by 3587 // TABLE_SCHEM, TABLE_NAME, and PRIVILEGE... 3588 return execute(sql); 3589 } 3590 3591 /** 3592 * Retrieves a description of a table's optimal set of columns that 3593 * uniquely identifies a row. They are ordered by SCOPE. 3594 * 3595 * <P>Each column description has the following columns: 3596 * <OL> 3597 * <LI><B>SCOPE</B> short => actual scope of result 3598 * <UL> 3599 * <LI> bestRowTemporary - very temporary, while using row 3600 * <LI> bestRowTransaction - valid for remainder of current transaction 3601 * <LI> bestRowSession - valid for remainder of current session 3602 * </UL> 3603 * <LI><B>COLUMN_NAME</B> String => column name 3604 * <LI><B>DATA_TYPE</B> int => SQL data type from java.sql.Types 3605 * <LI><B>TYPE_NAME</B> String => Data source dependent type name, 3606 * for a UDT the type name is fully qualified 3607 * <LI><B>COLUMN_SIZE</B> int => precision 3608 * <LI><B>BUFFER_LENGTH</B> int => not used 3609 * <LI><B>DECIMAL_DIGITS</B> short => scale - Null is returned for data types where 3610 * DECIMAL_DIGITS is not applicable. 3611 * <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column 3612 * like an Oracle ROWID 3613 * <UL> 3614 * <LI> bestRowUnknown - may or may not be pseudo column 3615 * <LI> bestRowNotPseudo - is NOT a pseudo column 3616 * <LI> bestRowPseudo - is a pseudo column 3617 * </UL> 3618 * </OL> 3619 * 3620 * <p>(JDBC4 clarification:) 3621 * <p>The COLUMN_SIZE column represents the specified column size for the given column. 3622 * For numeric data, this is the maximum precision. For character data, this is the [declared or implicit maximum] length in characters. 3623 * For datetime datatypes, this is the [maximum] length in characters of the String representation (assuming the 3624 * maximum allowed precision of the fractional seconds component). For binary data, this is the [maximum] length in bytes. For the ROWID datatype, 3625 * this is the length in bytes[, as returned by the implementation-specific java.sql.RowId.getBytes() method]. JDBC 4.1 Deleted[0] JDBC 4.1 Added[Null] is returned for data types where the 3626 * column size is not applicable. <p> 3627 * 3628 * <!-- start release-specific documentation --> 3629 * <div class="ReleaseSpecificDocumentation"> 3630 * <h3>HSQLDB-Specific Information:</h3> <p> 3631 * 3632 * HSQLDB supports the SQL Standard. It treats unquoted identifiers as 3633 * case insensitive in SQL and stores 3634 * them in upper case; it treats quoted identifiers as case sensitive and 3635 * stores them verbatim. All JDBCDatabaseMetaData methods perform 3636 * case-sensitive comparison between name (pattern) arguments and the 3637 * corresponding identifier values as they are stored in the database. 3638 * Therefore, care must be taken to specify name arguments precisely 3639 * (including case) as they are stored in the database. <p> 3640 * 3641 * If the name of a column is defined in the database without double 3642 * quotes, an all-uppercase name must be specified when calling this 3643 * method. Otherwise, the name must be specified in the exact case of 3644 * the column definition in the database. <p> 3645 * 3646 * Since 1.7.2, this feature is supported by default. If the jar is 3647 * compiled without org.hsqldb.dbinfo.DatabaseInformationMain, the feature is 3648 * not supported. The default implementation is 3649 * {@link org.hsqldb.dbinfo.DatabaseInformationMain}. 3650 * </div> 3651 * <!-- end release-specific documentation --> 3652 * 3653 * @param catalog a catalog name; must match the catalog name as it 3654 * is stored in the database; "" retrieves those without a catalog; 3655 * <code>null</code> means that the catalog name should not be used to narrow 3656 * the search 3657 * @param schema a schema name; must match the schema name 3658 * as it is stored in the database; "" retrieves those without a schema; 3659 * <code>null</code> means that the schema name should not be used to narrow 3660 * the search 3661 * @param table a table name; must match the table name as it is stored 3662 * in the database 3663 * @param scope the scope of interest; use same values as SCOPE 3664 * @param nullable include columns that are nullable. 3665 * @return <code>ResultSet</code> - each row is a column description 3666 * @exception SQLException if a database access error occurs 3667 */ getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable)3668 public ResultSet getBestRowIdentifier(String catalog, String schema, 3669 String table, int scope, boolean nullable) throws SQLException { 3670 3671 if (table == null) { 3672 throw JDBCUtil.nullArgument("table"); 3673 } 3674 3675 String scopeIn; 3676 3677 switch (scope) { 3678 3679 case bestRowTemporary : 3680 scopeIn = BRI_TEMPORARY_SCOPE_IN_LIST; 3681 3682 break; 3683 case bestRowTransaction : 3684 scopeIn = BRI_TRANSACTION_SCOPE_IN_LIST; 3685 3686 break; 3687 case bestRowSession : 3688 scopeIn = BRI_SESSION_SCOPE_IN_LIST; 3689 3690 break; 3691 default : 3692 throw JDBCUtil.invalidArgument("scope"); 3693 } 3694 catalog = translateCatalog(catalog); 3695 schema = translateSchema(schema); 3696 3697 Integer Nullable = (nullable) ? null 3698 : INT_COLUMNS_NO_NULLS; 3699 StringBuffer select = 3700 toQueryPrefix("SYSTEM_BESTROWIDENTIFIER").append(and("TABLE_CAT", 3701 "=", catalog)).append(and("TABLE_SCHEM", "=", 3702 schema)).append(and("TABLE_NAME", "=", 3703 table)).append(and("NULLABLE", "=", 3704 Nullable)).append(" AND SCOPE IN " 3705 + scopeIn); 3706 3707 // By default, query already returns rows in contract order. 3708 // However, the way things are set up, there should never be 3709 // a result where there is > 1 distinct scope value: most requests 3710 // will want only one table and the system table producer (for 3711 // now) guarantees that a maximum of one BRI scope column set is 3712 // produced for each table 3713 return execute(select.toString()); 3714 } 3715 3716 /** 3717 * Retrieves a description of a table's columns that are automatically 3718 * updated when any value in a row is updated. They are 3719 * unordered. 3720 * 3721 * <P>Each column description has the following columns: 3722 * <OL> 3723 * <LI><B>SCOPE</B> short => is not used 3724 * <LI><B>COLUMN_NAME</B> String => column name 3725 * <LI><B>DATA_TYPE</B> int => SQL data type from <code>java.sql.Types</code> 3726 * <LI><B>TYPE_NAME</B> String => Data source-dependent type name 3727 * <LI><B>COLUMN_SIZE</B> int => precision 3728 * <LI><B>BUFFER_LENGTH</B> int => length of column value in bytes 3729 * <LI><B>DECIMAL_DIGITS</B> short => scale - Null is returned for data types where 3730 * DECIMAL_DIGITS is not applicable. 3731 * <LI><B>PSEUDO_COLUMN</B> short => whether this is pseudo column 3732 * like an Oracle ROWID 3733 * <UL> 3734 * <LI> versionColumnUnknown - may or may not be pseudo column 3735 * <LI> versionColumnNotPseudo - is NOT a pseudo column 3736 * <LI> versionColumnPseudo - is a pseudo column 3737 * </UL> 3738 * </OL> 3739 * 3740 * <p>(JDBC4 clarification:) 3741 * <p>The COLUMN_SIZE column represents the specified column size for the given column. 3742 * For numeric data, this is the maximum precision. For character data, this is the [declared or implicit maximum] length in characters. 3743 * For datetime datatypes, this is the [maximum] length in characters of the String representation (assuming the 3744 * maximum allowed precision of the fractional seconds component). For binary data, this is the [maximum] length in bytes. For the ROWID datatype, 3745 * this is the length in bytes[, as returned by the implementation-specific java.sql.RowId.getBytes() method]. JDBC 4.1 Deleted[0], JDBC 4.1 Added[Null] is returned for data types where the 3746 * column size is not applicable. 3747 * 3748 * <!-- start release-specific documentation --> 3749 * <div class="ReleaseSpecificDocumentation"> 3750 * <h3>HSQLDB-Specific Information:</h3> <p> 3751 * 3752 * HSQLDB does not support version columns. This returns an empty result set. 3753 * </div> 3754 * <!-- end release-specific documentation --> 3755 * 3756 * @param catalog a catalog name; must match the catalog name as it 3757 * is stored in the database; "" retrieves those without a catalog; 3758 * <code>null</code> means that the catalog name should not be used to narrow 3759 * the search 3760 * @param schema a schema name; must match the schema name 3761 * as it is stored in the database; "" retrieves those without a schema; 3762 * <code>null</code> means that the schema name should not be used to narrow 3763 * the search 3764 * @param table a table name; must match the table name as it is stored 3765 * in the database 3766 * @return a <code>ResultSet</code> object in which each row is a 3767 * column description 3768 * @exception SQLException if a database access error occurs 3769 */ getVersionColumns(String catalog, String schema, String table)3770 public ResultSet getVersionColumns(String catalog, String schema, 3771 String table) throws SQLException { 3772 3773 if (table == null) { 3774 throw JDBCUtil.nullArgument("table"); 3775 } 3776 catalog = translateCatalog(catalog); 3777 schema = translateSchema(schema); 3778 3779 StringBuffer select = 3780 toQueryPrefix("SYSTEM_VERSIONCOLUMNS").append(and("TABLE_CAT", 3781 "=", catalog)).append(and("TABLE_SCHEM", "=", 3782 schema)).append(and("TABLE_NAME", "=", table)); 3783 3784 // result does not need to be ordered 3785 return execute(select.toString()); 3786 } 3787 3788 /** 3789 * Retrieves a description of the given table's primary key columns. They 3790 * are ordered by COLUMN_NAME. 3791 * 3792 * <P>Each primary key column description has the following columns: 3793 * <OL> 3794 * <LI><B>TABLE_CAT</B> String => table catalog (may be <code>null</code>) 3795 * <LI><B>TABLE_SCHEM</B> String => table schema (may be <code>null</code>) 3796 * <LI><B>TABLE_NAME</B> String => table name 3797 * <LI><B>COLUMN_NAME</B> String => column name 3798 * <LI><B>KEY_SEQ</B> short => (JDBC4 Clarification:) sequence number within primary key( a value 3799 * of 1 represents the first column of the primary key, a value of 2 would 3800 * represent the second column within the primary key). 3801 * <LI><B>PK_NAME</B> String => primary key name (may be <code>null</code>) 3802 * </OL> 3803 * 3804 * <!-- start release-specific documentation --> 3805 * <div class="ReleaseSpecificDocumentation"> 3806 * <h3>HSQLDB-Specific Information:</h3> <p> 3807 * 3808 * HSQLDB supports the SQL Standard. It treats unquoted identifiers as 3809 * case insensitive in SQL and stores 3810 * them in upper case; it treats quoted identifiers as case sensitive and 3811 * stores them verbatim. All JDBCDatabaseMetaData methods perform 3812 * case-sensitive comparison between name (pattern) arguments and the 3813 * corresponding identifier values as they are stored in the database. 3814 * Therefore, care must be taken to specify name arguments precisely 3815 * (including case) as they are stored in the database. <p> 3816 * 3817 * Since 1.7.2, this feature is supported by default. If the jar is 3818 * compiled without org.hsqldb.dbinfo.DatabaseInformationMain, the feature is 3819 * not supported. The default implementation is 3820 * {@link org.hsqldb.dbinfo.DatabaseInformationMain}. 3821 * </div> 3822 * <!-- end release-specific documentation --> 3823 * 3824 * @param catalog a catalog name; must match the catalog name as it 3825 * is stored in the database; "" retrieves those without a catalog; 3826 * <code>null</code> means that the catalog name should not be used to narrow 3827 * the search 3828 * @param schema a schema name; must match the schema name 3829 * as it is stored in the database; "" retrieves those without a schema; 3830 * <code>null</code> means that the schema name should not be used to narrow 3831 * the search 3832 * @param table a table name; must match the table name as it is stored 3833 * in the database 3834 * @return <code>ResultSet</code> - each row is a primary key column description 3835 * @exception SQLException if a database access error occurs 3836 * @see #supportsMixedCaseQuotedIdentifiers 3837 * @see #storesUpperCaseIdentifiers 3838 */ getPrimaryKeys(String catalog, String schema, String table)3839 public ResultSet getPrimaryKeys(String catalog, String schema, 3840 String table) throws SQLException { 3841 3842 if (table == null) { 3843 throw JDBCUtil.nullArgument("table"); 3844 } 3845 catalog = translateCatalog(catalog); 3846 schema = translateSchema(schema); 3847 3848 StringBuffer select = 3849 toQueryPrefix("SYSTEM_PRIMARYKEYS").append(and("TABLE_CAT", "=", 3850 catalog)).append(and("TABLE_SCHEM", "=", 3851 schema)).append(and("TABLE_NAME", "=", 3852 table)); 3853 3854 // By default, query already returns result in contract order 3855 return execute(select.toString()); 3856 } 3857 3858 /** 3859 * Retrieves a description of the primary key columns that are 3860 * referenced by the given table's foreign key columns (the primary keys 3861 * imported by a table). They are ordered by PKTABLE_CAT, 3862 * PKTABLE_SCHEM, PKTABLE_NAME, and KEY_SEQ. 3863 * 3864 * <P>Each primary key column description has the following columns: 3865 * <OL> 3866 * <LI><B>PKTABLE_CAT</B> String => primary key table catalog 3867 * being imported (may be <code>null</code>) 3868 * <LI><B>PKTABLE_SCHEM</B> String => primary key table schema 3869 * being imported (may be <code>null</code>) 3870 * <LI><B>PKTABLE_NAME</B> String => primary key table name 3871 * being imported 3872 * <LI><B>PKCOLUMN_NAME</B> String => primary key column name 3873 * being imported 3874 * <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be <code>null</code>) 3875 * <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be <code>null</code>) 3876 * <LI><B>FKTABLE_NAME</B> String => foreign key table name 3877 * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name 3878 * <LI><B>KEY_SEQ</B> short => (JDBC4 clarification) sequence number within a foreign key (a value 3879 * of 1 represents the first column of the foreign key, a value of 2 would 3880 * represent the second column within the foreign key). 3881 * <LI><B>UPDATE_RULE</B> short => What happens to a 3882 * foreign key when the primary key is updated: 3883 * <UL> 3884 * <LI> importedNoAction - do not allow update of primary 3885 * key if it has been imported 3886 * <LI> importedKeyCascade - change imported key to agree 3887 * with primary key update 3888 * <LI> importedKeySetNull - change imported key to <code>NULL</code> 3889 * if its primary key has been updated 3890 * <LI> importedKeySetDefault - change imported key to default values 3891 * if its primary key has been updated 3892 * <LI> importedKeyRestrict - same as importedKeyNoAction 3893 * (for ODBC 2.x compatibility) 3894 * </UL> 3895 * <LI><B>DELETE_RULE</B> short => What happens to 3896 * the foreign key when primary is deleted. 3897 * <UL> 3898 * <LI> importedKeyNoAction - do not allow delete of primary 3899 * key if it has been imported 3900 * <LI> importedKeyCascade - delete rows that import a deleted key 3901 * <LI> importedKeySetNull - change imported key to NULL if 3902 * its primary key has been deleted 3903 * <LI> importedKeyRestrict - same as importedKeyNoAction 3904 * (for ODBC 2.x compatibility) 3905 * <LI> importedKeySetDefault - change imported key to default if 3906 * its primary key has been deleted 3907 * </UL> 3908 * <LI><B>FK_NAME</B> String => foreign key name (may be <code>null</code>) 3909 * <LI><B>PK_NAME</B> String => primary key name (may be <code>null</code>) 3910 * <LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key 3911 * constraints be deferred until commit 3912 * <UL> 3913 * <LI> importedKeyInitiallyDeferred - see SQL92 for definition 3914 * <LI> importedKeyInitiallyImmediate - see SQL92 for definition 3915 * <LI> importedKeyNotDeferrable - see SQL92 for definition 3916 * </UL> 3917 * </OL> 3918 * 3919 * <!-- start release-specific documentation --> 3920 * <div class="ReleaseSpecificDocumentation"> 3921 * <h3>HSQLDB-Specific Information:</h3> <p> 3922 * 3923 * HSQLDB supports the SQL Standard. It treats unquoted identifiers as 3924 * case insensitive in SQL and stores 3925 * them in upper case; it treats quoted identifiers as case sensitive and 3926 * stores them verbatim. All JDBCDatabaseMetaData methods perform 3927 * case-sensitive comparison between name (pattern) arguments and the 3928 * corresponding identifier values as they are stored in the database. 3929 * Therefore, care must be taken to specify name arguments precisely 3930 * (including case) as they are stored in the database. <p> 3931 * 3932 * Since 1.7.2, this feature is supported by default. If the jar is 3933 * compiled without org.hsqldb.dbinfo.DatabaseInformationMain, the feature is 3934 * not supported. The default implementation is 3935 * {@link org.hsqldb.dbinfo.DatabaseInformationMain}. 3936 * </div> 3937 * <!-- end release-specific documentation --> 3938 * 3939 * @param catalog a catalog name; must match the catalog name as it 3940 * is stored in the database; "" retrieves those without a catalog; 3941 * <code>null</code> means that the catalog name should not be used to narrow 3942 * the search 3943 * @param schema a schema name; must match the schema name 3944 * as it is stored in the database; "" retrieves those without a schema; 3945 * <code>null</code> means that the schema name should not be used to narrow 3946 * the search 3947 * @param table a table name; must match the table name as it is stored 3948 * in the database 3949 * @return <code>ResultSet</code> - each row is a primary key column description 3950 * @exception SQLException if a database access error occurs 3951 * @see #getExportedKeys 3952 * @see #supportsMixedCaseQuotedIdentifiers 3953 * @see #storesUpperCaseIdentifiers 3954 */ getImportedKeys(String catalog, String schema, String table)3955 public ResultSet getImportedKeys(String catalog, String schema, 3956 String table) throws SQLException { 3957 3958 if (table == null) { 3959 throw JDBCUtil.nullArgument("table"); 3960 } 3961 catalog = translateCatalog(catalog); 3962 schema = translateSchema(schema); 3963 3964 StringBuffer select = toQueryPrefix("SYSTEM_CROSSREFERENCE").append( 3965 and("FKTABLE_CAT", "=", catalog)).append( 3966 and("FKTABLE_SCHEM", "=", schema)).append( 3967 and("FKTABLE_NAME", "=", table)).append( 3968 " ORDER BY PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME, KEY_SEQ"); 3969 3970 return execute(select.toString()); 3971 } 3972 3973 /** 3974 * Retrieves a description of the foreign key columns that reference the 3975 * given table's primary key columns (the foreign keys exported by a 3976 * table). They are ordered by FKTABLE_CAT, FKTABLE_SCHEM, 3977 * FKTABLE_NAME, and KEY_SEQ. 3978 * 3979 * <P>Each foreign key column description has the following columns: 3980 * <OL> 3981 * <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be <code>null</code>) 3982 * <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be <code>null</code>) 3983 * <LI><B>PKTABLE_NAME</B> String => primary key table name 3984 * <LI><B>PKCOLUMN_NAME</B> String => primary key column name 3985 * <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be <code>null</code>) 3986 * being exported (may be <code>null</code>) 3987 * <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be <code>null</code>) 3988 * being exported (may be <code>null</code>) 3989 * <LI><B>FKTABLE_NAME</B> String => foreign key table name 3990 * being exported 3991 * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name 3992 * being exported 3993 * <LI><B>KEY_SEQ</B> short => (JDBC4 clarification:) sequence number within foreign key( a value 3994 * of 1 represents the first column of the foreign key, a value of 2 would 3995 * represent the second column within the foreign key). 3996 * <LI><B>UPDATE_RULE</B> short => What happens to 3997 * foreign key when primary is updated: 3998 * <UL> 3999 * <LI> importedNoAction - do not allow update of primary 4000 * key if it has been imported 4001 * <LI> importedKeyCascade - change imported key to agree 4002 * with primary key update 4003 * <LI> importedKeySetNull - change imported key to <code>NULL</code> if 4004 * its primary key has been updated 4005 * <LI> importedKeySetDefault - change imported key to default values 4006 * if its primary key has been updated 4007 * <LI> importedKeyRestrict - same as importedKeyNoAction 4008 * (for ODBC 2.x compatibility) 4009 * </UL> 4010 * <LI><B>DELETE_RULE</B> short => What happens to 4011 * the foreign key when primary is deleted. 4012 * <UL> 4013 * <LI> importedKeyNoAction - do not allow delete of primary 4014 * key if it has been imported 4015 * <LI> importedKeyCascade - delete rows that import a deleted key 4016 * <LI> importedKeySetNull - change imported key to <code>NULL</code> if 4017 * its primary key has been deleted 4018 * <LI> importedKeyRestrict - same as importedKeyNoAction 4019 * (for ODBC 2.x compatibility) 4020 * <LI> importedKeySetDefault - change imported key to default if 4021 * its primary key has been deleted 4022 * </UL> 4023 * <LI><B>FK_NAME</B> String => foreign key name (may be <code>null</code>) 4024 * <LI><B>PK_NAME</B> String => primary key name (may be <code>null</code>) 4025 * <LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key 4026 * constraints be deferred until commit 4027 * <UL> 4028 * <LI> importedKeyInitiallyDeferred - see SQL92 for definition 4029 * <LI> importedKeyInitiallyImmediate - see SQL92 for definition 4030 * <LI> importedKeyNotDeferrable - see SQL92 for definition 4031 * </UL> 4032 * </OL> 4033 * 4034 * <!-- start release-specific documentation --> 4035 * <div class="ReleaseSpecificDocumentation"> 4036 * <h3>HSQLDB-Specific Information:</h3> <p> 4037 * 4038 * HSQLDB supports the SQL Standard. It treats unquoted identifiers as 4039 * case insensitive in SQL and stores 4040 * them in upper case; it treats quoted identifiers as case sensitive and 4041 * stores them verbatim. All JDBCDatabaseMetaData methods perform 4042 * case-sensitive comparison between name (pattern) arguments and the 4043 * corresponding identifier values as they are stored in the database. 4044 * Therefore, care must be taken to specify name arguments precisely 4045 * (including case) as they are stored in the database. <p> 4046 * 4047 * Since 1.7.2, this feature is supported by default. If the jar is 4048 * compiled without org.hsqldb.dbinfo.DatabaseInformationMain, the feature is 4049 * not supported. The default implementation is 4050 * {@link org.hsqldb.dbinfo.DatabaseInformationMain}. 4051 * </div> 4052 * <!-- end release-specific documentation --> 4053 * 4054 * @param catalog a catalog name; must match the catalog name as it 4055 * is stored in this database; "" retrieves those without a catalog; 4056 * <code>null</code> means that the catalog name should not be used to narrow 4057 * the search 4058 * @param schema a schema name; must match the schema name 4059 * as it is stored in the database; "" retrieves those without a schema; 4060 * <code>null</code> means that the schema name should not be used to narrow 4061 * the search 4062 * @param table a table name; must match the table name as it is stored 4063 * in this database 4064 * @return a <code>ResultSet</code> object in which each row is a 4065 * foreign key column description 4066 * @exception SQLException if a database access error occurs 4067 * @see #getImportedKeys 4068 * @see #supportsMixedCaseQuotedIdentifiers 4069 * @see #storesUpperCaseIdentifiers 4070 */ getExportedKeys(String catalog, String schema, String table)4071 public ResultSet getExportedKeys(String catalog, String schema, 4072 String table) throws SQLException { 4073 4074 if (table == null) { 4075 throw JDBCUtil.nullArgument("table"); 4076 } 4077 catalog = translateCatalog(catalog); 4078 schema = translateSchema(schema); 4079 4080 StringBuffer select = 4081 toQueryPrefix("SYSTEM_CROSSREFERENCE").append(and("PKTABLE_CAT", 4082 "=", catalog)).append(and("PKTABLE_SCHEM", "=", 4083 schema)).append(and("PKTABLE_NAME", "=", table)); 4084 4085 // By default, query already returns the table ordered by 4086 // FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and KEY_SEQ. 4087 return execute(select.toString()); 4088 } 4089 4090 /** 4091 * (JDBC4 clarification:) 4092 * Retrieves a description of the foreign key columns in the given foreign key 4093 * table that reference the primary key or the columns representing a unique constraint of the parent table (could be the same or a different table). 4094 * The number of columns returned from the parent table must match the number of 4095 * columns that make up the foreign key. They 4096 * are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and 4097 * KEY_SEQ. 4098 * 4099 * <P>Each foreign key column description has the following columns: 4100 * <OL> 4101 * <LI><B>PKTABLE_CAT</B> String => parent key table catalog (may be <code>null</code>) 4102 * <LI><B>PKTABLE_SCHEM</B> String => parent key table schema (may be <code>null</code>) 4103 * <LI><B>PKTABLE_NAME</B> String => parent key table name 4104 * <LI><B>PKCOLUMN_NAME</B> String => parent key column name 4105 * <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be <code>null</code>) 4106 * being exported (may be <code>null</code>) 4107 * <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be <code>null</code>) 4108 * being exported (may be <code>null</code>) 4109 * <LI><B>FKTABLE_NAME</B> String => foreign key table name 4110 * being exported 4111 * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name 4112 * being exported 4113 * <LI><B>KEY_SEQ</B> short => sequence number within foreign key( a value 4114 * of 1 represents the first column of the foreign key, a value of 2 would 4115 * represent the second column within the foreign key). 4116 * <LI><B>UPDATE_RULE</B> short => What happens to 4117 * foreign key when parent key is updated: 4118 * <UL> 4119 * <LI> importedNoAction - do not allow update of parent 4120 * key if it has been imported 4121 * <LI> importedKeyCascade - change imported key to agree 4122 * with parent key update 4123 * <LI> importedKeySetNull - change imported key to <code>NULL</code> if 4124 * its parent key has been updated 4125 * <LI> importedKeySetDefault - change imported key to default values 4126 * if its parent key has been updated 4127 * <LI> importedKeyRestrict - same as importedKeyNoAction 4128 * (for ODBC 2.x compatibility) 4129 * </UL> 4130 * <LI><B>DELETE_RULE</B> short => What happens to 4131 * the foreign key when parent key is deleted. 4132 * <UL> 4133 * <LI> importedKeyNoAction - do not allow delete of parent 4134 * key if it has been imported 4135 * <LI> importedKeyCascade - delete rows that import a deleted key 4136 * <LI> importedKeySetNull - change imported key to <code>NULL</code> if 4137 * its primary key has been deleted 4138 * <LI> importedKeyRestrict - same as importedKeyNoAction 4139 * (for ODBC 2.x compatibility) 4140 * <LI> importedKeySetDefault - change imported key to default if 4141 * its parent key has been deleted 4142 * </UL> 4143 * <LI><B>FK_NAME</B> String => foreign key name (may be <code>null</code>) 4144 * <LI><B>PK_NAME</B> String => parent key name (may be <code>null</code>) 4145 * <LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key 4146 * constraints be deferred until commit 4147 * <UL> 4148 * <LI> importedKeyInitiallyDeferred - see SQL92 for definition 4149 * <LI> importedKeyInitiallyImmediate - see SQL92 for definition 4150 * <LI> importedKeyNotDeferrable - see SQL92 for definition 4151 * </UL> 4152 * </OL> 4153 * 4154 * <!-- start release-specific documentation --> 4155 * <div class="ReleaseSpecificDocumentation"> 4156 * <h3>HSQLDB-Specific Information:</h3> <p> 4157 * 4158 * HSQLDB supports the SQL Standard. It treats unquoted identifiers as 4159 * case insensitive in SQL and stores 4160 * them in upper case; it treats quoted identifiers as case sensitive and 4161 * stores them verbatim. All JDBCDatabaseMetaData methods perform 4162 * case-sensitive comparison between name (pattern) arguments and the 4163 * corresponding identifier values as they are stored in the database. 4164 * Therefore, care must be taken to specify name arguments precisely 4165 * (including case) as they are stored in the database. <p> 4166 * 4167 * Since 1.7.2, this feature is supported by default. If the jar is 4168 * compiled without org.hsqldb.dbinfo.DatabaseInformationMain, the feature is 4169 * not supported. The default implementation is 4170 * {@link org.hsqldb.dbinfo.DatabaseInformationMain}. 4171 * </div> 4172 * <!-- end release-specific documentation --> 4173 * 4174 * @param parentCatalog a catalog name; must match the catalog name 4175 * as it is stored in the database; "" retrieves those without a 4176 * catalog; <code>null</code> means drop catalog name from the selection criteria 4177 * @param parentSchema a schema name; must match the schema name as 4178 * it is stored in the database; "" retrieves those without a schema; 4179 * <code>null</code> means drop schema name from the selection criteria 4180 * @param parentTable the name of the table that exports the key; must match 4181 * the table name as it is stored in the database 4182 * @param foreignCatalog a catalog name; must match the catalog name as 4183 * it is stored in the database; "" retrieves those without a 4184 * catalog; <code>null</code> means drop catalog name from the selection criteria 4185 * @param foreignSchema a schema name; must match the schema name as it 4186 * is stored in the database; "" retrieves those without a schema; 4187 * <code>null</code> means drop schema name from the selection criteria 4188 * @param foreignTable the name of the table that imports the key; must match 4189 * the table name as it is stored in the database 4190 * @return <code>ResultSet</code> - each row is a foreign key column description 4191 * @exception SQLException if a database access error occurs 4192 * @see #getImportedKeys 4193 * @see #supportsMixedCaseQuotedIdentifiers 4194 * @see #storesUpperCaseIdentifiers 4195 */ getCrossReference( String parentCatalog, String parentSchema, String parentTable, String foreignCatalog, String foreignSchema, String foreignTable)4196 public ResultSet getCrossReference( 4197 String parentCatalog, String parentSchema, String parentTable, 4198 String foreignCatalog, String foreignSchema, 4199 String foreignTable) throws SQLException { 4200 4201 if (parentTable == null) { 4202 throw JDBCUtil.nullArgument("parentTable"); 4203 } 4204 4205 if (foreignTable == null) { 4206 throw JDBCUtil.nullArgument("foreignTable"); 4207 } 4208 parentCatalog = translateCatalog(parentCatalog); 4209 foreignCatalog = translateCatalog(foreignCatalog); 4210 parentSchema = translateSchema(parentSchema); 4211 foreignSchema = translateSchema(foreignSchema); 4212 4213 StringBuffer select = 4214 toQueryPrefix("SYSTEM_CROSSREFERENCE").append(and("PKTABLE_CAT", 4215 "=", parentCatalog)).append(and("PKTABLE_SCHEM", "=", 4216 parentSchema)).append(and("PKTABLE_NAME", "=", 4217 parentTable)).append(and("FKTABLE_CAT", "=", 4218 foreignCatalog)).append(and("FKTABLE_SCHEM", "=", 4219 foreignSchema)).append(and("FKTABLE_NAME", 4220 "=", foreignTable)); 4221 4222 // by default, query already returns the table ordered by 4223 // FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and KEY_SEQ. 4224 return execute(select.toString()); 4225 } 4226 4227 /** 4228 * Retrieves a description of all the (JDBC4 clarification:) data types supported by 4229 * this database. They are ordered by DATA_TYPE and then by how 4230 * closely the data type maps to the corresponding JDBC SQL type. 4231 * 4232 * <P>(JDBC4 clarification:) If the database supports SQL distinct types, then getTypeInfo() will return 4233 * a single row with a TYPE_NAME of DISTINCT and a DATA_TYPE of Types.DISTINCT. 4234 * If the database supports SQL structured types, then getTypeInfo() will return 4235 * a single row with a TYPE_NAME of STRUCT and a DATA_TYPE of Types.STRUCT. 4236 * 4237 * <P>(JDBC4 clarification:) 4238 * <P>If SQL distinct or structured types are supported, then information on the 4239 * individual types may be obtained from the getUDTs() method. 4240 * 4241 * 4242 * <P>Each type description has the following columns: 4243 * <OL> 4244 * <LI><B>TYPE_NAME</B> String => Type name 4245 * <LI><B>DATA_TYPE</B> int => SQL data type from java.sql.Types 4246 * <LI><B>PRECISION</B> int => maximum precision 4247 * <LI><B>LITERAL_PREFIX</B> String => prefix used to quote a literal 4248 * (may be <code>null</code>) 4249 * <LI><B>LITERAL_SUFFIX</B> String => suffix used to quote a literal 4250 * (may be <code>null</code>) 4251 * <LI><B>CREATE_PARAMS</B> String => parameters used in creating 4252 * the type (may be <code>null</code>) 4253 * <LI><B>NULLABLE</B> short => can you use NULL for this type. 4254 * <UL> 4255 * <LI> typeNoNulls - does not allow NULL values 4256 * <LI> typeNullable - allows NULL values 4257 * <LI> typeNullableUnknown - nullability unknown 4258 * </UL> 4259 * <LI><B>CASE_SENSITIVE</B> boolean=> is it case sensitive. 4260 * <LI><B>SEARCHABLE</B> short => can you use "WHERE" based on this type: 4261 * <UL> 4262 * <LI> typePredNone - No support 4263 * <LI> typePredChar - Only supported with WHERE .. LIKE 4264 * <LI> typePredBasic - Supported except for WHERE .. LIKE 4265 * <LI> typeSearchable - Supported for all WHERE .. 4266 * </UL> 4267 * <LI><B>UNSIGNED_ATTRIBUTE</B> boolean => is it unsigned. 4268 * <LI><B>FIXED_PREC_SCALE</B> boolean => can it be a money value. 4269 * <LI><B>AUTO_INCREMENT</B> boolean => can it be used for an 4270 * auto-increment value. 4271 * <LI><B>LOCAL_TYPE_NAME</B> String => localized version of type name 4272 * (may be <code>null</code>) 4273 * <LI><B>MINIMUM_SCALE</B> short => minimum scale supported 4274 * <LI><B>MAXIMUM_SCALE</B> short => maximum scale supported 4275 * <LI><B>SQL_DATA_TYPE</B> int => unused 4276 * <LI><B>SQL_DATETIME_SUB</B> int => unused 4277 * <LI><B>NUM_PREC_RADIX</B> int => usually 2 or 10 4278 * </OL> 4279 * 4280 * <p>(JDBC4 clarification:) The PRECISION column represents the maximum column size that the server supports for the given datatype. 4281 * For numeric data, this is the maximum precision. For character data, this is the [maximum] length in characters. 4282 * For datetime datatypes, this is the [maximum] length in characters of the String representation (assuming the 4283 * maximum allowed precision of the fractional seconds component). For binary data, this is the [maximum] length in bytes. For the ROWID datatype, 4284 * this is the length in bytes[, as returned by the implementation-specific java.sql.RowId.getBytes() method]. JDBC 4.1 Deleted[0] JDBC 4.1 Added[Null] is returned for data types where the 4285 * column size is not applicable. 4286 * 4287 * <!-- start release-specific documentation --> 4288 * <div class="ReleaseSpecificDocumentation"> 4289 * <h3>HSQLDB-Specific Information:</h3> <p> 4290 * 4291 * Since 1.7.2, this feature is supported by default. If the jar is 4292 * compiled without org.hsqldb.dbinfo.DatabaseInformationMain, the feature is 4293 * not supported. The default implementation is 4294 * {@link org.hsqldb.dbinfo.DatabaseInformationMain}. 4295 * </div> 4296 * <!-- end release-specific documentation --> 4297 * 4298 * @return a <code>ResultSet</code> object in which each row is an SQL 4299 * type description 4300 * @exception SQLException if a database access error occurs 4301 */ getTypeInfo()4302 public ResultSet getTypeInfo() throws SQLException { 4303 4304 // system table producer returns rows in contract order 4305 return executeSelect("SYSTEM_TYPEINFO", null); 4306 } 4307 4308 /** 4309 * Retrieves a description of the given table's indices and statistics. They are 4310 * ordered by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION. 4311 * 4312 * <P>Each index column description has the following columns: 4313 * <OL> 4314 * <LI><B>TABLE_CAT</B> String => table catalog (may be <code>null</code>) 4315 * <LI><B>TABLE_SCHEM</B> String => table schema (may be <code>null</code>) 4316 * <LI><B>TABLE_NAME</B> String => table name 4317 * <LI><B>NON_UNIQUE</B> boolean => Can index values be non-unique. 4318 * false when TYPE is tableIndexStatistic 4319 * <LI><B>INDEX_QUALIFIER</B> String => index catalog (may be <code>null</code>); 4320 * <code>null</code> when TYPE is tableIndexStatistic 4321 * <LI><B>INDEX_NAME</B> String => index name; <code>null</code> when TYPE is 4322 * tableIndexStatistic 4323 * <LI><B>TYPE</B> short => index type: 4324 * <UL> 4325 * <LI> tableIndexStatistic - this identifies table statistics that are 4326 * returned in conjunction with a table's index descriptions 4327 * <LI> tableIndexClustered - this is a clustered index 4328 * <LI> tableIndexHashed - this is a hashed index 4329 * <LI> tableIndexOther - this is some other style of index 4330 * </UL> 4331 * <LI><B>ORDINAL_POSITION</B> short => column sequence number 4332 * within index; zero when TYPE is tableIndexStatistic 4333 * <LI><B>COLUMN_NAME</B> String => column name; <code>null</code> when TYPE is 4334 * tableIndexStatistic 4335 * <LI><B>ASC_OR_DESC</B> String => column sort sequence, "A" => ascending, 4336 * "D" => descending, may be <code>null</code> if sort sequence is not supported; 4337 * <code>null</code> when TYPE is tableIndexStatistic 4338 * <LI><B>CARDINALITY</B> int => When TYPE is tableIndexStatistic, then 4339 * this is the number of rows in the table; otherwise, it is the 4340 * number of unique values in the index. 4341 * <LI><B>PAGES</B> int => When TYPE is tableIndexStatistic then 4342 * this is the number of pages used for the table, otherwise it 4343 * is the number of pages used for the current index. 4344 * <LI><B>FILTER_CONDITION</B> String => Filter condition, if any. 4345 * (may be <code>null</code>) 4346 * </OL> 4347 * 4348 * <!-- start release-specific documentation --> 4349 * <div class="ReleaseSpecificDocumentation"> 4350 * <h3>HSQLDB-Specific Information:</h3> <p> 4351 * 4352 * HSQLDB supports the SQL Standard. It treats unquoted identifiers as 4353 * case insensitive in SQL and stores 4354 * them in upper case; it treats quoted identifiers as case sensitive and 4355 * stores them verbatim. All JDBCDatabaseMetaData methods perform 4356 * case-sensitive comparison between name (pattern) arguments and the 4357 * corresponding identifier values as they are stored in the database. 4358 * Therefore, care must be taken to specify name arguments precisely 4359 * (including case) as they are stored in the database. <p> 4360 * 4361 * Since 1.7.2, this feature is supported by default. If the jar is 4362 * compiled without org.hsqldb.dbinfo.DatabaseInformationMain, the feature is 4363 * not supported. The default implementation is 4364 * {@link org.hsqldb.dbinfo.DatabaseInformationMain}. 4365 * </div> 4366 * <!-- end release-specific documentation --> 4367 * 4368 * @param catalog a catalog name; must match the catalog name as it 4369 * is stored in this database; "" retrieves those without a catalog; 4370 * <code>null</code> means that the catalog name should not be used to narrow 4371 * the search 4372 * @param schema a schema name; must match the schema name 4373 * as it is stored in this database; "" retrieves those without a schema; 4374 * <code>null</code> means that the schema name should not be used to narrow 4375 * the search 4376 * @param table a table name; must match the table name as it is stored 4377 * in this database 4378 * @param unique when true, return only indices for unique values; 4379 * when false, return indices regardless of whether unique or not 4380 * @param approximate when true, result is allowed to reflect approximate 4381 * or out of data values; when false, results are requested to be 4382 * accurate 4383 * @return <code>ResultSet</code> - each row is an index column description 4384 * @exception SQLException if a database access error occurs 4385 * @see #supportsMixedCaseQuotedIdentifiers 4386 * @see #storesUpperCaseIdentifiers 4387 */ getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate)4388 public ResultSet getIndexInfo(String catalog, String schema, String table, 4389 boolean unique, 4390 boolean approximate) throws SQLException { 4391 4392 if (table == null) { 4393 throw JDBCUtil.nullArgument("table"); 4394 } 4395 catalog = translateCatalog(catalog); 4396 schema = translateSchema(schema); 4397 4398 Boolean nu = (unique) ? Boolean.FALSE 4399 : null; 4400 StringBuffer select = 4401 toQueryPrefix("SYSTEM_INDEXINFO").append(and("TABLE_CAT", "=", 4402 catalog)).append(and("TABLE_SCHEM", "=", 4403 schema)).append(and("TABLE_NAME", "=", 4404 table)).append(and("NON_UNIQUE", "=", 4405 nu)); 4406 4407 // By default, this query already returns the table ordered by 4408 // NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION... 4409 return execute(select.toString()); 4410 } 4411 4412 //--------------------------JDBC 2.0----------------------------- 4413 4414 /** 4415 * Retrieves whether this database supports the given result set type. 4416 * 4417 * @param type defined in <code>java.sql.ResultSet</code> 4418 * @return <code>true</code> if so; <code>false</code> otherwise 4419 * @exception SQLException if a database access error occurs 4420 * @see JDBCConnection 4421 * @since JDK 1.2 (JDK 1.1.x developers: read the overview 4422 * for JDBCDatabaseMetaData) 4423 */ supportsResultSetType(int type)4424 public boolean supportsResultSetType(int type) throws SQLException { 4425 return (type == JDBCResultSet.TYPE_FORWARD_ONLY 4426 || type == JDBCResultSet.TYPE_SCROLL_INSENSITIVE); 4427 } 4428 4429 /** 4430 * Retrieves whether this database supports the given concurrency type 4431 * in combination with the given result set type. 4432 * 4433 * @param type defined in <code>java.sql.ResultSet</code> 4434 * @param concurrency type defined in <code>java.sql.ResultSet</code> 4435 * @return <code>true</code> if so; <code>false</code> otherwise 4436 * @exception SQLException if a database access error occurs 4437 * @see JDBCConnection 4438 * @since JDK 1.2 (JDK 1.1.x developers: read the overview 4439 * for JDBCDatabaseMetaData) 4440 */ supportsResultSetConcurrency(int type, int concurrency)4441 public boolean supportsResultSetConcurrency(int type, 4442 int concurrency) throws SQLException { 4443 4444 return supportsResultSetType(type) 4445 && (concurrency == JDBCResultSet.CONCUR_READ_ONLY 4446 || concurrency == JDBCResultSet.CONCUR_UPDATABLE); 4447 } 4448 4449 /** 4450 * 4451 * Retrieves whether for the given type of <code>ResultSet</code> object, 4452 * the result set's own updates are visible. 4453 * 4454 * <!-- start release-specific documentation --> 4455 * <div class="ReleaseSpecificDocumentation"> 4456 * <h3>HSQLDB-Specific Information:</h3> <p> 4457 * Updates to ResultSet rows are not visible after moving from the updated 4458 * row. 4459 * </div> 4460 * <!-- end release-specific documentation --> 4461 * @param type the <code>ResultSet</code> type; one of 4462 * <code>ResultSet.TYPE_FORWARD_ONLY</code>, 4463 * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or 4464 * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> 4465 * @return <code>true</code> if updates are visible for the given result set type; 4466 * <code>false</code> otherwise 4467 * @exception SQLException if a database access error occurs 4468 * @since JDK 1.2 (JDK 1.1.x developers: read the overview 4469 * for JDBCDatabaseMetaData) 4470 */ ownUpdatesAreVisible(int type)4471 public boolean ownUpdatesAreVisible(int type) throws SQLException { 4472 return false; 4473 } 4474 4475 /** 4476 * Retrieves whether a result set's own deletes are visible. 4477 * 4478 * <!-- start release-specific documentation --> 4479 * <div class="ReleaseSpecificDocumentation"> 4480 * <h3>HSQLDB-Specific Information:</h3> <p> 4481 * 4482 * Rows deleted from the ResultSet are still visible after moving from the 4483 * deleted row. 4484 * </div> 4485 * <!-- end release-specific documentation --> 4486 * @param type the <code>ResultSet</code> type; one of 4487 * <code>ResultSet.TYPE_FORWARD_ONLY</code>, 4488 * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or 4489 * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> 4490 * @return <code>true</code> if deletes are visible for the given result set type; 4491 * <code>false</code> otherwise 4492 * @exception SQLException if a database access error occurs 4493 * @since JDK 1.2 (JDK 1.1.x developers: read the overview 4494 * for JDBCDatabaseMetaData) 4495 */ ownDeletesAreVisible(int type)4496 public boolean ownDeletesAreVisible(int type) throws SQLException { 4497 return false; 4498 } 4499 4500 /** 4501 * Retrieves whether a result set's own inserts are visible. 4502 * 4503 * <!-- start release-specific documentation --> 4504 * <div class="ReleaseSpecificDocumentation"> 4505 * <h3>HSQLDB-Specific Information:</h3> <p> 4506 * 4507 * Rows added to a ResultSet are not visible after moving from the 4508 * insert row; this method always returns <code>false</code>. 4509 * </div> 4510 * <!-- end release-specific documentation --> 4511 * @param type the <code>ResultSet</code> type; one of 4512 * <code>ResultSet.TYPE_FORWARD_ONLY</code>, 4513 * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or 4514 * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> 4515 * @return <code>true</code> if inserts are visible for the given result set type; 4516 * <code>false</code> otherwise 4517 * @exception SQLException if a database access error occurs 4518 * @since JDK 1.2 (JDK 1.1.x developers: read the overview 4519 * for JDBCDatabaseMetaData) 4520 */ ownInsertsAreVisible(int type)4521 public boolean ownInsertsAreVisible(int type) throws SQLException { 4522 return false; 4523 } 4524 4525 /** 4526 * Retrieves whether updates made by others are visible. 4527 * 4528 * <!-- start release-specific documentation --> 4529 * <div class="ReleaseSpecificDocumentation"> 4530 * <h3>HSQLDB-Specific Information:</h3> <p> 4531 * 4532 * Updates made by other connections or the same connection while the 4533 * ResultSet is open are not visible in the ResultSet. 4534 * </div> 4535 * <!-- end release-specific documentation --> 4536 * @param type the <code>ResultSet</code> type; one of 4537 * <code>ResultSet.TYPE_FORWARD_ONLY</code>, 4538 * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or 4539 * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> 4540 * @return <code>true</code> if updates made by others 4541 * are visible for the given result set type; 4542 * <code>false</code> otherwise 4543 * @exception SQLException if a database access error occurs 4544 * @since JDK 1.2 (JDK 1.1.x developers: read the overview 4545 * for JDBCDatabaseMetaData) 4546 */ othersUpdatesAreVisible(int type)4547 public boolean othersUpdatesAreVisible(int type) throws SQLException { 4548 return false; 4549 } 4550 4551 /** 4552 * Retrieves whether deletes made by others are visible. 4553 * 4554 * <!-- start release-specific documentation --> 4555 * <div class="ReleaseSpecificDocumentation"> 4556 * <h3>HSQLDB-Specific Information:</h3> <p> 4557 * 4558 * Deletes made by other connections or the same connection while the 4559 * ResultSet is open are not visible in the ResultSet. 4560 * </div> 4561 * <!-- end release-specific documentation --> 4562 * @param type the <code>ResultSet</code> type; one of 4563 * <code>ResultSet.TYPE_FORWARD_ONLY</code>, 4564 * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or 4565 * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> 4566 * @return <code>true</code> if deletes made by others 4567 * are visible for the given result set type; 4568 * <code>false</code> otherwise 4569 * @exception SQLException if a database access error occurs 4570 * @since JDK 1.2 (JDK 1.1.x developers: read the overview 4571 * for JDBCDatabaseMetaData) 4572 */ othersDeletesAreVisible(int type)4573 public boolean othersDeletesAreVisible(int type) throws SQLException { 4574 return false; 4575 } 4576 4577 /** 4578 * Retrieves whether inserts made by others are visible. 4579 * 4580 * <!-- start release-specific documentation --> 4581 * <div class="ReleaseSpecificDocumentation"> 4582 * <h3>HSQLDB-Specific Information:</h3> <p> 4583 * 4584 * Inserts made by other connections or the same connection while the 4585 * ResultSet is open are not visible in the ResultSet. 4586 * </div> 4587 * <!-- end release-specific documentation --> 4588 * @param type the <code>ResultSet</code> type; one of 4589 * <code>ResultSet.TYPE_FORWARD_ONLY</code>, 4590 * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or 4591 * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> 4592 * @return <code>true</code> if inserts made by others 4593 * are visible for the given result set type; 4594 * <code>false</code> otherwise 4595 * @exception SQLException if a database access error occurs 4596 * @since JDK 1.2 (JDK 1.1.x developers: read the overview 4597 * for JDBCDatabaseMetaData) 4598 */ othersInsertsAreVisible(int type)4599 public boolean othersInsertsAreVisible(int type) throws SQLException { 4600 return false; 4601 } 4602 4603 /** 4604 * Retrieves whether or not a visible row update can be detected by 4605 * calling the method <code>ResultSet.rowUpdated</code>. 4606 * 4607 * <!-- start release-specific documentation --> 4608 * <div class="ReleaseSpecificDocumentation"> 4609 * <h3>HSQLDB-Specific Information:</h3> <p> 4610 * 4611 * Updates made to the rows of the ResultSet are not detected by 4612 * calling the <code>ResultSet.rowUpdated</code>. 4613 * </div> 4614 * <!-- end release-specific documentation --> 4615 * @param type the <code>ResultSet</code> type; one of 4616 * <code>ResultSet.TYPE_FORWARD_ONLY</code>, 4617 * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or 4618 * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> 4619 * @return <code>true</code> if changes are detected by the result set type; 4620 * <code>false</code> otherwise 4621 * @exception SQLException if a database access error occurs 4622 * @since JDK 1.2 (JDK 1.1.x developers: read the overview 4623 * for JDBCDatabaseMetaData) 4624 */ updatesAreDetected(int type)4625 public boolean updatesAreDetected(int type) throws SQLException { 4626 return false; 4627 } 4628 4629 /** 4630 * Retrieves whether or not a visible row delete can be detected by 4631 * calling the method <code>ResultSet.rowDeleted</code>. If the method 4632 * <code>deletesAreDetected</code> returns <code>false</code>, it means that 4633 * deleted rows are removed from the result set. 4634 * 4635 * <!-- start release-specific documentation --> 4636 * <div class="ReleaseSpecificDocumentation"> 4637 * <h3>HSQLDB-Specific Information:</h3> <p> 4638 * 4639 * Deletes made to the rows of the ResultSet are not detected by 4640 * calling the <code>ResultSet.rowDeleted</code>. 4641 * </div> 4642 * <!-- end release-specific documentation --> 4643 * 4644 * 4645 * @param type the <code>ResultSet</code> type; one of 4646 * <code>ResultSet.TYPE_FORWARD_ONLY</code>, 4647 * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or 4648 * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> 4649 * @return <code>true</code> if deletes are detected by the given result set type; 4650 * <code>false</code> otherwise 4651 * @exception SQLException if a database access error occurs 4652 * @since JDK 1.2 (JDK 1.1.x developers: read the overview 4653 * for JDBCDatabaseMetaData) 4654 */ deletesAreDetected(int type)4655 public boolean deletesAreDetected(int type) throws SQLException { 4656 return false; 4657 } 4658 4659 /** 4660 * Retrieves whether or not a visible row insert can be detected 4661 * by calling the method <code>ResultSet.rowInserted</code>. 4662 * 4663 * <!-- start release-specific documentation --> 4664 * <div class="ReleaseSpecificDocumentation"> 4665 * <h3>HSQLDB-Specific Information:</h3> <p> 4666 * 4667 * Inserts made into the ResultSet are not visible and thus not detected by 4668 * calling the <code>ResultSet.rowInserted</code>. 4669 * </div> 4670 * <!-- end release-specific documentation --> 4671 * @param type the <code>ResultSet</code> type; one of 4672 * <code>ResultSet.TYPE_FORWARD_ONLY</code>, 4673 * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or 4674 * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> 4675 * @return <code>true</code> if changes are detected by the specified result 4676 * set type; <code>false</code> otherwise 4677 * @exception SQLException if a database access error occurs 4678 * @since JDK 1.2 (JDK 1.1.x developers: read the overview 4679 * for JDBCDatabaseMetaData) 4680 */ insertsAreDetected(int type)4681 public boolean insertsAreDetected(int type) throws SQLException { 4682 return false; 4683 } 4684 4685 /** 4686 * Retrieves whether this database supports batch updates. 4687 * 4688 * <!-- start release-specific documentation --> 4689 * <div class="ReleaseSpecificDocumentation"> 4690 * <h3>HSQLDB-Specific Information:</h3> <p> 4691 * 4692 * HSQLDB supports batch updates; 4693 * this method always returns <code>true</code>. 4694 * </div> 4695 * <!-- end release-specific documentation --> 4696 * @return <code>true</code> if this database supports batch updates; 4697 * <code>false</code> otherwise 4698 * @exception SQLException if a database access error occurs 4699 * @since JDK 1.2 (JDK 1.1.x developers: read the overview 4700 * for JDBCDatabaseMetaData) 4701 */ supportsBatchUpdates()4702 public boolean supportsBatchUpdates() throws SQLException { 4703 return true; 4704 } 4705 4706 /** 4707 * Retrieves a description of the user-defined types (UDTs) defined 4708 * in a particular schema. Schema-specific UDTs may have type 4709 * <code>JAVA_OBJECT</code>, <code>STRUCT</code>, 4710 * or <code>DISTINCT</code>. 4711 * 4712 * <P>Only types matching the catalog, schema, type name and type 4713 * criteria are returned. They are ordered by <code>DATA_TYPE</code>, 4714 * JDBC 4.1[<code>TYPE_CAT</code>,] <code>TYPE_SCHEM</code> and 4715 * <code>TYPE_NAME</code>. The type name parameter may be a fully-qualified 4716 * name. In this case, the catalog and schemaPattern parameters are 4717 * ignored. 4718 * 4719 * <P>Each type description has the following columns: 4720 * <OL> 4721 * <LI><B>TYPE_CAT</B> String => the type's catalog (may be <code>null</code>) 4722 * <LI><B>TYPE_SCHEM</B> String => type's schema (may be <code>null</code>) 4723 * <LI><B>TYPE_NAME</B> String => type name 4724 * <LI><B>CLASS_NAME</B> String => Java class name 4725 * <LI><B>DATA_TYPE</B> int => type value defined in java.sql.Types. 4726 * One of JAVA_OBJECT, STRUCT, or DISTINCT 4727 * <LI><B>REMARKS</B> String => explanatory comment on the type 4728 * <LI><B>BASE_TYPE</B> short => type code of the source type of a 4729 * DISTINCT type or the type that implements the user-generated 4730 * reference type of the SELF_REFERENCING_COLUMN of a structured 4731 * type as defined in java.sql.Types (<code>null</code> if DATA_TYPE is not 4732 * DISTINCT or not STRUCT with REFERENCE_GENERATION = USER_DEFINED) 4733 * </OL> 4734 * 4735 * <P><B>Note:</B> If the driver does not support UDTs, an empty 4736 * result set is returned. 4737 * 4738 * <!-- start release-specific documentation --> 4739 * <div class="ReleaseSpecificDocumentation"> 4740 * <h3>HSQLDB-Specific Information:</h3> <p> 4741 * 4742 * HSQLDB supports the SQL Standard. It treats unquoted identifiers as 4743 * case insensitive in SQL and stores 4744 * them in upper case; it treats quoted identifiers as case sensitive and 4745 * stores them verbatim. All JDBCDatabaseMetaData methods perform 4746 * case-sensitive comparison between name (pattern) arguments and the 4747 * corresponding identifier values as they are stored in the database. 4748 * Therefore, care must be taken to specify name arguments precisely 4749 * (including case) as they are stored in the database. <p> 4750 * 4751 * Starting with 2.0, DISTICT types are supported and are reported by this 4752 * method. 4753 * </div> 4754 * <!-- end release-specific documentation --> 4755 * @param catalog a catalog name; must match the catalog name as it 4756 * is stored in the database; "" retrieves those without a catalog; 4757 * <code>null</code> means that the catalog name should not be used to narrow 4758 * the search 4759 * @param schemaPattern a schema pattern name; must match the schema name 4760 * as it is stored in the database; "" retrieves those without a schema; 4761 * <code>null</code> means that the schema name should not be used to narrow 4762 * the search 4763 * @param typeNamePattern a type name pattern; must match the type name 4764 * as it is stored in the database; may be a fully qualified name 4765 * @param types a list of user-defined types (JAVA_OBJECT, 4766 * STRUCT, or DISTINCT) to include; <code>null</code> returns all types 4767 * @return <code>ResultSet</code> object in which each row describes a UDT 4768 * @exception SQLException if a database access error occurs 4769 * @see #getSearchStringEscape (JDBC4 clarification) 4770 * @since JDK 1.2 (JDK 1.1.x developers: read the overview 4771 * for JDBCDatabaseMetaData) 4772 */ getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types)4773 public ResultSet getUDTs(String catalog, String schemaPattern, 4774 String typeNamePattern, 4775 int[] types) throws SQLException { 4776 4777 if (wantsIsNull(typeNamePattern) 4778 || (types != null && types.length == 0)) { 4779 executeSelect("SYSTEM_UDTS", "0=1"); 4780 } 4781 catalog = translateCatalog(catalog); 4782 schemaPattern = translateSchema(schemaPattern); 4783 4784 StringBuffer select = 4785 toQueryPrefix("SYSTEM_UDTS").append(and("TYPE_CAT", "=", 4786 catalog)).append(and("TYPE_SCHEM", "LIKE", 4787 schemaPattern)).append(and("TYPE_NAME", 4788 "LIKE", typeNamePattern)); 4789 4790 if (types == null) { 4791 4792 // do not use to narrow search 4793 } else { 4794 select.append(" AND DATA_TYPE IN (").append( 4795 StringUtil.getList(types, ",", "")).append(')'); 4796 } 4797 4798 // By default, the query already returns a result ordered by 4799 // DATA_TYPE, TYPE_SCHEM, and TYPE_NAME... 4800 return execute(select.toString()); 4801 } 4802 4803 /** 4804 * Retrieves the connection that produced this metadata object. 4805 * <P> 4806 * @return the connection that produced this metadata object 4807 * @exception SQLException if a database access error occurs 4808 * @since JDK 1.2 (JDK 1.1.x developers: read the overview 4809 * for JDBCDatabaseMetaData) 4810 */ getConnection()4811 public Connection getConnection() throws SQLException { 4812 return connection; 4813 } 4814 4815 // ------------------- JDBC 3.0 ------------------------- 4816 4817 /** 4818 * Retrieves whether this database supports savepoints. 4819 * 4820 * <!-- start release-specific documentation --> 4821 * <div class="ReleaseSpecificDocumentation"> 4822 * <h3>HSQLDB-Specific Information:</h3> <p> 4823 * 4824 * Beginning with 1.7.2, this SQL feature is supported 4825 * through JDBC as well as SQL. <p> 4826 * 4827 * </div> 4828 * <!-- end release-specific documentation --> 4829 * @return <code>true</code> if savepoints are supported; 4830 * <code>false</code> otherwise 4831 * @exception SQLException if a database access error occurs 4832 * @since JDK 1.4, HSQLDB 1.7 4833 */ supportsSavepoints()4834 public boolean supportsSavepoints() throws SQLException { 4835 return true; 4836 } 4837 4838 /** 4839 * Retrieves whether this database supports named parameters to callable 4840 * statements. 4841 * 4842 * <!-- start release-specific documentation --> 4843 * <div class="ReleaseSpecificDocumentation"> 4844 * <h3>HSQLDB-Specific Information:</h3> <p> 4845 * 4846 * Starting with 1.7.2, HSQLDB supports JDBC named parameters to 4847 * callable statements; this method returns true. <p> 4848 * 4849 * </div> 4850 * <!-- end release-specific documentation --> 4851 * @return <code>true</code> if named parameters are supported; 4852 * <code>false</code> otherwise 4853 * @exception SQLException if a database access error occurs 4854 * @since JDK 1.4, HSQLDB 1.7 4855 */ supportsNamedParameters()4856 public boolean supportsNamedParameters() throws SQLException { 4857 return true; 4858 } 4859 4860 /** 4861 * Retrieves whether it is possible to have multiple <code>ResultSet</code> objects 4862 * returned from a <code>CallableStatement</code> object 4863 * simultaneously. 4864 * 4865 * <!-- start release-specific documentation --> 4866 * <div class="ReleaseSpecificDocumentation"> 4867 * <h3>HSQLDB-Specific Information:</h3> <p> 4868 * 4869 * HSQLDB supports multiple ResultSet 4870 * objects returned from a <code>CallableStatement</code>; 4871 * this method always returns <code>true</code>. <p> 4872 * </div> 4873 * <!-- end release-specific documentation --> 4874 * @return <code>true</code> if a <code>CallableStatement</code> object 4875 * can return multiple <code>ResultSet</code> objects 4876 * simultaneously; <code>false</code> otherwise 4877 * @exception SQLException if a database access error occurs 4878 * @since JDK 1.4, HSQLDB 1.7 4879 */ supportsMultipleOpenResults()4880 public boolean supportsMultipleOpenResults() throws SQLException { 4881 return true; 4882 } 4883 4884 /** 4885 * Retrieves whether auto-generated keys can be retrieved after 4886 * a statement has been executed 4887 * 4888 * <!-- start release-specific documentation --> 4889 * <div class="ReleaseSpecificDocumentation"> 4890 * <h3>HSQLDB-Specific Information:</h3> <p> 4891 * 4892 * HSQLDB supports retrieval of 4893 * autogenerated keys through the JDBC interface; 4894 * this method always returns <code>true</code>. <p> 4895 * </div> 4896 * <!-- end release-specific documentation --> 4897 * @return <code>true</code> if auto-generated keys can be retrieved 4898 * after a statement has executed; <code>false</code> otherwise 4899 * <p>(JDBC4 Clarification:) 4900 * <p>If <code>true</code> is returned, the JDBC driver must support the 4901 * returning of auto-generated keys for at least SQL INSERT statements 4902 * <p> 4903 * @exception SQLException if a database access error occurs 4904 * @since JDK 1.4, HSQLDB 1.7 4905 */ supportsGetGeneratedKeys()4906 public boolean supportsGetGeneratedKeys() throws SQLException { 4907 return true; 4908 } 4909 4910 /** 4911 * Retrieves a description of the user-defined type (UDT) hierarchies defined in a 4912 * particular schema in this database. Only the immediate super type 4913 * sub type relationship is modeled. 4914 * <P> 4915 * Only supertype information for UDTs matching the catalog, 4916 * schema, and type name is returned. The type name parameter 4917 * may be a fully-qualified name. When the UDT name supplied is a 4918 * fully-qualified name, the catalog and schemaPattern parameters are 4919 * ignored. 4920 * <P> 4921 * If a UDT does not have a direct super type, it is not listed here. 4922 * A row of the <code>ResultSet</code> object returned by this method 4923 * describes the designated UDT and a direct supertype. A row has the following 4924 * columns: 4925 * <OL> 4926 * <LI><B>TYPE_CAT</B> String => the UDT's catalog (may be <code>null</code>) 4927 * <LI><B>TYPE_SCHEM</B> String => UDT's schema (may be <code>null</code>) 4928 * <LI><B>TYPE_NAME</B> String => type name of the UDT 4929 * <LI><B>SUPERTYPE_CAT</B> String => the direct super type's catalog 4930 * (may be <code>null</code>) 4931 * <LI><B>SUPERTYPE_SCHEM</B> String => the direct super type's schema 4932 * (may be <code>null</code>) 4933 * <LI><B>SUPERTYPE_NAME</B> String => the direct super type's name 4934 * </OL> 4935 * 4936 * <P><B>Note:</B> If the driver does not support type hierarchies, an 4937 * empty result set is returned. 4938 * 4939 * <!-- start release-specific documentation --> 4940 * <div class="ReleaseSpecificDocumentation"> 4941 * <h3>HSQLDB-Specific Information:</h3> <p> 4942 * 4943 * HSQLDB supports the SQL Standard. It treats unquoted identifiers as 4944 * case insensitive in SQL and stores 4945 * them in upper case; it treats quoted identifiers as case sensitive and 4946 * stores them verbatim. All JDBCDatabaseMetaData methods perform 4947 * case-sensitive comparison between name (pattern) arguments and the 4948 * corresponding identifier values as they are stored in the database. 4949 * Therefore, care must be taken to specify name arguments precisely 4950 * (including case) as they are stored in the database. <p> 4951 * 4952 * From 2.0, this feature is supported by default and return supertypes 4953 * for DOMAIN and DISTINCT types.<p> 4954 * 4955 * If the jar is 4956 * compiled without org.hsqldb.dbinfo.DatabaseInformationMain, the feature is 4957 * not supported. The default implementation is 4958 * {@link org.hsqldb.dbinfo.DatabaseInformationMain}. 4959 * </div> 4960 * <!-- end release-specific documentation --> 4961 * 4962 * @param catalog a catalog name; "" retrieves those without a catalog; 4963 * <code>null</code> means drop catalog name from the selection criteria 4964 * @param schemaPattern a schema name pattern; "" retrieves those 4965 * without a schema 4966 * @param typeNamePattern a UDT name pattern; may be a fully-qualified 4967 * name 4968 * @return a <code>ResultSet</code> object in which a row gives information 4969 * about the designated UDT 4970 * @throws SQLException if a database access error occurs 4971 * @see #getSearchStringEscape (JDBC4 clarification) 4972 * @since JDK 1.4, HSQLDB 1.7 4973 */ getSuperTypes( String catalog, String schemaPattern, String typeNamePattern)4974 public ResultSet getSuperTypes( 4975 String catalog, String schemaPattern, 4976 String typeNamePattern) throws SQLException { 4977 4978 if (wantsIsNull(typeNamePattern)) { 4979 return executeSelect("SYSTEM_SUPERTYPES", "0=1"); 4980 } 4981 catalog = translateCatalog(catalog); 4982 schemaPattern = translateSchema(schemaPattern); 4983 4984 StringBuffer select = toQueryPrefixNoSelect( 4985 "SELECT * FROM (SELECT USER_DEFINED_TYPE_CATALOG, USER_DEFINED_TYPE_SCHEMA, USER_DEFINED_TYPE_NAME," 4986 + "CAST (NULL AS INFORMATION_SCHEMA.SQL_IDENTIFIER), CAST (NULL AS INFORMATION_SCHEMA.SQL_IDENTIFIER), DATA_TYPE " 4987 + "FROM INFORMATION_SCHEMA.USER_DEFINED_TYPES " 4988 + "UNION SELECT DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME,NULL,NULL, DATA_TYPE " 4989 + "FROM INFORMATION_SCHEMA.DOMAINS) " 4990 + "AS SUPERTYPES(TYPE_CAT, TYPE_SCHEM, TYPE_NAME, SUPERTYPE_CAT, SUPERTYPE_SCHEM, SUPERTYPE_NAME) ").append( 4991 and("TYPE_CAT", "=", catalog)).append( 4992 and("TYPE_SCHEM", "LIKE", schemaPattern)).append( 4993 and("TYPE_NAME", "LIKE", typeNamePattern)); 4994 4995 return execute(select.toString()); 4996 } 4997 4998 /** 4999 * Retrieves a description of the table hierarchies defined in a particular 5000 * schema in this database. 5001 * 5002 * <P>Only supertable information for tables matching the catalog, schema 5003 * and table name are returned. The table name parameter may be a fully- 5004 * qualified name, in which case, the catalog and schemaPattern parameters 5005 * are ignored. If a table does not have a super table, it is not listed here. 5006 * Supertables have to be defined in the same catalog and schema as the 5007 * sub tables. Therefore, the type description does not need to include 5008 * this information for the supertable. 5009 * 5010 * <P>Each type description has the following columns: 5011 * <OL> 5012 * <LI><B>TABLE_CAT</B> String => the type's catalog (may be <code>null</code>) 5013 * <LI><B>TABLE_SCHEM</B> String => type's schema (may be <code>null</code>) 5014 * <LI><B>TABLE_NAME</B> String => type name 5015 * <LI><B>SUPERTABLE_NAME</B> String => the direct super type's name 5016 * </OL> 5017 * 5018 * <P><B>Note:</B> If the driver does not support type hierarchies, an 5019 * empty result set is returned. 5020 * 5021 * <!-- start release-specific documentation --> 5022 * <div class="ReleaseSpecificDocumentation"> 5023 * <h3>HSQLDB-Specific Information:</h3> <p> 5024 * 5025 * This method is intended for tables of structured types. 5026 * From 2.0 this method returns an empty ResultSet. 5027 * {@link org.hsqldb.dbinfo.DatabaseInformationMain}. 5028 * </div> 5029 * <!-- end release-specific documentation --> 5030 * 5031 * @param catalog a catalog name; "" retrieves those without a catalog; 5032 * <code>null</code> means drop catalog name from the selection criteria 5033 * @param schemaPattern a schema name pattern; "" retrieves those 5034 * without a schema 5035 * @param tableNamePattern a table name pattern; may be a fully-qualified 5036 * name 5037 * @return a <code>ResultSet</code> object in which each row is a type description 5038 * @throws SQLException if a database access error occurs 5039 * @see #getSearchStringEscape (JDBC4 clarification) 5040 * @since JDK 1.4, HSQLDB 1.7 5041 */ getSuperTables( String catalog, String schemaPattern, String tableNamePattern)5042 public ResultSet getSuperTables( 5043 String catalog, String schemaPattern, 5044 String tableNamePattern) throws SQLException { 5045 5046 // query with no result 5047 StringBuffer select = toQueryPrefixNoSelect( 5048 "SELECT TABLE_NAME AS TABLE_CAT, TABLE_NAME AS TABLE_SCHEM, TABLE_NAME, TABLE_NAME AS SUPERTABLE_NAME " 5049 + "FROM INFORMATION_SCHEMA.TABLES ").append( 5050 and("TABLE_NAME", "=", "")); 5051 5052 return execute(select.toString()); 5053 } 5054 5055 /** 5056 * Retrieves a description of the given attribute of the given type 5057 * for a user-defined type (UDT) that is available in the given schema 5058 * and catalog. 5059 * <P> 5060 * Descriptions are returned only for attributes of UDTs matching the 5061 * catalog, schema, type, and attribute name criteria. They are ordered by 5062 * JDBC 4.1[<code>TYPE_CAT</code>, ]<code>TYPE_SCHEM</code>, 5063 * <code>TYPE_NAME</code> and <code>ORDINAL_POSITION</code>. This description 5064 * does not contain inherited attributes. 5065 * <P> 5066 * The <code>ResultSet</code> object that is returned has the following 5067 * columns: 5068 * <OL> 5069 * <LI><B>TYPE_CAT</B> String => type catalog (may be <code>null</code>) 5070 * <LI><B>TYPE_SCHEM</B> String => type schema (may be <code>null</code>) 5071 * <LI><B>TYPE_NAME</B> String => type name 5072 * <LI><B>ATTR_NAME</B> String => attribute name 5073 * <LI><B>DATA_TYPE</B> int => attribute type SQL type from java.sql.Types 5074 * <LI><B>ATTR_TYPE_NAME</B> String => Data source dependent type name. 5075 * For a UDT, the type name is fully qualified. For a REF, the type name is 5076 * fully qualified and represents the target type of the reference type. 5077 * <LI><B>ATTR_SIZE</B> int => column size. For char or date 5078 * types this is the maximum number of characters; for numeric or 5079 * decimal types this is precision. 5080 * <LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits. Null is returned for data types where 5081 * DECIMAL_DIGITS is not applicable. 5082 * <LI><B>NUM_PREC_RADIX</B> int => Radix (typically either 10 or 2) 5083 * <LI><B>NULLABLE</B> int => whether NULL is allowed 5084 * <UL> 5085 * <LI> attributeNoNulls - might not allow NULL values 5086 * <LI> attributeNullable - definitely allows NULL values 5087 * <LI> attributeNullableUnknown - nullability unknown 5088 * </UL> 5089 * <LI><B>REMARKS</B> String => comment describing column (may be <code>null</code>) 5090 * <LI><B>ATTR_DEF</B> String => default value (may be <code>null</code>) 5091 * <LI><B>SQL_DATA_TYPE</B> int => unused 5092 * <LI><B>SQL_DATETIME_SUB</B> int => unused 5093 * <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the 5094 * maximum number of bytes in the column 5095 * <LI><B>ORDINAL_POSITION</B> int => index of JDBC 4.1 correction[the attribute in the UDT] 5096 * (starting at 1) 5097 * <LI><B>IS_NULLABLE</B> String => ISO rules are used to determine 5098 * the nullability for a column. 5099 * <UL> 5100 * <LI> YES --- if the JDBC 4.1 correction[attribute] can include NULLs 5101 * <LI> NO --- if the JDBC 4.1 correction[attribute] cannot include NULLs 5102 * <LI> empty string --- if the nullability for the 5103 * JDBC 4.1 correction[attribute] is unknown 5104 * </UL> 5105 * <LI><B>SCOPE_CATALOG</B> String => catalog of table that is the 5106 * scope of a reference attribute (<code>null</code> if DATA_TYPE isn't REF) 5107 * <LI><B>SCOPE_SCHEMA</B> String => schema of table that is the 5108 * scope of a reference attribute (<code>null</code> if DATA_TYPE isn't REF) 5109 * <LI><B>SCOPE_TABLE</B> String => table name that is the scope of a 5110 * reference attribute (<code>null</code> if the DATA_TYPE isn't REF) 5111 * <LI><B>SOURCE_DATA_TYPE</B> short => source type of a distinct type or user-generated 5112 * Ref type,SQL type from java.sql.Types (<code>null</code> if DATA_TYPE 5113 * isn't DISTINCT or user-generated REF) 5114 * </OL> 5115 * 5116 * <!-- start release-specific documentation --> 5117 * <div class="ReleaseSpecificDocumentation"> 5118 * <h3>HSQLDB-Specific Information:</h3> <p> 5119 * 5120 * This method is intended for attributes of structured types. 5121 * From 2.0 this method returns an empty ResultSet. 5122 * </div> 5123 * <!-- end release-specific documentation --> 5124 * 5125 * @param catalog a catalog name; must match the catalog name as it 5126 * is stored in the database; "" retrieves those without a catalog; 5127 * <code>null</code> means that the catalog name should not be used to narrow 5128 * the search 5129 * @param schemaPattern a schema name pattern; must match the schema name 5130 * as it is stored in the database; "" retrieves those without a schema; 5131 * <code>null</code> means that the schema name should not be used to narrow 5132 * the search 5133 * @param typeNamePattern a type name pattern; must match the 5134 * type name as it is stored in the database 5135 * @param attributeNamePattern an attribute name pattern; must match the attribute 5136 * name as it is declared in the database 5137 * @return a <code>ResultSet</code> object in which each row is an 5138 * attribute description 5139 * @exception SQLException if a database access error occurs 5140 * @see #getSearchStringEscape 5141 * @since JDK 1.4, HSQLDB 1.7 5142 */ getAttributes( String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern)5143 public ResultSet getAttributes( 5144 String catalog, String schemaPattern, String typeNamePattern, 5145 String attributeNamePattern) throws SQLException { 5146 5147 StringBuffer select = toQueryPrefixNoSelect( 5148 "SELECT TABLE_NAME AS TYPE_CAT, TABLE_NAME AS TYPE_SCHME, TABLE_NAME AS TYPE_NAME, " 5149 + "TABLE_NAME AS ATTR_NAME, CAST(0 AS INTEGER) AS DATA_TYPE, TABLE_NAME AS ATTR_TYPE_NAME, " 5150 + "CAST(0 AS INTEGER) AS ATTR_SIZE, CAST(0 AS INTEGER) AS DECIMAL_DIGITS, " 5151 + "CAST(0 AS INTEGER) AS NUM_PREC_RADIX, CAST(0 AS INTEGER) AS NULLABLE, " 5152 + "'' AS REMARK, '' AS ATTR_DEF, CAST(0 AS INTEGER) AS SQL_DATA_TYPE, " 5153 + "CAST(0 AS INTEGER) AS SQL_DATETIME_SUB, CAST(0 AS INTEGER) AS CHAR_OCTECT_LENGTH, " 5154 + "CAST(0 AS INTEGER) AS ORDINAL_POSITION, '' AS NULLABLE, " 5155 + "'' AS SCOPE_CATALOG, '' AS SCOPE_SCHEMA, '' AS SCOPE_TABLE, " 5156 + "CAST(0 AS SMALLINT) AS SCOPE_DATA_TYPE " 5157 + "FROM INFORMATION_SCHEMA.TABLES ").append( 5158 and("TABLE_NAME", "=", "")); 5159 5160 return execute(select.toString()); 5161 } 5162 5163 /** 5164 * Retrieves whether this database supports the given result set holdability. 5165 * 5166 * <!-- start release-specific documentation --> 5167 * <div class="ReleaseSpecificDocumentation"> 5168 * <h3>HSQLDB-Specific Information:</h3> <p> 5169 * 5170 * HSQLDB returns true for both alternatives. <p> 5171 * 5172 * </div> 5173 * <!-- end release-specific documentation --> 5174 * @param holdability one of the following constants: 5175 * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or 5176 * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code> 5177 * @return <code>true</code> if so; <code>false</code> otherwise 5178 * @exception SQLException if a database access error occurs 5179 * @see JDBCConnection 5180 * @since JDK 1.4, HSQLDB 1.7 5181 */ supportsResultSetHoldability( int holdability)5182 public boolean supportsResultSetHoldability( 5183 int holdability) throws SQLException { 5184 return holdability == JDBCResultSet.HOLD_CURSORS_OVER_COMMIT 5185 || holdability == JDBCResultSet.CLOSE_CURSORS_AT_COMMIT; 5186 } 5187 5188 /** 5189 * (JDBC4 clarification:) 5190 * Retrieves this database's default holdability for <code>ResultSet</code> 5191 * objects. 5192 * 5193 * <!-- start release-specific documentation --> 5194 * <div class="ReleaseSpecificDocumentation"> 5195 * <h3>HSQLDB-Specific Information:</h3> <p> 5196 * 5197 * HSQLDB defaults to HOLD_CURSORS_OVER_COMMIT for CONSUR_READ_ONLY 5198 * ResultSet objects. 5199 * If the ResultSet concurrency is CONCUR_UPDATABLE, then holdability is 5200 * is enforced as CLOSE_CURSORS_AT_COMMIT. <p> 5201 * 5202 * </div> 5203 * <!-- end release-specific documentation --> 5204 * 5205 * @return the default holdability; either 5206 * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or 5207 * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code> 5208 * @exception SQLException if a database access error occurs 5209 * @since JDK 1.4, HSQLDB 1.7 5210 */ getResultSetHoldability()5211 public int getResultSetHoldability() throws SQLException { 5212 return JDBCResultSet.HOLD_CURSORS_OVER_COMMIT; 5213 } 5214 5215 /** 5216 * Retrieves the major version number of the underlying database. 5217 * 5218 * <!-- start release-specific documentation --> 5219 * <div class="ReleaseSpecificDocumentation"> 5220 * <h3>HSQLDB-Specific Information:</h3> <p> 5221 * Returns the major version 5222 * </div> 5223 * <!-- end release-specific documentation --> 5224 * @return the underlying database's major version 5225 * @exception SQLException if a database access error occurs 5226 * @since JDK 1.4, HSQLDB 1.7 5227 */ getDatabaseMajorVersion()5228 public int getDatabaseMajorVersion() throws SQLException { 5229 5230 ResultSet rs = execute("call database_version()"); 5231 5232 rs.next(); 5233 5234 String v = rs.getString(1); 5235 5236 rs.close(); 5237 5238 return Integer.parseInt(v.substring(0, v.indexOf("."))); 5239 } 5240 5241 /** 5242 * Retrieves the minor version number of the underlying database. 5243 * 5244 * <!-- start release-specific documentation --> 5245 * <div class="ReleaseSpecificDocumentation"> 5246 * <h3>HSQLDB-Specific Information:</h3> <p> 5247 * 5248 * This returns the digit after the first point in version. 5249 * </div> 5250 * <!-- end release-specific documentation --> 5251 * @return underlying database's minor version 5252 * @exception SQLException if a database access error occurs 5253 * @since JDK 1.4, HSQLDB 1.7 5254 */ getDatabaseMinorVersion()5255 public int getDatabaseMinorVersion() throws SQLException { 5256 5257 ResultSet rs = execute("call database_version()"); 5258 5259 rs.next(); 5260 5261 String v = rs.getString(1); 5262 5263 rs.close(); 5264 5265 int start = v.indexOf(".") + 1; 5266 5267 return Integer.parseInt(v.substring(start, v.indexOf(".", start))); 5268 } 5269 5270 /** 5271 * Retrieves the major JDBC version number for this 5272 * driver. 5273 * 5274 * <!-- start release-specific documentation --> 5275 * <div class="ReleaseSpecificDocumentation"> 5276 * <h3>HSQLDB-Specific Information:</h3> <p> 5277 * </div> 5278 * <!-- end release-specific documentation --> 5279 * 5280 * @return JDBC version major number 5281 * @exception SQLException if a database access error occurs 5282 * @since JDK 1.4, HSQLDB 1.7 5283 */ getJDBCMajorVersion()5284 public int getJDBCMajorVersion() throws SQLException { 5285 return JDBC_MAJOR; 5286 } 5287 5288 /** 5289 * Retrieves the minor JDBC version number for this 5290 * driver. 5291 * 5292 * <!-- start release-specific documentation --> 5293 * <div class="ReleaseSpecificDocumentation"> 5294 * <h3>HSQLDB-Specific Information:</h3> <p> 5295 * </div> 5296 * <!-- end release-specific documentation --> 5297 * @return JDBC version minor number 5298 * @exception SQLException if a database access error occurs 5299 * @since JDK 1.4, HSQLDB 1.7 5300 */ getJDBCMinorVersion()5301 public int getJDBCMinorVersion() throws SQLException { 5302 return 0; 5303 } 5304 5305 /** 5306 * (JDBC4 modified:) 5307 * Indicates whether the SQLSTATE returned by <code>SQLException.getSQLState</code> 5308 * is X/Open (now known as Open Group) SQL CLI or SQL:2003. 5309 * 5310 * <!-- start release-specific documentation --> 5311 * <div class="ReleaseSpecificDocumentation"> 5312 * <h3>HSQLDB-Specific Information:</h3> <p> 5313 * 5314 * HSQLDB returns <code>sqlStateSQL</code> under JDBC4 which is equivalent 5315 * to JDBC3 value of sqlStateSQL99. <p> 5316 * </div> 5317 * <!-- end release-specific documentation --> 5318 * @return the type of SQLSTATE; one of: 5319 * sqlStateXOpen or 5320 * sqlStateSQL 5321 * 5322 * <p>sqlStateSQL is new in JDBC4 and its value is the same as JDBC3 sqlStateSQL99 5323 * @throws SQLException if a database access error occurs 5324 * @since JDK 1.4, HSQLDB 1.7 5325 */ getSQLStateType()5326 public int getSQLStateType() throws SQLException { 5327 return sqlStateSQL99; 5328 } 5329 5330 /** 5331 * Indicates whether updates made to a LOB are made on a copy or directly 5332 * to the LOB. 5333 * 5334 * <!-- start release-specific documentation --> 5335 * <div class="ReleaseSpecificDocumentation"> 5336 * <h3>HSQLDB-Specific Information:</h3> <p> 5337 * 5338 * Updates to a LOB are made directly. This means the lobs in an updatable 5339 * ResultSet can be updated and the change is applied when the updateRow() 5340 * method is applied. Lobs created by calling the Connection methods 5341 * createClob() and createBlob() can be updated. The lob can then be sent to 5342 * the database in a PreparedStatement with an UPDATE or INSERT SQL 5343 * statement. 5344 * 5345 * </div> 5346 * <!-- end release-specific documentation --> 5347 * 5348 * @return <code>true</code> if updates are made to a copy of the LOB; 5349 * <code>false</code> if updates are made directly to the LOB 5350 * @throws SQLException if a database access error occurs 5351 * @since JDK 1.4, HSQLDB 1.7 5352 */ locatorsUpdateCopy()5353 public boolean locatorsUpdateCopy() throws SQLException { 5354 return false; 5355 } 5356 5357 /** 5358 * Retrieves whether this database supports statement pooling. 5359 * 5360 * <!-- start release-specific documentation --> 5361 * <div class="ReleaseSpecificDocumentation"> 5362 * <h3>HSQLDB-Specific Information:</h3> <p> 5363 * 5364 * Starting with 2.0, HSQLDB supports statement pooling when built under 5365 * JDK 1.6+. <p> 5366 * </div> 5367 * <!-- end release-specific documentation --> 5368 * 5369 * @return <code>true</code> if so; <code>false</code> otherwise 5370 * @throws SQLException if a database access error occurs 5371 * @since JDK 1.4, HSQLDB 1.7 5372 */ supportsStatementPooling()5373 public boolean supportsStatementPooling() throws SQLException { 5374 return (JDBC_MAJOR >= 4); 5375 } 5376 5377 //------------------------- JDBC 4.0 ----------------------------------- 5378 5379 /** 5380 * Indicates whether or not this data source supports the SQL <code>ROWID</code> type, 5381 * and if so the lifetime for which a <code>RowId</code> object remains valid. 5382 * <p> 5383 * The returned int values have the following relationship: 5384 * <pre> 5385 * ROWID_UNSUPPORTED < ROWID_VALID_OTHER < ROWID_VALID_TRANSACTION 5386 * < ROWID_VALID_SESSION < ROWID_VALID_FOREVER 5387 * </pre> 5388 * so conditional logic such as 5389 * <pre> 5390 * if (metadata.getRowIdLifetime() > DatabaseMetaData.ROWID_VALID_TRANSACTION) 5391 * </pre> 5392 * can be used. Valid Forever means valid across all Sessions, and valid for 5393 * a Session means valid across all its contained Transactions. 5394 * 5395 * @return the status indicating the lifetime of a <code>RowId</code> 5396 * @throws SQLException if a database access error occurs 5397 * @since JDK 1.6, HSQLDB 1.9 5398 */ 5399 //#ifdef JAVA6 getRowIdLifetime()5400 public RowIdLifetime getRowIdLifetime() throws SQLException { 5401 return RowIdLifetime.ROWID_UNSUPPORTED; 5402 } 5403 5404 //#endif JAVA6 5405 5406 /** 5407 * Retrieves the schema names available in this database. The results 5408 * are ordered by JDBC 4.1[<code>TABLE_CATALOG</code>] and 5409 * <code>TABLE_SCHEM</code>. 5410 * 5411 * <P>The schema columns are: 5412 * <OL> 5413 * <LI><B>TABLE_SCHEM</B> String => schema name 5414 * <LI><B>TABLE_CATALOG</B> String => catalog name (may be <code>null</code>) 5415 * </OL> 5416 * 5417 * 5418 * @param catalog a catalog name; must match the catalog name as it is stored 5419 * in the database;"" retrieves those without a catalog; null means catalog 5420 * name should not be used to narrow down the search. 5421 * @param schemaPattern a schema name; must match the schema name as it is 5422 * stored in the database; null means 5423 * schema name should not be used to narrow down the search. 5424 * @return a <code>ResultSet</code> object in which each row is a 5425 * schema description 5426 * @exception SQLException if a database access error occurs 5427 * @see #getSearchStringEscape 5428 * @since JDK 1.6, HSQLDB 1.9 5429 */ 5430 //#ifdef JAVA6 getSchemas(String catalog, String schemaPattern)5431 public ResultSet getSchemas(String catalog, 5432 String schemaPattern) throws SQLException { 5433 5434 StringBuffer select = 5435 toQueryPrefix("SYSTEM_SCHEMAS").append(and("TABLE_CATALOG", "=", 5436 catalog)).append(and("TABLE_SCHEM", "LIKE", schemaPattern)); 5437 5438 // By default, query already returns result in contract order 5439 return execute(select.toString()); 5440 } 5441 5442 //#endif JAVA6 5443 5444 /** 5445 * Retrieves whether this database supports invoking user-defined or vendor functions 5446 * using the stored procedure escape syntax. 5447 * 5448 * @return <code>true</code> if so; <code>false</code> otherwise 5449 * @exception SQLException if a database access error occurs 5450 * @since JDK 1.6, HSQLDB 1.9 5451 */ 5452 //#ifdef JAVA6 supportsStoredFunctionsUsingCallSyntax()5453 public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException { 5454 return true; 5455 } 5456 5457 //#endif JAVA6 5458 5459 /** @todo */ 5460 5461 /** 5462 * Retrieves whether a <code>SQLException</code> while autoCommit is <code>true</code> indicates 5463 * that all open ResultSets are closed, even ones that are holdable. When a <code>SQLException</code> occurs while 5464 * autocommit is <code>true</code>, it is vendor specific whether the JDBC driver responds with a commit operation, a 5465 * rollback operation, or by doing neither a commit nor a rollback. A potential result of this difference 5466 * is in whether or not holdable ResultSets are closed. 5467 * 5468 * @return <code>true</code> if so; <code>false</code> otherwise 5469 * @exception SQLException if a database access error occurs 5470 * @since JDK 1.6, HSQLDB 1.9 5471 */ 5472 //#ifdef JAVA6 autoCommitFailureClosesAllResultSets()5473 public boolean autoCommitFailureClosesAllResultSets() throws SQLException { 5474 return false; 5475 } 5476 5477 //#endif JAVA6 5478 5479 /** 5480 * Retrieves a list of the client info properties 5481 * that the driver supports. The result set contains the following columns 5482 * <p> 5483 * <ol> 5484 * <li><b>NAME</b> String=> The name of the client info property<br> 5485 * <li><b>MAX_LEN</b> int=> The maximum length of the value for the property<br> 5486 * <li><b>DEFAULT_VALUE</b> String=> The default value of the property<br> 5487 * <li><b>DESCRIPTION</b> String=> A description of the property. This will typically 5488 * contain information as to where this property is 5489 * stored in the database. 5490 * </ol> 5491 * <p> 5492 * The <code>ResultSet</code> is sorted by the NAME column 5493 * <p> 5494 * @return A <code>ResultSet</code> object; each row is a supported client info 5495 * property 5496 * <p> 5497 * @exception SQLException if a database access error occurs 5498 * <p> 5499 * @since JDK 1.6, HSQLDB 1.9 5500 */ 5501 //#ifdef JAVA6 getClientInfoProperties()5502 public ResultSet getClientInfoProperties() throws SQLException { 5503 5504 String s = 5505 "SELECT * FROM INFORMATION_SCHEMA.SYSTEM_CONNECTION_PROPERTIES"; 5506 5507 return execute(s); 5508 } 5509 5510 //#endif JAVA6 5511 5512 /** 5513 * Retrieves a description of the JDBC 4.1[ system and ]user functions available 5514 * in the given catalog. 5515 * <P> 5516 * Only system and user function descriptions matching the schema and 5517 * function name criteria are returned. They are ordered by 5518 * <code>FUNCTION_CAT</code>, <code>FUNCTION_SCHEM</code>, 5519 * <code>FUNCTION_NAME</code> and 5520 * <code>SPECIFIC_ NAME</code>. 5521 * 5522 * <P>Each function description has the the following columns: 5523 * <OL> 5524 * <LI><B>FUNCTION_CAT</B> String => function catalog (may be <code>null</code>) 5525 * <LI><B>FUNCTION_SCHEM</B> String => function schema (may be <code>null</code>) 5526 * <LI><B>FUNCTION_NAME</B> String => function name. This is the name 5527 * used to invoke the function 5528 * <LI><B>REMARKS</B> String => explanatory comment on the function 5529 * <LI><B>FUNCTION_TYPE</B> short => kind of function: 5530 * <UL> 5531 * <LI>functionResultUnknown - Cannot determine if a return value 5532 * or table will be returned 5533 * <LI> functionNoTable- Does not return a table 5534 * <LI> functionReturnsTable - Returns a table 5535 * </UL> 5536 * <LI><B>SPECIFIC_NAME</B> String => the name which uniquely identifies 5537 * this function within its schema. This is a user specified, or DBMS 5538 * generated, name that may be different then the <code>FUNCTION_NAME</code> 5539 * for example with overload functions 5540 * </OL> 5541 * <p> 5542 * A user may not have permission to execute any of the functions that are 5543 * returned by <code>getFunctions</code> 5544 * 5545 * @param catalog a catalog name; must match the catalog name as it 5546 * is stored in the database; "" retrieves those without a catalog; 5547 * <code>null</code> means that the catalog name should not be used to narrow 5548 * the search 5549 * @param schemaPattern a schema name pattern; must match the schema name 5550 * as it is stored in the database; "" retrieves those without a schema; 5551 * <code>null</code> means that the schema name should not be used to narrow 5552 * the search 5553 * @param functionNamePattern a function name pattern; must match the 5554 * function name as it is stored in the database 5555 * @return <code>ResultSet</code> - each row is a function description 5556 * @exception SQLException if a database access error occurs 5557 * @see #getSearchStringEscape 5558 * @since JDK 1.6, HSQLDB 1.9 5559 */ 5560 //#ifdef JAVA6 getFunctions( String catalog, String schemaPattern, String functionNamePattern)5561 public ResultSet getFunctions( 5562 String catalog, String schemaPattern, 5563 String functionNamePattern) throws SQLException { 5564 5565 StringBuffer sb = new StringBuffer(256); 5566 5567 sb.append("select ").append( 5568 "sp.procedure_cat as FUNCTION_CAT,").append( 5569 "sp.procedure_schem as FUNCTION_SCHEM,").append( 5570 "sp.procedure_name as FUNCTION_NAME,").append( 5571 "sp.remarks as REMARKS,").append("1 as FUNCTION_TYPE,").append( 5572 "sp.specific_name as SPECIFIC_NAME ").append( 5573 "from information_schema.system_procedures sp ").append( 5574 "where sp.procedure_type = 2 "); 5575 5576 if (wantsIsNull(functionNamePattern)) { 5577 return execute(sb.append("and 1=0").toString()); 5578 } 5579 schemaPattern = translateSchema(schemaPattern); 5580 5581 sb.append(and("sp.procedure_cat", "=", 5582 catalog)).append(and("sp.procedure_schem", "LIKE", 5583 schemaPattern)).append(and("sp.procedure_name", 5584 "LIKE", functionNamePattern)); 5585 5586 // By default, query already returns the result ordered by 5587 // FUNCTION_SCHEM, FUNCTION_NAME... 5588 return execute(sb.toString()); 5589 } 5590 5591 //#endif JAVA6 5592 5593 /** 5594 * Retrieves a description of the given catalog's system or user 5595 * function parameters and return type. 5596 * 5597 * <P>Only descriptions matching the schema, function and 5598 * parameter name criteria are returned. They are ordered by 5599 * <code>FUNCTION_CAT</code>, <code>FUNCTION_SCHEM</code>, 5600 * <code>FUNCTION_NAME</code> and 5601 * <code>SPECIFIC_ NAME</code>. Within this, the return value, 5602 * if any, is first. Next are the parameter descriptions in call 5603 * order. The column descriptions follow in column number order. 5604 * 5605 * <P>Each row in the <code>ResultSet</code> 5606 * is a parameter description, column description or 5607 * return type description with the following fields: 5608 * <OL> 5609 * <LI><B>FUNCTION_CAT</B> String => function catalog (may be <code>null</code>) 5610 * <LI><B>FUNCTION_SCHEM</B> String => function schema (may be <code>null</code>) 5611 * <LI><B>FUNCTION_NAME</B> String => function name. This is the name 5612 * used to invoke the function 5613 * <LI><B>COLUMN_NAME</B> String => column/parameter name 5614 * <LI><B>COLUMN_TYPE</B> Short => kind of column/parameter: 5615 * <UL> 5616 * <LI> functionColumnUnknown - nobody knows 5617 * <LI> functionColumnIn - IN parameter 5618 * <LI> functionColumnInOut - INOUT parameter 5619 * <LI> functionColumnOut - OUT parameter 5620 * <LI> functionColumnReturn - function return value 5621 * <LI> functionColumnResult - Indicates that the parameter or column 5622 * is a column in the <code>ResultSet</code> 5623 * </UL> 5624 * <LI><B>DATA_TYPE</B> int => SQL type from java.sql.Types 5625 * <LI><B>TYPE_NAME</B> String => SQL type name, for a UDT type the 5626 * type name is fully qualified 5627 * <LI><B>PRECISION</B> int => precision 5628 * <LI><B>LENGTH</B> int => length in bytes of data 5629 * <LI><B>SCALE</B> short => scale - null is returned for data types where 5630 * SCALE is not applicable. 5631 * <LI><B>RADIX</B> short => radix 5632 * <LI><B>NULLABLE</B> short => can it contain NULL. 5633 * <UL> 5634 * <LI> functionNoNulls - does not allow NULL values 5635 * <LI> functionNullable - allows NULL values 5636 * <LI> functionNullableUnknown - nullability unknown 5637 * </UL> 5638 * <LI><B>REMARKS</B> String => comment describing column/parameter 5639 * <LI><B>CHAR_OCTET_LENGTH</B> int => the maximum length of binary 5640 * and character based parameters or columns. For any other datatype the returned value 5641 * is a NULL 5642 * <LI><B>ORDINAL_POSITION</B> int => the ordinal position, starting 5643 * from 1, for the input and output parameters. A value of 0 5644 * is returned if this row describes the function's return value. 5645 * For result set columns, it is the 5646 * ordinal position of the column in the result set starting from 1. 5647 * <LI><B>IS_NULLABLE</B> String => ISO rules are used to determine 5648 * the nullability for a parameter or column. 5649 * <UL> 5650 * <LI> YES --- if the parameter or column can include NULLs 5651 * <LI> NO --- if the parameter or column cannot include NULLs 5652 * <LI> empty string --- if the nullability for the 5653 * parameter or column is unknown 5654 * </UL> 5655 * <LI><B>SPECIFIC_NAME</B> String => the name which uniquely identifies 5656 * this function within its schema. This is a user specified, or DBMS 5657 * generated, name that may be different then the <code>FUNCTION_NAME</code> 5658 * for example with overload functions 5659 * </OL> 5660 * 5661 * <p>The PRECISION column represents the specified column size for the given 5662 * parameter or column. 5663 * For numeric data, this is the maximum precision. For character data, this is the length in characters. 5664 * For datetime datatypes, this is the length in characters of the String representation (assuming the 5665 * maximum allowed precision of the fractional seconds component). For binary data, this is the length in bytes. For the ROWID datatype, 5666 * this is the length in bytes. Null is returned for data types where the 5667 * column size is not applicable. 5668 * @param catalog a catalog name; must match the catalog name as it 5669 * is stored in the database; "" retrieves those without a catalog; 5670 * <code>null</code> means that the catalog name should not be used to narrow 5671 * the search 5672 * @param schemaPattern a schema name pattern; must match the schema name 5673 * as it is stored in the database; "" retrieves those without a schema; 5674 * <code>null</code> means that the schema name should not be used to narrow 5675 * the search 5676 * @param functionNamePattern a procedure name pattern; must match the 5677 * function name as it is stored in the database 5678 * @param columnNamePattern a parameter name pattern; must match the 5679 * parameter or column name as it is stored in the database 5680 * @return <code>ResultSet</code> - each row describes a 5681 * user function parameter, column or return type 5682 * 5683 * @exception SQLException if a database access error occurs 5684 * @see #getSearchStringEscape 5685 * @since JDK 1.6, HSQLDB 1.9 5686 */ 5687 //#ifdef JAVA6 getFunctionColumns( String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern)5688 public ResultSet getFunctionColumns( 5689 String catalog, String schemaPattern, String functionNamePattern, 5690 String columnNamePattern) throws SQLException { 5691 5692 StringBuffer sb = new StringBuffer(256); 5693 5694 sb.append("select pc.procedure_cat as FUNCTION_CAT,").append( 5695 "pc.procedure_schem as FUNCTION_SCHEM,").append( 5696 "pc.procedure_name as FUNCTION_NAME,").append( 5697 "pc.column_name as COLUMN_NAME,").append( 5698 "case pc.column_type").append(" when 3 then 5").append( 5699 " when 4 then 3").append(" when 5 then 4").append( 5700 " else pc.column_type").append(" end as COLUMN_TYPE,").append( 5701 "pc.DATA_TYPE,").append("pc.TYPE_NAME,").append( 5702 "pc.PRECISION,").append("pc.LENGTH,").append("pc.SCALE,").append( 5703 "pc.RADIX,").append("pc.NULLABLE,").append("pc.REMARKS,").append( 5704 "pc.CHAR_OCTET_LENGTH,").append("pc.ORDINAL_POSITION,").append( 5705 "pc.IS_NULLABLE,").append("pc.SPECIFIC_NAME,").append( 5706 "case pc.column_type").append(" when 3 then 1").append( 5707 " else 0").append(" end AS COLUMN_GROUP ").append( 5708 "from information_schema.system_procedurecolumns pc ").append( 5709 "join (select procedure_schem,").append("procedure_name,").append( 5710 "specific_name ").append( 5711 "from information_schema.system_procedures ").append( 5712 "where procedure_type = 2) p ").append( 5713 "on pc.procedure_schem = p.procedure_schem ").append( 5714 "and pc.procedure_name = p.procedure_name ").append( 5715 "and pc.specific_name = p.specific_name ").append( 5716 "and ((pc.column_type = 3 and pc.column_name = '@p0') ").append( 5717 "or ").append("(pc.column_type <> 3)) "); 5718 5719 if (wantsIsNull(functionNamePattern) 5720 || wantsIsNull(columnNamePattern)) { 5721 return execute(sb.append("where 1=0").toString()); 5722 } 5723 schemaPattern = translateSchema(schemaPattern); 5724 5725 sb.append("where 1=1 ").append( 5726 and("pc.procedure_cat", "=", catalog)).append( 5727 and("pc.procedure_schem", "LIKE", schemaPattern)).append( 5728 and("pc.procedure_name", "LIKE", functionNamePattern)).append( 5729 and("pc.column_name", "LIKE", columnNamePattern)).append( 5730 " order by 1, 2, 3, 17, 18 , 15"); 5731 5732 // Order by FUNCTION_CAT, FUNCTION_SCHEM, FUNCTION_NAME, SPECIFIC_NAME 5733 // COLUMN_GROUP and ORDINAL_POSITION 5734 return execute(sb.toString()); 5735 } 5736 5737 //#endif JAVA6 5738 5739 /** 5740 * Returns an object that implements the given interface to allow access to non-standard methods, 5741 * or standard methods not exposed by the proxy. 5742 * The result may be either the object found to implement the interface or a proxy for that object. 5743 * If the receiver implements the interface then that is the object. If the receiver is a wrapper 5744 * and the wrapped object implements the interface then that is the object. Otherwise the object is 5745 * the result of calling <code>unwrap</code> recursively on the wrapped object. If the receiver is not a 5746 * wrapper and does not implement the interface, then an <code>SQLException</code> is thrown. 5747 * 5748 * @param iface A Class defining an interface that the result must implement. 5749 * @return an object that implements the interface. May be a proxy for the actual implementing object. 5750 * @throws java.sql.SQLException If no object found that implements the interface 5751 * @since JDK 1.6, HSQLDB 1.9 5752 */ 5753 //#ifdef JAVA6 5754 @SuppressWarnings("unchecked") unwrap(java.lang.Class<T> iface)5755 public <T>T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException { 5756 5757 if (isWrapperFor(iface)) { 5758 return (T) this; 5759 } 5760 5761 throw JDBCUtil.invalidArgument("iface: " + iface); 5762 } 5763 5764 //#endif JAVA6 5765 5766 /** 5767 * Returns true if this either implements the interface argument or is directly or indirectly a wrapper 5768 * for an object that does. Returns false otherwise. If this implements the interface then return true, 5769 * else if this is a wrapper then return the result of recursively calling <code>isWrapperFor</code> on the wrapped 5770 * object. If this does not implement the interface and is not a wrapper, return false. 5771 * This method should be implemented as a low-cost operation compared to <code>unwrap</code> so that 5772 * callers can use this method to avoid expensive <code>unwrap</code> calls that may fail. If this method 5773 * returns true then calling <code>unwrap</code> with the same argument should succeed. 5774 * 5775 * @param iface a Class defining an interface. 5776 * @return true if this implements the interface or directly or indirectly wraps an object that does. 5777 * @throws java.sql.SQLException if an error occurs while determining whether this is a wrapper 5778 * for an object with the given interface. 5779 * @since JDK 1.6, HSQLDB 1.9 5780 */ 5781 //#ifdef JAVA6 isWrapperFor( java.lang.Class<?> iface)5782 public boolean isWrapperFor( 5783 java.lang.Class<?> iface) throws java.sql.SQLException { 5784 return (iface != null && iface.isAssignableFrom(this.getClass())); 5785 } 5786 5787 //#endif JAVA6 5788 //--------------------------JDBC 4.1 ----------------------------- 5789 5790 /** 5791 * Retrieves a description of the pseudo or hidden columns available 5792 * in a given table within the specified catalog and schema. 5793 * Pseudo or hidden columns may not always be stored within 5794 * a table and are not visible in a ResultSet unless they are 5795 * specified in the query's outermost SELECT list. Pseudo or hidden 5796 * columns may not necessarily be able to be modified. If there are 5797 * no pseudo or hidden columns, an empty ResultSet is returned. 5798 * 5799 * <P>Only column descriptions matching the catalog, schema, table 5800 * and column name criteria are returned. They are ordered by 5801 * <code>TABLE_CAT</code>,<code>TABLE_SCHEM</code>, <code>TABLE_NAME</code> 5802 * and <code>COLUMN_NAME</code>. 5803 * 5804 * <P>Each column description has the following columns: 5805 * <OL> 5806 * <LI><B>TABLE_CAT</B> String => table catalog (may be <code>null</code>) 5807 * <LI><B>TABLE_SCHEM</B> String => table schema (may be <code>null</code>) 5808 * <LI><B>TABLE_NAME</B> String => table name 5809 * <LI><B>COLUMN_NAME</B> String => column name 5810 * <LI><B>DATA_TYPE</B> int => SQL type from java.sql.Types 5811 * <LI><B>COLUMN_SIZE</B> int => column size. 5812 * <LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits. Null is returned for data types where 5813 * DECIMAL_DIGITS is not applicable. 5814 * <LI><B>NUM_PREC_RADIX</B> int => Radix (typically either 10 or 2) 5815 * <LI><B>COLUMN_USAGE</B> String => The allowed usage for the column. The 5816 * value returned will correspond to the enum name returned by {@link java.sql.PseudoColumnUsage#name PseudoColumnUsage.name()} 5817 * <LI><B>REMARKS</B> String => comment describing column (may be <code>null</code>) 5818 * <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the 5819 * maximum number of bytes in the column 5820 * <LI><B>IS_NULLABLE</B> String => ISO rules are used to determine the nullability for a column. 5821 * <UL> 5822 * <LI> YES --- if the column can include NULLs 5823 * <LI> NO --- if the column cannot include NULLs 5824 * <LI> empty string --- if the nullability for the column is unknown 5825 * </UL> 5826 * </OL> 5827 * 5828 * <p>The COLUMN_SIZE column specifies the column size for the given column. 5829 * For numeric data, this is the maximum precision. For character data, this is the length in characters. 5830 * For datetime datatypes, this is the length in characters of the String representation (assuming the 5831 * maximum allowed precision of the fractional seconds component). For binary data, this is the length in bytes. For the ROWID datatype, 5832 * this is the length in bytes. Null is returned for data types where the 5833 * column size is not applicable. 5834 * 5835 * @param catalog a catalog name; must match the catalog name as it 5836 * is stored in the database; "" retrieves those without a catalog; 5837 * <code>null</code> means that the catalog name should not be used to narrow 5838 * the search 5839 * @param schemaPattern a schema name pattern; must match the schema name 5840 * as it is stored in the database; "" retrieves those without a schema; 5841 * <code>null</code> means that the schema name should not be used to narrow 5842 * the search 5843 * @param tableNamePattern a table name pattern; must match the 5844 * table name as it is stored in the database 5845 * @param columnNamePattern a column name pattern; must match the column 5846 * name as it is stored in the database 5847 * @return <code>ResultSet</code> - each row is a column description 5848 * @exception SQLException if a database access error occurs 5849 * @see java.sql.PseudoColumnUsage 5850 * @since JDK 1.7 M11 2010/09/10 (b123), HSQLDB 2.0.1 5851 */ getPseudoColumns( String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)5852 public ResultSet getPseudoColumns( 5853 String catalog, String schemaPattern, String tableNamePattern, 5854 String columnNamePattern) throws SQLException { 5855 throw JDBCUtil.notSupported(); 5856 } 5857 5858 /** 5859 * Retrieves whether a generated key will always be returned if the column 5860 * name(s) or index(es) specified for the auto generated key column(s) 5861 * are valid and the statement succeeds. The key that is returned may or 5862 * may not be based on the column(s) for the auto generated key. 5863 * Consult your JDBC driver documentation for additional details. 5864 * @return <code>true</code> if so; <code>false</code> otherwise 5865 * @exception SQLException if a database access error occurs 5866 * @since JDK 1.7 M11 2010/09/10 (b123), HSQLDB 2.0.1 5867 */ generatedKeyAlwaysReturned()5868 public boolean generatedKeyAlwaysReturned() throws SQLException { 5869 return true; 5870 } 5871 5872 //----------------------- Internal Implementation -------------------------- 5873 5874 /** Used by getBestRowIdentifier to avoid extra object construction */ 5875 static final Integer INT_COLUMNS_NO_NULLS = Integer.valueOf(columnNoNulls); 5876 5877 // ----------------------------------------------------------------------- 5878 // private attributes 5879 // ----------------------------------------------------------------------- 5880 5881 /** 5882 * The connection this object uses to retrieve database instance-specific 5883 * metadata. 5884 */ 5885 private JDBCConnection connection; 5886 5887 /** 5888 * Connection property for schema reporting. 5889 */ 5890 final private boolean useSchemaDefault; 5891 5892 /** 5893 * NULL related properties are updated on each call. 5894 */ 5895 private boolean concatNulls = true; 5896 private boolean nullsFirst = true; 5897 private boolean nullsOrder = true; 5898 5899 /** 5900 * A CSV list representing the SQL IN list to use when generating 5901 * queries for <code>getBestRowIdentifier</code> when the 5902 * <code>scope</code> argument is <code>bestRowSession</code>. 5903 * @since HSQLDB 1.7.2 5904 */ 5905 private static final String BRI_SESSION_SCOPE_IN_LIST = "(" 5906 + bestRowSession + ")"; 5907 5908 /** 5909 * A CSV list representing the SQL IN list to use when generating 5910 * queries for <code>getBestRowIdentifier</code> when the 5911 * <code>scope</code> argument is <code>bestRowTemporary</code>. 5912 * @since HSQLDB 1.7.2 5913 */ 5914 private static final String BRI_TEMPORARY_SCOPE_IN_LIST = "(" 5915 + bestRowTemporary + "," + bestRowTransaction + "," + bestRowSession 5916 + ")"; 5917 5918 /** 5919 * A CSV list representing the SQL IN list to use when generating 5920 * queries for <code>getBestRowIdentifier</code> when the 5921 * <code>scope</code> argument is <code>bestRowTransaction</code>. 5922 * @since HSQLDB 1.7.2 5923 */ 5924 private static final String BRI_TRANSACTION_SCOPE_IN_LIST = "(" 5925 + bestRowTransaction + "," + bestRowSession + ")"; 5926 5927 /** 5928 * "SELECT * FROM ". <p> 5929 * 5930 * This attribute is in support of methods that use SQL SELECT statements to 5931 * generate returned <code>ResultSet</code> objects. <p> 5932 * 5933 * @since HSQLDB 1.7.2 5934 */ 5935 private static final String selstar = "SELECT * FROM INFORMATION_SCHEMA."; 5936 5937 /** 5938 * " WHERE TRUE ". <p> 5939 * 5940 * This attribute is in support of methods that use SQL SELECT statements to 5941 * generate returned <code>ResultSet</code> objects. <p> 5942 * 5943 * A good optimizer will simply drop this when parsing a condition 5944 * expression. And it makes our code much easier to write, since we don't 5945 * have to check our "WHERE" clause productions as strictly for proper 5946 * conjunction: we just stick additional conjunctive predicates on the 5947 * end of this and Presto! Everything works :-) <p> 5948 * @since HSQLDB 1.7.2 5949 */ 5950 private static final String whereTrue = " WHERE TRUE"; 5951 5952 //#ifdef JAVA6 5953 public static final int JDBC_MAJOR = 4; 5954 5955 //#else 5956 /* 5957 public static final int JDBC_MAJOR = 3; 5958 */ 5959 5960 //#endif JAVA6 5961 5962 /** 5963 * Constructs a new <code>JDBCDatabaseMetaData</code> object using the 5964 * specified connection. This contructor is used by <code>JDBCConnection</code> 5965 * when producing a <code>DatabaseMetaData</code> object from a call to 5966 * {@link JDBCConnection#getMetaData() getMetaData}. 5967 * @param c the connection this object will use to retrieve 5968 * instance-specific metadata 5969 * @throws SQLException never - reserved for future use 5970 */ JDBCDatabaseMetaData(JDBCConnection c)5971 JDBCDatabaseMetaData(JDBCConnection c) throws SQLException { 5972 5973 // PRE: is non-null and not closed 5974 connection = c; 5975 useSchemaDefault = c.isInternal ? false 5976 : c.connProperties 5977 .isPropertyTrue(HsqlDatabaseProperties 5978 .url_default_schema); 5979 } 5980 5981 /** 5982 * Retrieves an "AND" predicate based on the (column) <code>id</code>, 5983 * <code>op</code>(erator) and<code>val</code>(ue) arguments to be 5984 * included in an SQL "WHERE" clause, using the conventions laid out for 5985 * JDBC DatabaseMetaData filter parameter values. <p> 5986 * 5987 * @return an "AND" predicate built from the arguments 5988 * @param id the simple, non-quoted identifier of a system table 5989 * column upon which to filter. <p> 5990 * 5991 * No checking is done for column name validity. <br> 5992 * It is assumed the system table column name is correct. <p> 5993 * 5994 * @param op the conditional operation to perform using the system table 5995 * column name value and the <code>val</code> argument. <p> 5996 * 5997 * @param val an object representing the value to use in some conditional 5998 * operation, op, between the column identified by the id argument 5999 * and this argument. <p> 6000 * 6001 * <UL> 6002 * <LI>null causes the empty string to be returned. <p> 6003 * 6004 * <LI>toString().length() == 0 causes the returned expression 6005 * to be built so that the IS NULL operation will occur 6006 * against the specified column. <p> 6007 * 6008 * <LI>instanceof String causes the returned expression to be 6009 * built so that the specified operation will occur between 6010 * the specified column and the specified value, converted to 6011 * an SQL string (single quoted, with internal single quotes 6012 * escaped by doubling). If <code>op</code> is "LIKE" and 6013 * <code>val</code> does not contain any "%" or "_" wild 6014 * card characters, then <code>op</code> is silently 6015 * converted to "=". <p> 6016 * 6017 * <LI>!instanceof String causes an expression to built so that 6018 * the specified operation will occur between the specified 6019 * column and <code>String.valueOf(val)</code>. <p> 6020 * 6021 * </UL> 6022 */ and(String id, String op, Object val)6023 private static String and(String id, String op, Object val) { 6024 6025 // The JDBC standard for pattern arguments seems to be: 6026 // 6027 // - pass null to mean ignore (do not include in query), 6028 // - pass "" to mean filter on <column-ident> IS NULL, 6029 // - pass "%" to filter on <column-ident> IS NOT NULL. 6030 // - pass sequence with "%" and "_" for wildcard matches 6031 // - when searching on values reported directly from DatabaseMetaData 6032 // results, typically an exact match is desired. In this case, it 6033 // is the client's responsibility to escape any reported "%" and "_" 6034 // characters using whatever DatabaseMetaData returns from 6035 // getSearchEscapeString(). In our case, this is the standard escape 6036 // character: '\'. Typically, '%' will rarely be encountered, but 6037 // certainly '_' is to be expected on a regular basis. 6038 // - checkme: what about the (silly) case where an identifier 6039 // has been declared such as: 'create table "xxx\_yyy"(...)'? 6040 // Must the client still escape the Java string like this: 6041 // "xxx\\\\_yyy"? 6042 // Yes: because otherwise the driver is expected to 6043 // construct something like: 6044 // select ... where ... like 'xxx\_yyy' escape '\' 6045 // which will try to match 'xxx_yyy', not 'xxx\_yyy' 6046 // Testing indicates that indeed, higher quality popular JDBC 6047 // database browsers do the escapes "properly." 6048 if (val == null) { 6049 return ""; 6050 } 6051 6052 StringBuffer sb = new StringBuffer(); 6053 boolean isStr = (val instanceof String); 6054 6055 if (isStr && ((String) val).length() == 0) { 6056 return sb.append(" AND ").append(id).append(" IS NULL").toString(); 6057 } 6058 6059 String v = isStr ? Type.SQL_VARCHAR.convertToSQLString(val) 6060 : String.valueOf(val); 6061 6062 sb.append(" AND ").append(id).append(' '); 6063 6064 // add the escape to like if required 6065 if (isStr && "LIKE".equalsIgnoreCase(op)) { 6066 if (v.indexOf('_') < 0 && v.indexOf('%') < 0) { 6067 6068 // then we can optimize. 6069 sb.append("=").append(' ').append(v); 6070 } else { 6071 sb.append("LIKE").append(' ').append(v); 6072 6073 if ((v.indexOf("\\_") >= 0) || (v.indexOf("\\%") >= 0)) { 6074 6075 // then client has requested at least one escape. 6076 sb.append(" ESCAPE '\\'"); 6077 } 6078 } 6079 } else { 6080 sb.append(op).append(' ').append(v); 6081 } 6082 6083 return sb.toString(); 6084 } 6085 6086 /** 6087 * The main SQL statement executor. All SQL destined for execution 6088 * ultimately goes through this method. <p> 6089 * 6090 * The sqlStatement field for the result is set autoClose to comply with 6091 * ResultSet.getStatement() semantics for result sets that are not from 6092 * a user supplied Statement object. (fredt) <p> 6093 * 6094 * @param sql SQL statement to execute 6095 * @return the result of issuing the statement 6096 * @throws SQLException is a database error occurs 6097 */ execute(String sql)6098 private ResultSet execute(String sql) throws SQLException { 6099 6100 // NOTE: 6101 // Need to create a JDBCStatement here so JDBCResultSet can return 6102 // its Statement object on call to getStatement(). 6103 // The native JDBCConnection.execute() method does not 6104 // automatically assign a Statement object for the ResultSet, but 6105 // JDBCStatement does. That is, without this, there is no way for the 6106 // JDBCResultSet to find its way back to its Connection (or Statement) 6107 // Also, cannot use single, shared JDBCStatement object, as each 6108 // fetchResult() closes any old JDBCResultSet before fetching the 6109 // next, causing the JDBCResultSet's Result object to be nullified 6110 final int scroll = JDBCResultSet.TYPE_SCROLL_INSENSITIVE; 6111 final int concur = JDBCResultSet.CONCUR_READ_ONLY; 6112 JDBCStatement st = (JDBCStatement) connection.createStatement(scroll, 6113 concur); 6114 6115 st.maxRows = -1; 6116 6117 ResultSet r = st.executeQuery(sql); 6118 6119 ((JDBCResultSet) r).autoClose = true; 6120 6121 return r; 6122 } 6123 6124 /** 6125 * An SQL statement executor that knows how to create a "SELECT 6126 * * FROM" statement, given a table name and a <em>where</em> clause.<p> 6127 * 6128 * If the <em>where</em> clause is null, it is omitted. <p> 6129 * 6130 * It is assumed that the table name is non-null, since this is a private 6131 * method. No check is performed. <p> 6132 * 6133 * @return the result of executing "SELECT * FROM " + table " " + where 6134 * @param table the name of a table to "select * from" 6135 * @param where the where condition for the select 6136 * @throws SQLException if database error occurs 6137 */ executeSelect(String table, String where)6138 private ResultSet executeSelect(String table, 6139 String where) throws SQLException { 6140 6141 String select = selstar + table; 6142 6143 if (where != null) { 6144 select += " WHERE " + where; 6145 } 6146 6147 return execute(select); 6148 } 6149 6150 /** 6151 * Retrieves "SELECT * FROM INFORMATION_SCHEMA.<table> WHERE 1=1" in string 6152 * buffer form. <p> 6153 * 6154 * This is a convenience method provided because, for most 6155 * <code>DatabaseMetaData</code> queries, this is the most suitable 6156 * thing upon which to start building. <p> 6157 * 6158 * @return an StringBuffer whose content is: 6159 * "SELECT * FROM <table> WHERE 1=1" 6160 * @param t the name of the table 6161 */ toQueryPrefix(String t)6162 private StringBuffer toQueryPrefix(String t) { 6163 6164 StringBuffer sb = new StringBuffer(255); 6165 6166 return sb.append(selstar).append(t).append(whereTrue); 6167 } 6168 6169 /** 6170 * Retrieves "<expression> WHERE 1=1" in string 6171 */ toQueryPrefixNoSelect(String t)6172 private StringBuffer toQueryPrefixNoSelect(String t) { 6173 6174 StringBuffer sb = new StringBuffer(255); 6175 6176 return sb.append(t).append(whereTrue); 6177 } 6178 6179 /** 6180 * Retrieves whether the JDBC <code>DatabaseMetaData</code> contract 6181 * specifies that the argument <code>s</code>code> is filter parameter 6182 * value that requires a corresponding IS NULL predicate. <p> 6183 * 6184 * @param s the filter parameter to test 6185 * @return true if the argument, s, is filter parameter value that 6186 * requires a corresponding IS NULL predicate 6187 */ wantsIsNull(String s)6188 private static boolean wantsIsNull(String s) { 6189 return (s != null && s.length() == 0); 6190 } 6191 setCurrentProperties()6192 private void setCurrentProperties() throws SQLException { 6193 ResultSet rs = executeSelect("SYSTEM_PROPERTIES", 6194 "PROPERTY_NAME IN "+ 6195 "('sql.concat_nulls', 'sql.nulls_first' , 'sql.nulls_order')"); 6196 6197 while(rs.next()) { 6198 String prop = rs.getString(2); 6199 boolean value = Boolean.valueOf(rs.getString(3)); 6200 6201 if (prop.equals("sql.concat_nulls")) { 6202 concatNulls = value; 6203 } else 6204 6205 if (prop.equals("sql.nulls_first")) { 6206 nullsFirst = value; 6207 } else 6208 6209 if (prop.equals("sql.nulls_order")) { 6210 nullsOrder = value; 6211 } 6212 } 6213 6214 rs.close(); 6215 } 6216 /** 6217 * Returns the name of the default schema for database. 6218 */ getDatabaseDefaultSchema()6219 String getDatabaseDefaultSchema() throws SQLException { 6220 6221 final ResultSet rs = executeSelect("SYSTEM_SCHEMAS", 6222 "IS_DEFAULT=TRUE"); 6223 6224 String value = rs.next() ? rs.getString(1) 6225 : null; 6226 rs.close(); 6227 return value; 6228 } 6229 getConnectionDefaultSchema()6230 String getConnectionDefaultSchema() throws SQLException { 6231 6232 ResultSet rs = execute("CALL CURRENT_SCHEMA"); 6233 6234 rs.next(); 6235 6236 String result = rs.getString(1); 6237 6238 rs.close(); 6239 6240 return result; 6241 } 6242 setConnectionDefaultSchema(String schemaName)6243 void setConnectionDefaultSchema(String schemaName) throws SQLException { 6244 6245 execute("SET SCHEMA " 6246 + StringConverter.toQuotedString(schemaName, 6247 '"', true)); 6248 } 6249 6250 /** 6251 * For compatibility, when the connection property "default_schema=true" 6252 * is present, any DatabaseMetaData call with an empty string as the 6253 * schema parameter will use the default schema (normally "PUBLIC"). 6254 */ translateSchema(String schemaName)6255 private String translateSchema(String schemaName) throws SQLException { 6256 6257 if (useSchemaDefault && schemaName != null 6258 && schemaName.length() == 0) { 6259 final String result = getDatabaseDefaultSchema(); 6260 6261 if (result != null) { 6262 schemaName = result; 6263 } 6264 } 6265 6266 return schemaName; 6267 } 6268 6269 /** 6270 * Returns the name of the catalog of the default schema. 6271 */ getDatabaseDefaultCatalog()6272 String getDatabaseDefaultCatalog() throws SQLException { 6273 6274 final ResultSet rs = executeSelect("SYSTEM_SCHEMAS", 6275 "IS_DEFAULT=TRUE"); 6276 6277 String value = rs.next() ? rs.getString(2) 6278 : null; 6279 rs.close(); 6280 return value; 6281 } 6282 6283 /** 6284 * For compatibility, when the connection property "default_schema=true" 6285 * is present, any DatabaseMetaData call with an empty string as the 6286 * catalog parameter will use the default catalog "PUBLIC". 6287 */ translateCatalog(String catalogName)6288 private String translateCatalog(String catalogName) throws SQLException { 6289 6290 if (useSchemaDefault && catalogName != null 6291 && catalogName.length() == 0) { 6292 String result = getDatabaseDefaultCatalog(); 6293 6294 if (result != null) { 6295 catalogName = result; 6296 } 6297 } 6298 6299 return catalogName; 6300 } 6301 } 6302