![]() |
Quadcap Embeddable Database |
00001 package com.quadcap.jdbc; 00002 00003 /* Copyright 1999 - 2003 Quadcap Software. All rights reserved. 00004 * 00005 * This software is distributed under the Quadcap Free Software License. 00006 * This software may be used or modified for any purpose, personal or 00007 * commercial. Open Source redistributions are permitted. Commercial 00008 * redistribution of larger works derived from, or works which bundle 00009 * this software requires a "Commercial Redistribution License"; see 00010 * http://www.quadcap.com/purchase. 00011 * 00012 * Redistributions qualify as "Open Source" under one of the following terms: 00013 * 00014 * Redistributions are made at no charge beyond the reasonable cost of 00015 * materials and delivery. 00016 * 00017 * Redistributions are accompanied by a copy of the Source Code or by an 00018 * irrevocable offer to provide a copy of the Source Code for up to three 00019 * years at the cost of materials and delivery. Such redistributions 00020 * must allow further use, modification, and redistribution of the Source 00021 * Code under substantially the same terms as this license. 00022 * 00023 * Redistributions of source code must retain the copyright notices as they 00024 * appear in each source code file, these license terms, and the 00025 * disclaimer/limitation of liability set forth as paragraph 6 below. 00026 * 00027 * Redistributions in binary form must reproduce this Copyright Notice, 00028 * these license terms, and the disclaimer/limitation of liability set 00029 * forth as paragraph 6 below, in the documentation and/or other materials 00030 * provided with the distribution. 00031 * 00032 * The Software is provided on an "AS IS" basis. No warranty is 00033 * provided that the Software is free of defects, or fit for a 00034 * particular purpose. 00035 * 00036 * Limitation of Liability. Quadcap Software shall not be liable 00037 * for any damages suffered by the Licensee or any third party resulting 00038 * from use of the Software. 00039 */ 00040 00041 import java.io.IOException; 00042 00043 import java.sql.SQLException; 00044 00045 import com.quadcap.sql.Database; 00046 import com.quadcap.sql.Expression; 00047 import com.quadcap.sql.Session; 00048 import com.quadcap.sql.SQLParser; 00049 import com.quadcap.sql.Version; 00050 00051 import com.quadcap.sql.types.ValuePattern; 00052 00053 import com.quadcap.sql.meta.MetaBestRowId; 00054 import com.quadcap.sql.meta.MetaColumns; 00055 import com.quadcap.sql.meta.MetaCrossReference; 00056 import com.quadcap.sql.meta.MetaCursor; 00057 import com.quadcap.sql.meta.MetaIndexInfo; 00058 import com.quadcap.sql.meta.MetaPrimaryKeys; 00059 import com.quadcap.sql.meta.MetaTableTypes; 00060 import com.quadcap.sql.meta.MetaTables; 00061 import com.quadcap.sql.meta.MetaTypes; 00062 00063 /** 00064 * This class implements the <code>java.sql.DatabaseMetaData</code> interface, 00065 * which provides a way for the JDBC application to determine which features 00066 * a database supports and also a way to explore the database schema, through 00067 * information analagous to the SQL "INFORMATION_SCHEMA". 00068 * 00069 * @author Stan Bailes 00070 */ 00071 public class DatabaseMetaData implements java.sql.DatabaseMetaData { 00072 Database database; 00073 com.quadcap.sql.Connection qConn; 00074 Session session; 00075 Connection connection; 00076 00077 DatabaseMetaData(Connection connection) throws IOException, SQLException { 00078 this.connection = connection; 00079 this.qConn = connection.getConnection(); 00080 this.session = qConn.createSession(); 00081 this.database = connection.getDatabase(); 00082 } 00083 00084 /** 00085 * Return true if the current user has the privileges necessary to 00086 * invoke all procedures returned by <code>getProcedures()</code>. 00087 * Since QED doesn't support access privileges, 00088 * this function always returns false, though since it doesn't support 00089 * stored procedures, this isn't likely to matter. 00090 * 00091 * @return true 00092 */ 00093 public boolean allProceduresAreCallable() { 00094 return true; 00095 } 00096 00097 /** 00098 * Return true if the current user can use a <code>SELECT</code> 00099 * statement with all tables returned by <code>getTables()</code>. 00100 * Since QED doesn't support access privileges, this function always 00101 * returns true. 00102 * 00103 * @return true 00104 */ 00105 public boolean allTablesAreSelectable() { 00106 return true; 00107 } 00108 00109 /** 00110 * A data definition statement within a transaction does not force 00111 * a commit in QED. 00112 * 00113 * @return false 00114 */ 00115 public boolean dataDefinitionCausesTransactionCommit() { 00116 return false; 00117 } 00118 00119 /** 00120 * Data definition statements within transactions are not ignored 00121 * in QED. 00122 * 00123 * @return false 00124 */ 00125 public boolean dataDefinitionIgnoredInTransactions() { 00126 return false; 00127 } 00128 00129 /** 00130 * For all types of ResultSets, deleted rows are simply removed 00131 * from the ResultSet, so this function always returns false. 00132 * 00133 * @return false 00134 */ 00135 public boolean deletesAreDetected(int type) { 00136 return false; 00137 } 00138 00139 /** 00140 * QED doesn't impose any maximum row size, so this function is 00141 * really a don't care, but we return true anyway. 00142 * 00143 * @return true 00144 */ 00145 public boolean doesMaxRowSizeIncludeBlobs() { 00146 return true; 00147 } 00148 00149 /** 00150 * Return a resultset containing the set of columns that "best uniquely 00151 * identify a row". In QED, this is interpreted to mean the 'primary key' 00152 * constraint, if specified, otherwise a 'unique' constraint, maybe... 00153 * 00154 * @return the specified ResultSet 00155 * @exception SQLException may be thrown 00156 */ 00157 public java.sql.ResultSet getBestRowIdentifier( 00158 String catalog, String schema, String table, int scope, 00159 boolean nullable) 00160 throws SQLException 00161 { 00162 StringBuffer sb = new StringBuffer(); 00163 if (schema != null && schema.trim().length() > 0) { 00164 sb.append(schema.trim()); 00165 sb.append('.'); 00166 } 00167 if (table != null) sb.append(table); 00168 MetaBestRowId mt = new MetaBestRowId(session, sb.toString(), 00169 scope, nullable); 00170 return new ResultSet(mt); 00171 } 00172 00173 /** 00174 * QED doesn't support catalogs, so there is no separator. 00175 * 00176 * @return the empty string 00177 */ 00178 public String getCatalogSeparator() { 00179 return ""; 00180 } 00181 00182 /** 00183 * Call it what you like, but QED doesn't support catalogs. 00184 * 00185 * @return "catalog" 00186 */ 00187 public String getCatalogTerm() { 00188 return "catalog"; 00189 } 00190 00191 /** 00192 * QED doesn't support catalogs, but we return an empty ResultSet 00193 * of the right signature as a courtesy. 00194 */ 00195 public java.sql.ResultSet getCatalogs() 00196 throws SQLException 00197 { 00198 return new ResultSet(MetaCursor.find(session, "SYSTEM.CATALOGS")); 00199 } 00200 00201 /** 00202 * QED doesn't support access controls, but we return an empty ResultSet 00203 * of the right signature as a courtesy. 00204 */ 00205 public java.sql.ResultSet 00206 getColumnPrivileges(String catalog, String schema, 00207 String table, 00208 String columnNamePattern) 00209 throws SQLException 00210 { 00211 return new ResultSet(MetaCursor.find(session, 00212 "SYSTEM.COLUMNPRIVILEGES")); 00213 } 00214 00215 /** 00216 * Helper function to handle a single metadata pattern matcher 00217 */ 00218 final void doPattern(StringBuffer sb, String name, String pattern) { 00219 if (pattern != null) { 00220 if (sb.length() > 0) { 00221 sb.append(" and "); 00222 } 00223 sb.append(name); 00224 sb.append(" like '"); 00225 sb.append(pattern.toUpperCase()); 00226 sb.append('\''); 00227 } 00228 } 00229 00230 /** 00231 * Helper function to handle a single metadata string specifier 00232 */ 00233 final void doString(StringBuffer sb, String name, String val) { 00234 if (val != null) { 00235 if (sb.length() > 0) { 00236 sb.append(" and "); 00237 } 00238 sb.append(name); 00239 sb.append(" = '"); 00240 sb.append(val.toUpperCase()); 00241 sb.append('\''); 00242 } 00243 } 00244 00245 /** 00246 * This function returns a <code>ResultSet</code> object containing 00247 * information about the specified columns. 00248 * 00249 * @param catalog not used 00250 * @param schemaPattern a SQL "like" pattern. All schema names matching 00251 * this pattern are selected. If this parameter is the empty 00252 * string, all schemas are selected. 00253 * @param tableNamePattern a SQL "like" pattern. All table names 00254 * matching this pattern are selected. 00255 * @param columnNamePattern a SQL "like" pattern. All column names 00256 * matching this pattern are selected. 00257 * @return a <code>ResultSet</code> object, with each row being a 00258 * description of a table column.<p> 00259 * The columns in the <code>ResultSet</code> object have the 00260 * following definition: 00261 * 00262 * <variablelist> 00263 * <varlistentry><term>1: TABLE_CAT</term> 00264 * <listitem> 00265 * <code>null</code> (Catalogs not supported by QED)</listitem> 00266 * </varlistentry> 00267 * <varlistentry><term>2: TABLE_SCHEM</term> 00268 * <listitem> 00269 * <code>String</code> giving the table's schema</listitem> 00270 * </varlistentry> 00271 * <varlistentry><term>3: TABLE_NAME</term> 00272 * <listitem> 00273 * <code>String</code> giving the table's name</listitem> 00274 * </varlistentry> 00275 * <varlistentry><term>4: COLUMN_NAME</term> 00276 * <listitem> 00277 * <code>String</code> giving the column name</listitem> 00278 * </varlistentry> 00279 * <varlistentry><term>5: DATA_TYPE</term> 00280 * <listitem> 00281 * <code>short</code> type from <code>java.sql.types</code></listitem> 00282 * </varlistentry> 00283 * <varlistentry><term>6: TYPE_NAME</term> 00284 * <listitem> 00285 * <code>String</code> giving the SQL type</listitem> 00286 * </varlistentry> 00287 * <varlistentry><term>7: COLUMN_SIZE</term> 00288 * <listitem> 00289 * <code>int</code> For numeric types, this is the precision; 00290 * for character types, it's the maximum width</listitem> 00291 * </varlistentry> 00292 * <varlistentry><term>8: BUFFER_LENGTH</term> 00293 * <listitem> 00294 * <code>null</code> unused</listitem> 00295 * </varlistentry> 00296 * <varlistentry><term>9: DECIMAL_DIGITS</term> 00297 * <listitem> 00298 * <code>int</code> For numeric types, the number of 00299 * digits to the right of the decimal point. 00300 * For other types, <code>-1</code></listitem> 00301 * </varlistentry> 00302 * <varlistentry><term>10: NUM_PREC_RADIX</term> 00303 * <listitem> 00304 * <code>int</code> 10</listitem> 00305 * </varlistentry> 00306 * <varlistentry><term>11: NULLABLE</term> 00307 * <listitem> 00308 * <code>int</code> One of: <ul> 00309 * <li><code>ResultSetMetaData.columnNoNulls</code></li> 00310 * <li><code>ResultSetMetaData.columnNullable</code></li> 00311 * <li><code>ResultSetMetaData.columnNullableUnknown</code> 00312 * </li></ul></listitem> 00313 * </varlistentry> 00314 * <varlistentry><term>12: REMARKS</term> 00315 * <listitem> 00316 * <code>null</code></listitem> 00317 * </varlistentry> 00318 * <varlistentry><term>13: COLUMN_DEF</term> 00319 * <listitem> 00320 * <code>String</code> The column's default value, 00321 * cast to a <code>String</code>. 00322 * <code>null</code> if the column doesn't have a default value</listitem> 00323 * </varlistentry> 00324 * <varlistentry><term>14: SQL_DATA_TYPE</term> 00325 * <listitem> 00326 * <code>null</code></listitem> 00327 * </varlistentry> 00328 * <varlistentry><term>15: SQL_DATETIME_SUB</term> 00329 * <listitem> 00330 * <code>null</code></listitem> 00331 * </varlistentry> 00332 * <varlistentry><term>16: CHAR_OCTET_LENGTH</term> 00333 * <listitem> 00334 * <code>int</code> For character types, 00335 * two times the maximum number 00336 * of characters in the column. 00337 * <code>null</code> for other types.</listitem> 00338 * </varlistentry> 00339 * <varlistentry><term>17: ORDINAL_POSITION</term> 00340 * <listitem> 00341 * <code>int</code> The index of the column 00342 * in its table.</listitem> 00343 * </varlistentry> 00344 * <varlistentry><term>18: IS_NULLABLE</term> 00345 * <listitem> 00346 * <code>String</code> One of <code>"NO"</code>, 00347 * <code>"YES"</code>, or <code>""</code> 00348 * </listitem> 00349 * </varlistentry> 00350 * </variablelist> 00351 * 00352 * @exception SQLException may be thrown. 00353 */ 00354 public java.sql.ResultSet 00355 getColumns(String catalog, String schemaPattern, 00356 String tableNamePattern, 00357 String columnNamePattern) 00358 throws SQLException 00359 { 00360 if (schemaPattern == null || schemaPattern.equals("")) { 00361 schemaPattern = null; 00362 } 00363 StringBuffer sb = new StringBuffer(); 00364 doPattern(sb, "TABLE_SCHEM", schemaPattern); 00365 doPattern(sb, "TABLE_NAME", tableNamePattern); 00366 doPattern(sb, "COLUMN_NAME", columnNamePattern); 00367 Expression ex = parseExpression(sb.toString()); 00368 MetaColumns mt = new MetaColumns(session, ex); 00369 return new ResultSet(mt); 00370 } 00371 00372 /** 00373 * Return the <code>Connection</code> object that was used to create this 00374 * <code>DatabaseMetaData</code> object. 00375 * 00376 * @return a Connection object 00377 */ 00378 public java.sql.Connection getConnection() { 00379 return connection; 00380 } 00381 00382 /** 00383 * This function returns a <code>ResultSet</code> object containing 00384 * information about the foreign key relationships in the database. 00385 * 00386 * @param primaryCatalog not used 00387 * @param primarySchema a schema name. Used to specify the schema name 00388 * of the table containing the primary key. <code>null</code> 00389 * specifies all schemas. 00390 * @param foreignCatalog not used 00391 * @param foreignSchema a schema name. Used to specify the schema name 00392 * of the table containing the foreign key. <code>null</code> 00393 * specifies all schemas. 00394 * @param foreignTable the name of the table containing the foreign key. 00395 * @return a <code>ResultSet</code> object, with each row being a 00396 * description of a foreign key column.<p> 00397 * @exception SQLException may be thrown. 00398 * 00399 * The columns in the <code>ResultSet</code> object have the following 00400 * definition: 00401 * <p> 00402 * <variablelist> 00403 * <varlistentry><term>1: PKTABLE_CAT</term> 00404 * <listitem> 00405 * <code>null</code> (Catalogs not supported by QED)</listitem> 00406 * </varlistentry> 00407 * <varlistentry><term>2: PKTABLE_SCHEM</term> 00408 * <listitem> 00409 * <code>String</code> giving the schema of the 00410 * primary key's table.</listitem> 00411 * </varlistentry> 00412 * <varlistentry><term>3: PKTABLE_NAME</term> 00413 * <listitem> 00414 * <code>String</code> giving the name of the 00415 * primary key's table</listitem> 00416 * </varlistentry> 00417 * <varlistentry><term>4: PKCOLUMN_NAME</term> 00418 * <listitem> 00419 * <code>String</code> giving the column name 00420 * of the primary key</listitem> 00421 * </varlistentry> 00422 * <varlistentry><term>5: FKTABLE_CAT</term> 00423 * <listitem> 00424 * <code>String</code> (An empty string in QED)</listitem> 00425 * </varlistentry> 00426 * <varlistentry><term>6: FKTABLE_SCHEM</term> 00427 * <listitem> 00428 * <code>String</code> giving the schema of 00429 * the foreign key's table.</listitem> 00430 * </varlistentry> 00431 * <varlistentry><term>7: FKTABLE_NAME</term> 00432 * <listitem> 00433 * <code>String</code> giving the name of the 00434 * foreign key's table</listitem> 00435 * </varlistentry> 00436 * <varlistentry><term>8: FKCOLUMN_NAME</term> 00437 * <listitem> 00438 * <code>String</code> giving the column name 00439 * of the foreign key</listitem> 00440 * </varlistentry> 00441 * <varlistentry><term>9: KEY_SEQ</term> 00442 * <listitem> 00443 * <code>short</code> indicating the column number 00444 * within the foreign key, if the foreign key has 00445 * more than one column</listitem> 00446 * </varlistentry> 00447 * <varlistentry><term>10: UPDATE_RULE</term> 00448 * <listitem> 00449 * <code>short</code> indicating what happens when the 00450 * primary key is updated: The values supported by QED 00451 * are: <ul> 00452 * <li><code>DatabaseMetaData.importedKeyRestrict</code></li> 00453 * <li><code>DatabaseMetaData.importedKeyCascade</code></li> 00454 * </ul></listitem> 00455 * </varlistentry> 00456 * <varlistentry><term>11: DELETE_RULE</term> 00457 * <listitem> 00458 * <code>short</code> indicating what happens when the 00459 * primary key is deleted: The values supported by QED 00460 * are: <ul> 00461 * <li><code>DatabaseMetaData.importedKeyRestrict</code></li> 00462 * <li><code>DatabaseMetaData.importedKeyCascade</code></li> 00463 * </ul></listitem> 00464 * </varlistentry> 00465 * <varlistentry><term>12: FK_NAME</term> 00466 * <listitem> 00467 * <code>null</code></listitem> 00468 * </varlistentry> 00469 * <varlistentry><term>13: PK_NAME</term> 00470 * <listitem> 00471 * <code>null</code></listitem> 00472 * </varlistentry> 00473 * <varlistentry><term>14: DEFERRABILITY</term> 00474 * <listitem> 00475 * <code>short</code> indicating whether 00476 * foreign key constraint 00477 * checking can be deferred. One of: <ul> 00478 * <li><code>DatabaseMetaData.importedKeyInitiallyDeferred</code></li> 00479 * <li><code>DatabaseMetaData.importedKeyInitiallyImmediate</code></li> 00480 * <li><code>DatabaseMetaData.importedKeyNotDeferrable</code></li> 00481 * </ul> 00482 * <p>This QED release remembers the deferability specification 00483 * in the original DDL statement, but deferred constraint checking 00484 * is not supported in this release. 00485 * 00486 * </listitem> 00487 * </varlistentry> 00488 * </variablelist> 00489 */ 00490 public java.sql.ResultSet getCrossReference(String primaryCatalog, 00491 String primarySchema, 00492 String primaryTable, 00493 String foreignCatalog, 00494 String foreignSchema, 00495 String foreignTable) 00496 throws SQLException 00497 { 00498 StringBuffer sb = new StringBuffer(); 00499 doString(sb, "PKTABLE_SCHEM", primarySchema); 00500 doString(sb, "PKTABLE_NAME", primaryTable); 00501 doString(sb, "FKTABLE_SCHEM", foreignSchema); 00502 doString(sb, "FKTABLE_NAME", foreignTable); 00503 Expression ex = parseExpression(sb.toString()); 00504 MetaCrossReference mx = new MetaCrossReference(session, ex); 00505 return new ResultSet(mx); 00506 } 00507 00508 /** 00509 * Return the database product name, "QED" 00510 * 00511 * @return QED 00512 */ 00513 public String getDatabaseProductName() { 00514 return "QED"; 00515 } 00516 00517 /** 00518 * Return the version for this product. QED version strings are 00519 * strings of the form <i>major.minor</i>, where <i>major</i> 00520 * and <i>minor</i> are the driver major and minor version numbers 00521 * 00522 * @see #getDriverMajorVersion() 00523 * @see #getDriverMinorVersion() 00524 * 00525 * @return the QED version string. 00526 */ 00527 public String getDatabaseProductVersion() { 00528 return "" + getDriverMajorVersion() + "." + getDriverMinorVersion(); 00529 } 00530 00531 /** 00532 * Return the default transaction isolation level. For QED, the 00533 * default (and only supported) transaction isolation level is 00534 * <code>Connection.TRANSACTION_SERIALIZABLE</code>. 00535 * 00536 * @returnt the default transaction isolation level. 00537 */ 00538 public int getDefaultTransactionIsolation() { 00539 return Connection.TRANSACTION_SERIALIZABLE; 00540 } 00541 00542 /** 00543 * Return the driver major version number. 00544 * 00545 * @return the driver's major version number 00546 */ 00547 public int getDriverMajorVersion() { 00548 return Version.majorVersion; 00549 } 00550 00551 /** 00552 * Return the driver minor version number. 00553 * 00554 * @return the driver's minor version number 00555 */ 00556 public int getDriverMinorVersion() { return Version.minorVersion; } 00557 00558 /** 00559 * Return the name of this JDBC driver 00560 * 00561 * @return the string <code>"com.quadcap.jdbc.JdbcDriver"</code> 00562 */ 00563 public String getDriverName() { 00564 return "com.quadcap.jdbc.JdbcDriver"; 00565 } 00566 00567 /** 00568 * Return the version for this JDBC Driver. QED version strings are 00569 * strings of the form <i>major.minor</i>, where <i>major</i> 00570 * and <i>minor</i> are the driver major and minor version numbers 00571 * 00572 * @see #getDriverMajorVersion() 00573 * @see #getDriverMinorVersion() 00574 * 00575 * @return the QED version string. 00576 */ 00577 public String getDriverVersion() 00578 throws SQLException 00579 { 00580 return getDatabaseProductVersion(); 00581 } 00582 00583 /** 00584 * This function returns a <code>ResultSet</code> object that 00585 * contains information about the foreign key columns that reference 00586 * the primary keys in the specified table. 00587 * 00588 * @param catalog ignored, since catalogs not supported by QED. 00589 * @param schema a schema name. Used to specify the schema name 00590 * of the table containing the primary key. <code>null</code> 00591 * specifies any schema. 00592 * @param table the name of the table containing the primary key. 00593 * @return a <code>ResultSet</code> object, with each row being a 00594 * description of a foreign key column.<p> 00595 * @exception SQLException may be thrown. 00596 * 00597 * The columns in the <code>ResultSet</code> object have the following 00598 * definition: 00599 * <p> 00600 * <variablelist> 00601 * <varlistentry><term>1: PKTABLE_CAT</term> 00602 * <listitem> 00603 * <code>null</code> (Catalogs not supported by QED)</listitem> 00604 * </varlistentry> 00605 * <varlistentry><term>2: PKTABLE_SCHEM</term> 00606 * <listitem> 00607 * <code>String</code> giving the schema of the 00608 * primary key's table.</listitem> 00609 * </varlistentry> 00610 * <varlistentry><term>3: PKTABLE_NAME</term> 00611 * <listitem> 00612 * <code>String</code> giving the name of the 00613 * primary key's table</listitem> 00614 * </varlistentry> 00615 * <varlistentry><term>4: PKCOLUMN_NAME</term> 00616 * <listitem> 00617 * <code>String</code> giving the column name 00618 * of the primary key</listitem> 00619 * </varlistentry> 00620 * <varlistentry><term>5: FKTABLE_CAT</term> 00621 * <listitem> 00622 * <code>null</code> (Catalogs not supported by QED)</listitem> 00623 * </varlistentry> 00624 * <varlistentry><term>6: FKTABLE_SCHEM</term> 00625 * <listitem> 00626 * <code>String</code> giving the schema of 00627 * the foreign key's table.</listitem> 00628 * </varlistentry> 00629 * <varlistentry><term>7: FKTABLE_NAME</term> 00630 * <listitem> 00631 * <code>String</code> giving the name of the 00632 * foreign key's table</listitem> 00633 * </varlistentry> 00634 * <varlistentry><term>8: FKCOLUMN_NAME</term> 00635 * <listitem> 00636 * <code>String</code> giving the column name 00637 * of the foreign key</listitem> 00638 * </varlistentry> 00639 * <varlistentry><term>9: KEY_SEQ</term> 00640 * <listitem> 00641 * <code>short</code> indicating the column number 00642 * within the foreign key, if the foreign key has 00643 * more than one column</listitem> 00644 * </varlistentry> 00645 * <varlistentry><term>10: UPDATE_RULE</term> 00646 * <listitem> 00647 * <code>short</code> indicating what happens when the 00648 * primary key is updated: The values supported by QED 00649 * are: <ul> 00650 * <li><code>DatabaseMetaData.importedKeyRestrict</code></li> 00651 * <li><code>DatabaseMetaData.importedKeyCascade</code></li> 00652 * </ul></listitem> 00653 * </varlistentry> 00654 * <varlistentry><term>11: DELETE_RULE</term> 00655 * <listitem> 00656 * <code>short</code> indicating what happens when the 00657 * primary key is deleted: The values supported by QED 00658 * are: <ul> 00659 * <li><code>DatabaseMetaData.importedKeyRestrict</code></li> 00660 * <li><code>DatabaseMetaData.importedKeyCascade</code></li> 00661 * </ul></listitem> 00662 * </varlistentry> 00663 * <varlistentry><term>12: FK_NAME</term> 00664 * <listitem> 00665 * <code>null</code></listitem> 00666 * </varlistentry> 00667 * <varlistentry><term>13: PK_NAME</term> 00668 * <listitem> 00669 * <code>null</code></listitem> 00670 * </varlistentry> 00671 * <varlistentry><term>14: DEFERRABILITY</term> 00672 * <listitem> 00673 * <code>short</code> indicating whether 00674 * foreign key constraint 00675 * checking can be deferred. One of: <ul> 00676 * <li><code>DatabaseMetaData.importedKeyInitiallyDeferred</code></li> 00677 * <li><code>DatabaseMetaData.importedKeyInitiallyImmediate</code></li> 00678 * <li><code>DatabaseMetaData.importedKeyNotDeferrable</code></li> 00679 * </ul> 00680 * <p>This QED release remembers the deferability specification 00681 * in the original DDL statement, but deferred constraint checking 00682 * is not supported in this release. 00683 * 00684 * </listitem> 00685 * </varlistentry> 00686 * </variablelist> 00687 * 00688 */ 00689 public java.sql.ResultSet getExportedKeys(String catalog, String schema, 00690 String table) 00691 throws SQLException 00692 { 00693 StringBuffer sb = new StringBuffer(""); 00694 doString(sb, "PKTABLE_SCHEM", schema); 00695 doString(sb, "PKTABLE_NAME", table); 00696 Expression ex = parseExpression(sb.toString()); 00697 MetaCrossReference mt = new MetaCrossReference(session, ex); 00698 return new ResultSet(mt); 00699 } 00700 00701 /** 00702 * Returns a string consisting of all characters that can be used 00703 * in unquoted identifier names other than alphanumerics and _). 00704 * In QED, this returns the empty string, since only alphanumerics 00705 * and underscore are valid identifier characters. 00706 * 00707 * @return the empty string 00708 */ 00709 public String getExtraNameCharacters() { 00710 return ""; 00711 } 00712 00713 /** 00714 * Return the string used to quote SQL identifiers. 00715 * 00716 * @return the double-quote character: <code>"</code> 00717 */ 00718 public String getIdentifierQuoteString() { 00719 return "\""; 00720 } 00721 00722 /** 00723 * This function returns a <code>ResultSet</code> object that 00724 * contains information about the primary key columns that are 00725 * referenced by the foreign keys in the specified table. 00726 * 00727 * @param catalog ignored, since catalogs not supported by QED. 00728 * @param schema a schema name. Used to specify the schema name 00729 * of the table containing the foreign key. <code>null</code> 00730 * specifies any schema. 00731 * @param table the name of the table containing the foreign key. 00732 * @return a <code>ResultSet</code> object, with each row being a 00733 * description of a foreign key column.<p> 00734 * @exception SQLException may be thrown. 00735 * 00736 * The columns in the <code>ResultSet</code> object have the following 00737 * definition: 00738 * <p> 00739 * <variablelist> 00740 * <varlistentry><term>1: PKTABLE_CAT</term> 00741 * <listitem> 00742 * <code>null</code> (Catalogs not supported by QED)</listitem> 00743 * </varlistentry> 00744 * <varlistentry><term>2: PKTABLE_SCHEM</term> 00745 * <listitem> 00746 * <code>String</code> giving the schema of the 00747 * primary key's table.</listitem> 00748 * </varlistentry> 00749 * <varlistentry><term>3: PKTABLE_NAME</term> 00750 * <listitem> 00751 * <code>String</code> giving the name of the 00752 * primary key's table</listitem> 00753 * </varlistentry> 00754 * <varlistentry><term>4: PKCOLUMN_NAME</term> 00755 * <listitem> 00756 * <code>String</code> giving the column name 00757 * of the primary key</listitem> 00758 * </varlistentry> 00759 * <varlistentry><term>5: FKTABLE_CAT</term> 00760 * <listitem> 00761 * <code>null</code> (Catalogs not supported by QED)</listitem> 00762 * </varlistentry> 00763 * <varlistentry><term>6: FKTABLE_SCHEM</term> 00764 * <listitem> 00765 * <code>String</code> giving the schema of 00766 * the foreign key's table.</listitem> 00767 * </varlistentry> 00768 * <varlistentry><term>7: FKTABLE_NAME</term> 00769 * <listitem> 00770 * <code>String</code> giving the name of the 00771 * foreign key's table</listitem> 00772 * </varlistentry> 00773 * <varlistentry><term>8: FKCOLUMN_NAME</term> 00774 * <listitem> 00775 * <code>String</code> giving the column name 00776 * of the foreign key</listitem> 00777 * </varlistentry> 00778 * <varlistentry><term>9: KEY_SEQ</term> 00779 * <listitem> 00780 * <code>short</code> indicating the column number 00781 * within the foreign key, if the foreign key has 00782 * more than one column</listitem> 00783 * </varlistentry> 00784 * <varlistentry><term>10: UPDATE_RULE</term> 00785 * <listitem> 00786 * <code>short</code> indicating what happens when the 00787 * primary key is updated: The values supported by QED 00788 * are: <ul> 00789 * <li><code>DatabaseMetaData.importedKeyRestrict</code></li> 00790 * <li><code>DatabaseMetaData.importedKeyCascade</code></li> 00791 * </ul></listitem> 00792 * </varlistentry> 00793 * <varlistentry><term>11: DELETE_RULE</term> 00794 * <listitem> 00795 * <code>short</code> indicating what happens when the 00796 * primary key is deleted: The values supported by QED 00797 * are: <ul> 00798 * <li><code>DatabaseMetaData.importedKeyRestrict</code></li> 00799 * <li><code>DatabaseMetaData.importedKeyCascade</code></li> 00800 * </ul></listitem> 00801 * </varlistentry> 00802 * <varlistentry><term>12: FK_NAME</term> 00803 * <listitem> 00804 * the name of the foreign key constraint</listitem> 00805 * </varlistentry> 00806 * <varlistentry><term>13: PK_NAME</term> 00807 * <listitem> 00808 * <code>null</code></listitem> 00809 * </varlistentry> 00810 * <varlistentry><term>14: DEFERRABILITY</term> 00811 * <listitem> 00812 * <code>short</code> indicating whether 00813 * foreign key constraint 00814 * checking can be deferred. One of: <ul> 00815 * <li><code>DatabaseMetaData.importedKeyInitiallyDeferred</code></li> 00816 * <li><code>DatabaseMetaData.importedKeyInitiallyImmediate</code></li> 00817 * <li><code>DatabaseMetaData.importedKeyNotDeferrable</code></li> 00818 * </ul> 00819 * <p>This QED release remembers the deferability specification 00820 * in the original DDL statement, but deferred constraint checking 00821 * is not supported in this release. 00822 * 00823 * </listitem> 00824 * </varlistentry> 00825 * </variablelist> 00826 * 00827 */ 00828 public java.sql.ResultSet getImportedKeys(String catalog, String schema, 00829 String table) 00830 throws SQLException 00831 { 00832 StringBuffer sb = new StringBuffer(""); 00833 doString(sb, "FKTABLE_SCHEM", schema); 00834 doString(sb, "FKTABLE_NAME", table); 00835 Expression ex = parseExpression(sb.toString()); 00836 MetaCrossReference mt = new MetaCrossReference(session, ex); 00837 return new ResultSet(mt); 00838 } 00839 00840 /** 00841 * This function returns a <code>ResultSet</code> object that 00842 * contains information about the index columns in the specified 00843 * table. 00844 * 00845 * @param catalog ignored, since catalogs not supported by QED. 00846 * @param schema a schema name. Used to specify the schema name 00847 * of the table. <code>null</code> 00848 * specifies any schema. 00849 * @param table the name of the table. 00850 * @return a <code>ResultSet</code> object, with each row being a 00851 * description of an index column.<p> 00852 * @exception SQLException may be thrown. 00853 * 00854 * The columns in the <code>ResultSet</code> object have the following 00855 * definition: 00856 * <p> 00857 * <variablelist> 00858 * <varlistentry><term>1: TABLE_CAT</term> 00859 * <listitem> 00860 * <code>null</code> (Catalogs not supported by QED)</listitem> 00861 * </varlistentry> 00862 * <varlistentry><term>2: TABLE_SCHEM</term> 00863 * <listitem> 00864 * <code>String</code> giving the table's schema</listitem> 00865 * </varlistentry> 00866 * <varlistentry><term>3: TABLE_NAME</term> 00867 * <listitem> 00868 * <code>String</code> giving the table's name</listitem> 00869 * </varlistentry> 00870 * <varlistentry><term>4: NON_UNIQUE</term> 00871 * <listitem> 00872 * <code>boolean</code> <code>false</code> if index values 00873 * must be unique, <code>true</code> otherwise.</listitem> 00874 * </varlistentry> 00875 * <varlistentry><term>5: INDEX_QUALIFIER</term> 00876 * <listitem> 00877 * QED returns <code>"global"</code> if this is a global 00878 * index, <code>null</code> otherwise.</listitem> 00879 * </varlistentry> 00880 * <varlistentry><term>6: INDEX_NAME</term> 00881 * <listitem> 00882 * <code>String</code> the name of the index</listitem> 00883 * </varlistentry> 00884 * <varlistentry><term>7: TYPE</term> 00885 * <listitem> 00886 * <code>short</code> <code>DatabaseMetaData.tableIndexOther</code></listitem> 00887 * </varlistentry> 00888 * <varlistentry><term>8: ORDINAL_POSITION</term> 00889 * <listitem> 00890 * <code>short</code> indicating the column sequence 00891 * within the index</listitem> 00892 * </varlistentry> 00893 * <varlistentry><term>9: COLUMN_NAME</term> 00894 * <listitem> 00895 * <code>String</code> The name of the column</listitem> 00896 * </varlistentry> 00897 * <varlistentry><term>10: ASC_OR_DESC</term> 00898 * <listitem> 00899 * <code>String</code> always <code>"A"</code></listitem> 00900 * </varlistentry> 00901 * <varlistentry><term>11: CARDINALITY</term> 00902 * <listitem> 00903 * <code>null</code> The JDBC specification says that 00904 * this returns the number of unique values in the index, 00905 * a statistic which is not kept in this release of 00906 * QED.</listitem> 00907 * </varlistentry> 00908 * <varlistentry><term>12: PAGES</term> 00909 * <listitem> 00910 * <code>null</code> The JDBC specification says that 00911 * this returns the number of pages used by the index, 00912 * a statistic which is not kept in this release of 00913 * QED.</listitem> 00914 * </varlistentry> 00915 * <varlistentry><term>13: FILTER_CONDITION</term> 00916 * <listitem> 00917 * <code>null</code> not supported by QED 00918 * </listitem> 00919 * </varlistentry> 00920 * </variablelist> 00921 */ 00922 public java.sql.ResultSet getIndexInfo(String catalog, String schema, 00923 String table, boolean unique, 00924 boolean approximate) 00925 throws SQLException 00926 { 00927 StringBuffer sb = new StringBuffer(""); 00928 doString(sb, "TABLE_SCHEM", schema); 00929 doString(sb, "TABLE_NAME", table); 00930 if (unique) { 00931 if (sb.length() > 0) sb.append(" and "); 00932 sb.append("not NON_UNIQUE"); 00933 } 00934 Expression ex = parseExpression(sb.toString()); 00935 MetaIndexInfo mi = new MetaIndexInfo(session, ex); 00936 return new ResultSet(mi); 00937 } 00938 00939 /** 00940 * Return the maximum size of a binary literal. QED has no 00941 * architectural limitation on literal sizes, and so always 00942 * returns zero. 00943 * 00944 * @return zero, meaning unlimited. 00945 */ 00946 public int getMaxBinaryLiteralLength() { 00947 return 0; 00948 } 00949 00950 /** 00951 * QED doesn't support catalogs, but if it did, it wouldn't impose 00952 * a limit on the length of their names. 00953 * 00954 * @return zero, meaning unlimited. 00955 */ 00956 public int getMaxCatalogNameLength() { 00957 return 0; 00958 } 00959 00960 /** 00961 * Return the maximum size of a character literal. QED has no 00962 * architectural limitation on literal sizes, and so always 00963 * returns zero. 00964 * 00965 * @return zero, meaning unlimited. 00966 */ 00967 public int getMaxCharLiteralLength() { 00968 return 0; 00969 } 00970 00971 /** 00972 * Return the maximum length of a column name. QED has no 00973 * architectural limitation on name sizes, and so always 00974 * returns zero. 00975 * 00976 * @return zero, meaning unlimited. 00977 */ 00978 public int getMaxColumnNameLength() { 00979 return 0; 00980 } 00981 00982 /** 00983 * Return the maximum number of columns in a <code>GROUP BY</code> 00984 * clause. QED has no architectural limitation on 00985 * <code>GROUP BY</code> clauses, and so always 00986 * returns zero. 00987 * 00988 * @return zero, meaning unlimited. 00989 */ 00990 public int getMaxColumnsInGroupBy() { 00991 return 0; 00992 } 00993 00994 /** 00995 * Return the maximum number of columns in an index. 00996 * QED has no architectural limitation on index columns, 00997 * and so always returns zero. 00998 * 00999 * @return zero, meaning unlimited. 01000 */ 01001 public int getMaxColumnsInIndex() { 01002 return 0; 01003 } 01004 01005 /** 01006 * Return the maximum number of columns in an <code>ORDER BY</code> 01007 * clause. QED has no architectural limitation on 01008 * <code>ORDER BY</code> clauses, and so always 01009 * returns zero. 01010 * 01011 * @return zero, meaning unlimited. 01012 */ 01013 public int getMaxColumnsInOrderBy() { 01014 return 0; 01015 } 01016 01017 /** 01018 * Return the maximum number of columns in a <code>SELECT</code> 01019 * clause. QED has no architectural limitation on 01020 * <code>SELECT</code> clauses, and so always 01021 * returns zero. 01022 * 01023 * @return zero, meaning unlimited. 01024 */ 01025 public int getMaxColumnsInSelect() { 01026 return 0; 01027 } 01028 01029 /** 01030 * Return the maximum number of columns in an table. 01031 * QED has no architectural limitation on table columns, 01032 * and so always returns zero. 01033 * 01034 * @return zero, meaning unlimited. 01035 */ 01036 public int getMaxColumnsInTable() { 01037 return 0; 01038 } 01039 01040 /** 01041 * Return the maximum number of active connections that can 01042 * be maintained by this driver instance. 01043 * QED has no architectural limitation on datbase connections, 01044 * and so always returns zero. 01045 * 01046 * @return zero, meaning unlimited. 01047 */ 01048 public int getMaxConnections() { 01049 return 0; 01050 } 01051 01052 /** 01053 * QED doesn't support named cursors, but if it did, it wouldn't impose 01054 * a limit on the length of their names. 01055 * 01056 * @return zero, meaning unlimited. 01057 */ 01058 public int getMaxCursorNameLength() { 01059 return 0; 01060 } 01061 01062 /** 01063 * Return the maximum number of bytes in an index. QED has no 01064 * architectural limitation on index sizes, and so always returns zero. 01065 * 01066 * @return zero, meaning unlimited. 01067 */ 01068 public int getMaxIndexLength() { 01069 return 0; 01070 } 01071 01072 /** 01073 * QED doesn't support stored procedures, but if it did, it wouldn't impose 01074 * a limit on the length of their names. 01075 * 01076 * @return zero, meaning unlimited. 01077 */ 01078 public int getMaxProcedureNameLength() { 01079 return 0; 01080 } 01081 01082 /** 01083 * Return the maximum number of bytes in a single row. QED has no 01084 * architectural limitation on row sizes, and so always returns zero. 01085 * 01086 * @return zero, meaning unlimited. 01087 */ 01088 public int getMaxRowSize() { 01089 return 0; 01090 } 01091 01092 /** 01093 * Return the maximum length of a schema name. QED has no 01094 * architectural limitation on schema sizes, and so always 01095 * returns zero. 01096 * 01097 * @return zero, meaning unlimited. 01098 */ 01099 public int getMaxSchemaNameLength() { 01100 return 0; 01101 } 01102 01103 /** 01104 * Return the maximum number of characters in an SQL statement. QED has no 01105 * architectural limitation on statement sizes, and so always 01106 * returns zero. 01107 * 01108 * @return zero, meaning unlimited. 01109 */ 01110 public int getMaxStatementLength() { 01111 return 0; 01112 } 01113 01114 /** 01115 * Return the maximum number of concurrently active statements that 01116 * can be open on a single connection. The QED threading model 01117 * essentially restricts the application to a single active 01118 * <code>ResultSet</code> per connection. If another statement 01119 * is executed which creates a <code>ResultSet</code>, the first 01120 * <code>ResultSet</code> will be automatically closed. 01121 * 01122 * @return one 01123 */ 01124 public int getMaxStatements() { 01125 return 1; 01126 } 01127 01128 /** 01129 * Return the maximum length of a table name. QED has no 01130 * architectural limitation on name lengths, and so always 01131 * returns zero. 01132 * 01133 * @return zero, meaning unlimited. 01134 */ 01135 public int getMaxTableNameLength() { 01136 return 0; 01137 } 01138 01139 /** 01140 * Return the maximum number of tables allowed in a <code>SELECT</code> 01141 * clause. QED has no 01142 * architectural limitation on this, and so always 01143 * returns zero. 01144 * 01145 * @return zero, meaning unlimited. 01146 */ 01147 public int getMaxTablesInSelect() { 01148 return 0; 01149 } 01150 01151 /** 01152 * Return the maximum length of a user name. QED has no 01153 * architectural limitation on name lengths, and so always 01154 * returns zero. 01155 * 01156 * @return zero, meaning unlimited. 01157 */ 01158 public int getMaxUserNameLength() { 01159 return 0; 01160 } 01161 01162 /** 01163 * Return a comma-separated string containing the names of the 01164 * numeric functions supported by QED. 01165 * This string contains the Open Group 01166 * CLI names for the following functions: 01167 * 01168 * <p><code> 01169 * ABS,ACOS,ASIN,ATAN,ATAN2,CEILING,COS,COT,DEGREES,EXP,FLOOR 01170 * LOG,LOG10,MOD,PI,POWER,RADIANS,RAND,ROUND,SIGN,SIN,SQRT,TAN 01171 * TRUNCATE 01172 * </code></p> 01173 */ 01174 public String getNumericFunctions() { 01175 return 01176 "ABS,ACOS,ASIN,ATAN,ATAN2,CEILING,COS,COT,DEGREES,EXP,FLOOR," + 01177 "LOG,LOG10,MOD,PI,POWER,RADIANS,RAND,ROUND,SIGN,SIN,SQRT,TAN," + 01178 "TRUNCATE"; 01179 } 01180 01181 /** 01182 * This function returns a <code>ResultSet</code> describing the 01183 * primary key columns of the specified table. 01184 * 01185 * @param catalog ignored, since catalogs not supported by QED. 01186 * @param schema a schema name. Used to specify the schema name 01187 * of the table. <code>null</code> 01188 * specifies any schema. 01189 * @param table the name of the table. 01190 * @return a <code>ResultSet</code> object, with each row being a 01191 * description of an index column.<p> 01192 * @exception SQLException may be thrown. 01193 * 01194 * The columns in the <code>ResultSet</code> object have the following 01195 * definition: 01196 * <p> 01197 * <variablelist> 01198 * <varlistentry><term>1: TABLE_CAT</term> 01199 * <listitem> 01200 * <code>null</code> (Catalogs not supported by QED)</listitem> 01201 * </varlistentry> 01202 * <varlistentry><term>2: TABLE_SCHEM</term> 01203 * <listitem> 01204 * <code>String</code> giving the table's schema</listitem> 01205 * </varlistentry> 01206 * <varlistentry><term>3: TABLE_NAME</term> 01207 * <listitem> 01208 * <code>String</code> giving the table's name</listitem> 01209 * </varlistentry> 01210 * <varlistentry><term>4: COLUMN_NAME</term> 01211 * <listitem> 01212 * <code>String</code> giving the column name</listitem> 01213 * </varlistentry> 01214 * <varlistentry><term>5: KEY_SEQ</term> 01215 * <listitem> 01216 * <code>short</code> indicating the column sequence 01217 * within the primary key</listitem> 01218 * </varlistentry> 01219 * <varlistentry><term>6: PK_NAME</term> 01220 * <listitem> 01221 * <code>String</code> The name of the primary key constraint</listitem> 01222 * </varlistentry> 01223 * </variablelist> 01224 */ 01225 public java.sql.ResultSet getPrimaryKeys(String catalog, String schema, 01226 String table) 01227 throws SQLException 01228 { 01229 StringBuffer sb = new StringBuffer(""); 01230 doString(sb, "TABLE_SCHEM", schema); 01231 doString(sb, "TABLE_NAME", table); 01232 Expression ex = parseExpression(sb.toString()); 01233 MetaPrimaryKeys mt = new MetaPrimaryKeys(session, ex); 01234 return new ResultSet(mt); 01235 } 01236 01237 /** 01238 * Stored procedures aren't supported by QED, but 01239 * we return an empty result set with the right signature as a courtesy. 01240 * 01241 * @param catalog N/A 01242 * @param schemaNamePattern N/A 01243 * @param procedureNamePattern N/A 01244 * @param columnNamePattern N/A 01245 */ 01246 public java.sql.ResultSet getProcedureColumns(String catalog, 01247 String schemaNamePattern, 01248 String procedureNamePattern, 01249 String columnNamePattern) 01250 throws SQLException 01251 { 01252 return new ResultSet(MetaCursor.find(session, 01253 "SYSTEM.PROCEDURECOLUMNS")); 01254 } 01255 /** 01256 * Stored procedures aren't supported by QED, but 01257 * we return an empty result set with the right signature as a courtesy. 01258 * 01259 * @param catalog N/A 01260 * @param schemaNamePattern N/A 01261 * @param procedureNamePattern N/A 01262 */ 01263 public java.sql.ResultSet getProcedures(String catalog, 01264 String schemaNamePattern, 01265 String procedureNamePattern) 01266 throws SQLException 01267 { 01268 return new ResultSet(MetaCursor.find(session, "SYSTEM.PROCEDURES")); 01269 } 01270 01271 01272 /** 01273 * Whatever. 01274 */ 01275 public String getProcedureTerm() 01276 throws SQLException 01277 { 01278 return "proc"; 01279 } 01280 01281 /** 01282 * Return a result set containing the names of the database schemas. 01283 * 01284 */ 01285 public java.sql.ResultSet getSchemas() 01286 throws SQLException 01287 { 01288 return new ResultSet(MetaCursor.find(session, "SYSTEM.SCHEMAS")); 01289 } 01290 01291 /** 01292 * Get the "database vendor's preferred term for 'schema'". 01293 * 01294 * @return "schema" 01295 */ 01296 public String getSchemaTerm() { 01297 return "schema"; 01298 } 01299 01300 /** 01301 * Return the default value for the escape sequence that can be 01302 * used to escape literal "_" and "%" pattern characters in 01303 * <code>LIKE</code> pattern strings. 01304 * 01305 * @return the string "\" 01306 */ 01307 public String getSearchStringEscape() { 01308 return ValuePattern.defaultEscape; 01309 } 01310 01311 /** 01312 * Returns a list of database keywords that are not also SQL-92 01313 * keywords. For this release of QED, this is currently the 01314 * empty string. 01315 * 01316 * @return "" 01317 */ 01318 public String getSQLKeywords() { 01319 return ""; 01320 } 01321 01322 /** 01323 * Return a comma-separated string containing the names of the 01324 * string functions supported by QED. 01325 * This string contains the Open Group 01326 * CLI names for the following functions: 01327 * 01328 * <p><code> 01329 * ASCII, CHAR, CONCAT, DIFFERENCE, INSERT, LCASE, LOWER, LEFT, LENGTH 01330 * LOCATE, LTRIM, REPEAT, REPLACE, RIGHT, RTRIM, SOUNDEX, SPACE 01331 * SUBSTRING, UCASE, UPPER 01332 * </code</p> 01333 */ 01334 public String getStringFunctions() { 01335 return 01336 "ASCII,CHAR,CONCAT,DIFFERENCE,INSERT,LCASE,LOWER,LEFT,LENGTH," + 01337 "LOCATE,LTRIM,REPEAT,REPLACE,RIGHT,RTRIM,SOUNDEX,SPACE," + 01338 "SUBSTRING,UCASE,UPPER"; 01339 } 01340 01341 /** 01342 * Return a comma-separated string containing the names of the 01343 * system functions supported by QED. 01344 * This string contains the Open Group 01345 * CLI names for the following functions: 01346 * 01347 * <p><code>DATABASE, IFNULL, USER</code></p> 01348 */ 01349 public String getSystemFunctions() { 01350 return "DATABASE,IFULL,USER"; 01351 } 01352 01353 /** 01354 * QED doesn't support column privs, but we return an empty ResultSet 01355 * of the right signature as a courtesy. 01356 */ 01357 public java.sql.ResultSet getTablePrivileges(String catalog, String schema, 01358 String tableNamePattern) 01359 throws SQLException 01360 { 01361 return new ResultSet(MetaCursor.find(session, 01362 "SYSTEM.TABLEPRIVILEGES")); 01363 } 01364 01365 /** 01366 * This function returns a <code>ResultSet<code> describing the 01367 * tables in the database. 01368 * 01369 * @param catalog ignored, since catalogs not supported by QED. 01370 * @param schemaPattern a SQL "like" pattern. All schema names matching 01371 * this pattern are selected. If this parameter is the empty 01372 * string, all schemas are selected. 01373 * @param tableNamePattern a SQL "like" pattern. All table names 01374 * matching this pattern are selected. 01375 * @param types an array of strings specifying the table types to 01376 * be returned, from the set: <code>"TABLE", "VIEW", 01377 * "LOCAL TEMPORARY", "GLOBAL TEMPORARY"</code> 01378 * @return a <code>ResultSet</code> object, with each row being a 01379 * description of a table.<p> 01380 * @exception SQLException may be thrown. 01381 * 01382 * The columns in the <code>ResultSet</code> object have the following 01383 * definition: 01384 * <p> 01385 * <variablelist> 01386 * <varlistentry><term>1: TABLE_CAT</term> 01387 * <listitem> 01388 * <code>null</code> (Catalogs not supported by QED)</listitem> 01389 * </varlistentry> 01390 * <varlistentry><term>2: TABLE_SCHEM</term> 01391 * <listitem> 01392 * <code>String</code> giving the table's schema</listitem> 01393 * </varlistentry> 01394 * <varlistentry><term>3: TABLE_NAME</term> 01395 * <listitem> 01396 * <code>String</code> giving the table's name</listitem> 01397 * </varlistentry> 01398 * <varlistentry><term>4: TABLE_TYPE</term> 01399 * <listitem> 01400 * <code>String</code> The table type. One of: <ul> 01401 * <li><code>TABLE</code></li> 01402 * <li><code>VIEW</code></li> 01403 * <li><code>GLOBAL TEMPORARY</code></li> 01404 * <li><code>LOCAL TEMPORARY</code></li> 01405 * </ul></listitem> 01406 * </varlistentry> 01407 * <varlistentry><term>5: REMARKS</term> 01408 * <listitem> 01409 * <code>null</code></listitem> 01410 * </varlistentry> 01411 * </variablelist> 01412 */ 01413 public java.sql.ResultSet getTables(String catalog, String schemaPattern, 01414 String tableNamePattern, 01415 String[] types) 01416 throws SQLException 01417 { 01418 StringBuffer sb = new StringBuffer(); 01419 doPattern(sb, "TABLE_SCHEM", schemaPattern); 01420 doPattern(sb, "TABLE_NAME", tableNamePattern); 01421 if (types != null) { 01422 if (sb.length() > 0) sb.append(" AND "); 01423 sb.append("TABLE_TYPE in ("); 01424 for (int i = 0; i < types.length; i++) { 01425 if (i > 0) sb.append(','); 01426 sb.append('\''); 01427 sb.append(types[i].toUpperCase()); 01428 sb.append('\''); 01429 } 01430 sb.append(")"); 01431 } 01432 Expression ex = parseExpression(sb.toString()); 01433 MetaTables mt = new MetaTables(session, ex); 01434 return new ResultSet(mt); 01435 } 01436 01437 /** 01438 * This function returns a <code>ResultSet</code> which describes 01439 * the table types supported by QED. 01440 * 01441 * @exception SQLException may be thrown. 01442 * 01443 * The column in the <code>ResultSet</code> object has the following 01444 * definition: 01445 * <p> 01446 * <variablelist> 01447 * <varlistentry><term>1: TABLE_TYPE</term> 01448 * <listitem> 01449 * <code>String</code> listing the table type. 01450 * One of: <ul> 01451 * <li><code>TABLE</code></li> 01452 * <li><code>VIEW</code></li> 01453 * <li><code>GLOBAL TEMPORARY</code></li> 01454 * <li><code>LOCAL TEMPORARY</code></li> 01455 * </ul></listitem> 01456 * </varlistentry> 01457 * </variablelist> 01458 */ 01459 public java.sql.ResultSet getTableTypes() 01460 throws SQLException 01461 { 01462 MetaTableTypes mt = new MetaTableTypes(session); 01463 return new ResultSet(mt); 01464 } 01465 01466 Expression parseExpression(String s) throws SQLException { 01467 if (s.length() == 0) return null; 01468 try { 01469 session.makeTransaction(); 01470 SQLParser p = new SQLParser(session, s, false); 01471 return p.expression(); 01472 } catch (antlr.TokenStreamException e) { 01473 throw new SQLException(e.toString(), "Q000Y"); 01474 } catch (antlr.RecognitionException e) { 01475 throw new SQL