File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\jdbc\JdbcDatabaseMetaData.java.html

1 /*
2 * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
3 * Version 1.0, and under the Eclipse Public License, Version 1.0
4 * (http://h2database.com/html/license.html).
5 * Initial Developer: H2 Group
6 */
7 package org.h2.jdbc;
8
9 import java.sql.Connection;
10 import java.sql.DatabaseMetaData;
11 import java.sql.PreparedStatement;
12 import java.sql.ResultSet;
13 //## Java 1.6 ##
14 import java.sql.RowIdLifetime;
15 //*/
16 import java.sql.SQLException;
17
18 import org.h2.constant.SysProperties;
19 import org.h2.engine.Constants;
20 import org.h2.message.Trace;
21 import org.h2.message.TraceObject;
22 import org.h2.util.StatementBuilder;
23 import org.h2.util.StringUtils;
24
25 /**
26 * Represents the meta data for a database.
27 */
28 public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaData {
29
30 private final JdbcConnection conn;
31
32 JdbcDatabaseMetaData(JdbcConnection conn, Trace trace, int id) {
33 setTrace(trace, TraceObject.DATABASE_META_DATA, id);
34 this.conn = conn;
35 }
36
37 /**
38 * Returns the major version of this driver.
39 *
40 * @return the major version number
41 */
42 public int getDriverMajorVersion() {
43 debugCodeCall("getDriverMajorVersion");
44 return Constants.VERSION_MAJOR;
45 }
46
47 /**
48 * Returns the minor version of this driver.
49 *
50 * @return the minor version number
51 */
52 public int getDriverMinorVersion() {
53 debugCodeCall("getDriverMinorVersion");
54 return Constants.VERSION_MINOR;
55 }
56
57 /**
58 * Gets the database product name.
59 *
60 * @return the product name ("H2")
61 */
62 public String getDatabaseProductName() {
63 debugCodeCall("getDatabaseProductName");
64 // This value must stay like that, see
65 // http://opensource.atlassian.com/projects/hibernate/browse/HHH-2682
66 return "H2";
67 }
68
69 /**
70 * Gets the product version of the database.
71 *
72 * @return the product version
73 */
74 public String getDatabaseProductVersion() {
75 debugCodeCall("getDatabaseProductVersion");
76 return Constants.getFullVersion();
77 }
78
79 /**
80 * Gets the name of the JDBC driver.
81 *
82 * @return the driver name ("H2 JDBC Driver")
83 */
84 public String getDriverName() {
85 debugCodeCall("getDriverName");
86 return "H2 JDBC Driver";
87 }
88
89 /**
90 * Gets the version number of the driver. The format is
91 * [MajorVersion].[MinorVersion].
92 *
93 * @return the version number
94 */
95 public String getDriverVersion() {
96 debugCodeCall("getDriverVersion");
97 return Constants.getFullVersion();
98 }
99
100 /**
101 * Gets the list of tables in the database. The result set is sorted by
102 * TABLE_TYPE, TABLE_SCHEM, and TABLE_NAME.
103 *
104 * <ul>
105 * <li>1 TABLE_CAT (String) table catalog </li>
106 * <li>2 TABLE_SCHEM (String) table schema </li>
107 * <li>3 TABLE_NAME (String) table name </li>
108 * <li>4 TABLE_TYPE (String) table type </li>
109 * <li>5 REMARKS (String) comment </li>
110 * <li>6 TYPE_CAT (String) always null </li>
111 * <li>7 TYPE_SCHEM (String) always null </li>
112 * <li>8 TYPE_NAME (String) always null </li>
113 * <li>9 SELF_REFERENCING_COL_NAME (String) always null </li>
114 * <li>10 REF_GENERATION (String) always null </li>
115 * <li>11 SQL (String) the create table statement or NULL for systems tables
116 * </li>
117 * </ul>
118 *
119 * @param catalogPattern null (to get all objects) or the catalog name
120 * @param schemaPattern null (to get all objects) or a schema name
121 * (uppercase for unquoted names)
122 * @param tableNamePattern null (to get all objects) or a table name
123 * (uppercase for unquoted names)
124 * @param types null or a list of table types
125 * @return the list of columns
126 * @throws SQLException if the connection is closed
127 */
128 public ResultSet getTables(String catalogPattern, String schemaPattern,
129 String tableNamePattern, String[] types) throws SQLException {
130 try {
131 if (isDebugEnabled()) {
132 debugCode("getTables(" + quote(catalogPattern) + ", " + quote(schemaPattern) + ", " + quote(tableNamePattern)
133 + ", " + quoteArray(types) + ");");
134 }
135 checkClosed();
136 String tableType;
137 if (types != null && types.length > 0) {
138 StatementBuilder buff = new StatementBuilder("TABLE_TYPE IN(");
139 for (int i = 0; i < types.length; i++) {
140 buff.appendExceptFirst(", ");
141 buff.append('?');
142 }
143 tableType = buff.append(')').toString();
144 } else {
145 tableType = "TRUE";
146 }
147 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
148 + "TABLE_CATALOG TABLE_CAT, "
149 + "TABLE_SCHEMA TABLE_SCHEM, "
150 + "TABLE_NAME, "
151 + "TABLE_TYPE, "
152 + "REMARKS, "
153 + "TYPE_NAME TYPE_CAT, "
154 + "TYPE_NAME TYPE_SCHEM, "
155 + "TYPE_NAME, "
156 + "TYPE_NAME SELF_REFERENCING_COL_NAME, "
157 + "TYPE_NAME REF_GENERATION, "
158 + "SQL "
159 + "FROM INFORMATION_SCHEMA.TABLES "
160 + "WHERE TABLE_CATALOG LIKE ? ESCAPE ? "
161 + "AND TABLE_SCHEMA LIKE ? ESCAPE ? "
162 + "AND TABLE_NAME LIKE ? ESCAPE ? "
163 + "AND (" + tableType + ") "
164 + "ORDER BY TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME");
165 prep.setString(1, getCatalogPattern(catalogPattern));
166 prep.setString(2, "\\");
167 prep.setString(3, getSchemaPattern(schemaPattern));
168 prep.setString(4, "\\");
169 prep.setString(5, getPattern(tableNamePattern));
170 prep.setString(6, "\\");
171 for (int i = 0; types != null && i < types.length; i++) {
172 prep.setString(7 + i, types[i]);
173 }
174 return prep.executeQuery();
175 } catch (Exception e) {
176 throw logAndConvert(e);
177 }
178 }
179
180 /**
181 * Gets the list of columns. The result set is sorted by TABLE_SCHEM,
182 * TABLE_NAME, and ORDINAL_POSITION.
183 *
184 * <ul>
185 * <li>1 TABLE_CAT (String) table catalog </li>
186 * <li>2 TABLE_SCHEM (String) table schema </li>
187 * <li>3 TABLE_NAME (String) table name </li>
188 * <li>4 COLUMN_NAME (String) column name </li>
189 * <li>5 DATA_TYPE (short) data type (see java.sql.Types) </li>
190 * <li>6 TYPE_NAME (String) data type name ("INTEGER", "VARCHAR",...) </li>
191 * <li>7 COLUMN_SIZE (int) precision
192 * (values larger than 2 GB are returned as 2 GB)</li>
193 * <li>8 BUFFER_LENGTH (int) unused </li>
194 * <li>9 DECIMAL_DIGITS (int) scale (0 for INTEGER and VARCHAR) </li>
195 * <li>10 NUM_PREC_RADIX (int) radix (always 10) </li>
196 * <li>11 NULLABLE (int) columnNoNulls or columnNullable</li>
197 * <li>12 REMARKS (String) comment (always empty) </li>
198 * <li>13 COLUMN_DEF (String) default value </li>
199 * <li>14 SQL_DATA_TYPE (int) unused </li>
200 * <li>15 SQL_DATETIME_SUB (int) unused </li>
201 * <li>16 CHAR_OCTET_LENGTH (int) unused </li>
202 * <li>17 ORDINAL_POSITION (int) the column index (1,2,...) </li>
203 * <li>18 IS_NULLABLE (String) "NO" or "YES" </li>
204 * <li>19 SCOPE_CATALOG (String) always null </li>
205 * <li>20 SCOPE_SCHEMA (String) always null </li>
206 * <li>21 SCOPE_TABLE (String) always null </li>
207 * <li>22 SOURCE_DATA_TYPE (short) null </li>
208 * <li>23 IS_AUTOINCREMENT (String) "NO" or "YES" </li>
209 * <li>24 SCOPE_CATLOG (String) always null (the typo is on purpose,
210 * for compatibility with the JDBC specification prior to 4.1)</li>
211 * </ul>
212 *
213 * @param catalogPattern null (to get all objects) or the catalog name
214 * @param schemaPattern null (to get all objects) or a schema name
215 * (uppercase for unquoted names)
216 * @param tableNamePattern null (to get all objects) or a table name
217 * (uppercase for unquoted names)
218 * @param columnNamePattern null (to get all objects) or a column name
219 * (uppercase for unquoted names)
220 * @return the list of columns
221 * @throws SQLException if the connection is closed
222 */
223 public ResultSet getColumns(String catalogPattern, String schemaPattern,
224 String tableNamePattern, String columnNamePattern)
225 throws SQLException {
226 try {
227 if (isDebugEnabled()) {
228 debugCode("getColumns(" + quote(catalogPattern)+", "
229 +quote(schemaPattern)+", "
230 +quote(tableNamePattern)+", "
231 +quote(columnNamePattern)+");");
232 }
233 checkClosed();
234 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
235 + "TABLE_CATALOG TABLE_CAT, "
236 + "TABLE_SCHEMA TABLE_SCHEM, "
237 + "TABLE_NAME, "
238 + "COLUMN_NAME, "
239 + "DATA_TYPE, "
240 + "TYPE_NAME, "
241 + "CHARACTER_MAXIMUM_LENGTH COLUMN_SIZE, "
242 + "CHARACTER_MAXIMUM_LENGTH BUFFER_LENGTH, "
243 + "NUMERIC_SCALE DECIMAL_DIGITS, "
244 + "NUMERIC_PRECISION_RADIX NUM_PREC_RADIX, "
245 + "NULLABLE, "
246 + "REMARKS, "
247 + "COLUMN_DEFAULT COLUMN_DEF, "
248 + "DATA_TYPE SQL_DATA_TYPE, "
249 + "ZERO() SQL_DATETIME_SUB, "
250 + "CHARACTER_OCTET_LENGTH CHAR_OCTET_LENGTH, "
251 + "ORDINAL_POSITION, "
252 + "IS_NULLABLE IS_NULLABLE, "
253 + "CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_CATALOG, "
254 + "CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_SCHEMA, "
255 + "CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_TABLE, "
256 + "SOURCE_DATA_TYPE, "
257 + "CASE WHEN SEQUENCE_NAME IS NULL THEN CAST(? AS VARCHAR) ELSE CAST(? AS VARCHAR) END IS_AUTOINCREMENT, "
258 + "CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_CATLOG "
259 + "FROM INFORMATION_SCHEMA.COLUMNS "
260 + "WHERE TABLE_CATALOG LIKE ? ESCAPE ? "
261 + "AND TABLE_SCHEMA LIKE ? ESCAPE ? "
262 + "AND TABLE_NAME LIKE ? ESCAPE ? "
263 + "AND COLUMN_NAME LIKE ? ESCAPE ? "
264 + "ORDER BY TABLE_SCHEM, TABLE_NAME, ORDINAL_POSITION");
265 prep.setString(1, "NO");
266 prep.setString(2, "YES");
267 prep.setString(3, getCatalogPattern(catalogPattern));
268 prep.setString(4, "\\");
269 prep.setString(5, getSchemaPattern(schemaPattern));
270 prep.setString(6, "\\");
271 prep.setString(7, getPattern(tableNamePattern));
272 prep.setString(8, "\\");
273 prep.setString(9, getPattern(columnNamePattern));
274 prep.setString(10, "\\");
275 return prep.executeQuery();
276 } catch (Exception e) {
277 throw logAndConvert(e);
278 }
279 }
280
281 /**
282 * Gets the list of indexes for this database. The primary key index (if
283 * there is one) is also listed, with the name PRIMARY_KEY. The result set
284 * is sorted by NON_UNIQUE ('false' first), TYPE, TABLE_SCHEM, INDEX_NAME,
285 * and ORDINAL_POSITION.
286 *
287 * <ul>
288 * <li>1 TABLE_CAT (String) table catalog </li>
289 * <li>2 TABLE_SCHEM (String) table schema </li>
290 * <li>3 TABLE_NAME (String) table name </li>
291 * <li>4 NON_UNIQUE (boolean) 'true' if non-unique</li>
292 * <li>5 INDEX_QUALIFIER (String) index catalog </li>
293 * <li>6 INDEX_NAME (String) index name </li>
294 * <li>7 TYPE (short) the index type (always tableIndexOther) </li>
295 * <li>8 ORDINAL_POSITION (short) column index (1, 2, ...) </li>
296 * <li>9 COLUMN_NAME (String) column name </li>
297 * <li>10 ASC_OR_DESC (String) ascending or descending (always 'A') </li>
298 * <li>11 CARDINALITY (int) numbers of unique values </li>
299 * <li>12 PAGES (int) number of pages use (always 0) </li>
300 * <li>13 FILTER_CONDITION (String) filter condition (always empty) </li>
301 * <li>14 SORT_TYPE (int) the sort type bit map: 1=DESCENDING,
302 * 2=NULLS_FIRST, 4=NULLS_LAST </li>
303 * </ul>
304 *
305 * @param catalogPattern null or the catalog name
306 * @param schemaPattern null (to get all objects) or a schema name
307 * (uppercase for unquoted names)
308 * @param tableName table name (must be specified)
309 * @param unique only unique indexes
310 * @param approximate is ignored
311 * @return the list of indexes and columns
312 * @throws SQLException if the connection is closed
313 */
314 public ResultSet getIndexInfo(String catalogPattern, String schemaPattern,
315 String tableName, boolean unique, boolean approximate)
316 throws SQLException {
317 try {
318 if (isDebugEnabled()) {
319 debugCode("getIndexInfo(" + quote(catalogPattern) + ", " + quote(schemaPattern) + ", " + quote(tableName) + ", "
320 + unique + ", " + approximate + ");");
321 }
322 String uniqueCondition;
323 if (unique) {
324 uniqueCondition = "NON_UNIQUE=FALSE";
325 } else {
326 uniqueCondition = "TRUE";
327 }
328 checkClosed();
329 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
330 + "TABLE_CATALOG TABLE_CAT, "
331 + "TABLE_SCHEMA TABLE_SCHEM, "
332 + "TABLE_NAME, "
333 + "NON_UNIQUE, "
334 + "TABLE_CATALOG INDEX_QUALIFIER, "
335 + "INDEX_NAME, "
336 + "INDEX_TYPE TYPE, "
337 + "ORDINAL_POSITION, "
338 + "COLUMN_NAME, "
339 + "ASC_OR_DESC, "
340 // TODO meta data for number of unique values in an index
341 + "CARDINALITY, "
342 + "PAGES, "
343 + "FILTER_CONDITION, "
344 + "SORT_TYPE "
345 + "FROM INFORMATION_SCHEMA.INDEXES "
346 + "WHERE TABLE_CATALOG LIKE ? ESCAPE ? "
347 + "AND TABLE_SCHEMA LIKE ? ESCAPE ? "
348 + "AND (" + uniqueCondition + ") "
349 + "AND TABLE_NAME = ? "
350 + "ORDER BY NON_UNIQUE, TYPE, TABLE_SCHEM, INDEX_NAME, ORDINAL_POSITION");
351 prep.setString(1, getCatalogPattern(catalogPattern));
352 prep.setString(2, "\\");
353 prep.setString(3, getSchemaPattern(schemaPattern));
354 prep.setString(4, "\\");
355 prep.setString(5, tableName);
356 return prep.executeQuery();
357 } catch (Exception e) {
358 throw logAndConvert(e);
359 }
360 }
361
362 /**
363 * Gets the primary key columns for a table. The result set is sorted by
364 * TABLE_SCHEM, and COLUMN_NAME (and not by KEY_SEQ).
365 *
366 * <ul>
367 * <li>1 TABLE_CAT (String) table catalog</li>
368 * <li>2 TABLE_SCHEM (String) table schema</li>
369 * <li>3 TABLE_NAME (String) table name</li>
370 * <li>4 COLUMN_NAME (String) column name</li>
371 * <li>5 KEY_SEQ (short) the column index of this column (1,2,...)</li>
372 * <li>6 PK_NAME (String) the name of the primary key index</li>
373 * </ul>
374 *
375 * @param catalogPattern null or the catalog name
376 * @param schemaPattern null (to get all objects) or a schema name
377 * (uppercase for unquoted names)
378 * @param tableName table name (must be specified)
379 * @return the list of primary key columns
380 * @throws SQLException if the connection is closed
381 */
382 public ResultSet getPrimaryKeys(String catalogPattern, String schemaPattern, String tableName) throws SQLException {
383 try {
384 if (isDebugEnabled()) {
385 debugCode("getPrimaryKeys("
386 +quote(catalogPattern)+", "
387 +quote(schemaPattern)+", "
388 +quote(tableName)+");");
389 }
390 checkClosed();
391 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
392 + "TABLE_CATALOG TABLE_CAT, "
393 + "TABLE_SCHEMA TABLE_SCHEM, "
394 + "TABLE_NAME, "
395 + "COLUMN_NAME, "
396 + "ORDINAL_POSITION KEY_SEQ, "
397 + "IFNULL(CONSTRAINT_NAME, INDEX_NAME) PK_NAME "
398 + "FROM INFORMATION_SCHEMA.INDEXES "
399 + "WHERE TABLE_CATALOG LIKE ? ESCAPE ? "
400 + "AND TABLE_SCHEMA LIKE ? ESCAPE ? "
401 + "AND TABLE_NAME = ? "
402 + "AND PRIMARY_KEY = TRUE "
403 + "ORDER BY COLUMN_NAME");
404 prep.setString(1, getCatalogPattern(catalogPattern));
405 prep.setString(2, "\\");
406 prep.setString(3, getSchemaPattern(schemaPattern));
407 prep.setString(4, "\\");
408 prep.setString(5, tableName);
409 return prep.executeQuery();
410 } catch (Exception e) {
411 throw logAndConvert(e);
412 }
413 }
414
415 /**
416 * Checks if all procedures callable.
417 *
418 * @return true
419 */
420 public boolean allProceduresAreCallable() {
421 debugCodeCall("allProceduresAreCallable");
422 return true;
423 }
424
425 /**
426 * Checks if it possible to query all tables returned by getTables.
427 *
428 * @return true
429 */
430 public boolean allTablesAreSelectable() {
431 debugCodeCall("allTablesAreSelectable");
432 return true;
433 }
434
435 /**
436 * Returns the database URL for this connection.
437 *
438 * @return the url
439 */
440 public String getURL() throws SQLException {
441 try {
442 debugCodeCall("getURL");
443 return conn.getURL();
444 } catch (Exception e) {
445 throw logAndConvert(e);
446 }
447 }
448
449 /**
450 * Returns the user name as passed to DriverManager.getConnection(url, user,
451 * password).
452 *
453 * @return the user name
454 */
455 public String getUserName() throws SQLException {
456 try {
457 debugCodeCall("getUserName");
458 return conn.getUser();
459 } catch (Exception e) {
460 throw logAndConvert(e);
461 }
462 }
463
464 /**
465 * Returns the same as Connection.isReadOnly().
466 *
467 * @return if read only optimization is switched on
468 */
469 public boolean isReadOnly() throws SQLException {
470 try {
471 debugCodeCall("isReadOnly");
472 return conn.isReadOnly();
473 } catch (Exception e) {
474 throw logAndConvert(e);
475 }
476 }
477
478 /**
479 * Checks if NULL is sorted high (bigger than anything that is not null).
480 *
481 * @return false by default; true if the system property h2.sortNullsHigh is
482 * set to true
483 */
484 public boolean nullsAreSortedHigh() {
485 debugCodeCall("nullsAreSortedHigh");
486 return SysProperties.SORT_NULLS_HIGH;
487 }
488
489 /**
490 * Checks if NULL is sorted low (smaller than anything that is not null).
491 *
492 * @return true by default; false if the system property h2.sortNullsHigh is
493 * set to true
494 */
495 public boolean nullsAreSortedLow() {
496 debugCodeCall("nullsAreSortedLow");
497 return !SysProperties.SORT_NULLS_HIGH;
498 }
499
500 /**
501 * Checks if NULL is sorted at the beginning (no matter if ASC or DESC is
502 * used).
503 *
504 * @return false
505 */
506 public boolean nullsAreSortedAtStart() {
507 debugCodeCall("nullsAreSortedAtStart");
508 return false;
509 }
510
511 /**
512 * Checks if NULL is sorted at the end (no matter if ASC or DESC is used).
513 *
514 * @return false
515 */
516 public boolean nullsAreSortedAtEnd() {
517 debugCodeCall("nullsAreSortedAtEnd");
518 return false;
519 }
520
521 /**
522 * Returns the connection that created this object.
523 *
524 * @return the connection
525 */
526 public Connection getConnection() {
527 debugCodeCall("getConnection");
528 return conn;
529 }
530
531 /**
532 * Gets the list of procedures. The result set is sorted by PROCEDURE_SCHEM,
533 * PROCEDURE_NAME, and NUM_INPUT_PARAMS. There are potentially multiple
534 * procedures with the same name, each with a different number of input
535 * parameters.
536 *
537 * <ul>
538 * <li>1 PROCEDURE_CAT (String) catalog </li>
539 * <li>2 PROCEDURE_SCHEM (String) schema </li>
540 * <li>3 PROCEDURE_NAME (String) name </li>
541 * <li>4 NUM_INPUT_PARAMS (int) the number of arguments </li>
542 * <li>5 NUM_OUTPUT_PARAMS (int) for future use, always 0 </li>
543 * <li>6 NUM_RESULT_SETS (int) for future use, always 0 </li>
544 * <li>7 REMARKS (String) description </li>
545 * <li>8 PROCEDURE_TYPE (short) if this procedure returns a result
546 * (procedureNoResult or procedureReturnsResult) </li>
547 * <li>9 SPECIFIC_NAME (String) name </li>
548 * </ul>
549 *
550 * @param catalogPattern null or the catalog name
551 * @param schemaPattern null (to get all objects) or a schema name
552 * (uppercase for unquoted names)
553 * @param procedureNamePattern the procedure name pattern
554 * @return the procedures
555 * @throws SQLException if the connection is closed
556 */
557 public ResultSet getProcedures(String catalogPattern, String schemaPattern,
558 String procedureNamePattern) throws SQLException {
559 try {
560 if (isDebugEnabled()) {
561 debugCode("getProcedures("
562 +quote(catalogPattern)+", "
563 +quote(schemaPattern)+", "
564 +quote(procedureNamePattern)+");");
565 }
566 checkClosed();
567 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
568 + "ALIAS_CATALOG PROCEDURE_CAT, "
569 + "ALIAS_SCHEMA PROCEDURE_SCHEM, "
570 + "ALIAS_NAME PROCEDURE_NAME, "
571 + "COLUMN_COUNT NUM_INPUT_PARAMS, "
572 + "ZERO() NUM_OUTPUT_PARAMS, "
573 + "ZERO() NUM_RESULT_SETS, "
574 + "REMARKS, "
575 + "RETURNS_RESULT PROCEDURE_TYPE, "
576 + "ALIAS_NAME SPECIFIC_NAME "
577 + "FROM INFORMATION_SCHEMA.FUNCTION_ALIASES "
578 + "WHERE ALIAS_CATALOG LIKE ? ESCAPE ? "
579 + "AND ALIAS_SCHEMA LIKE ? ESCAPE ? "
580 + "AND ALIAS_NAME LIKE ? ESCAPE ? "
581 + "ORDER BY PROCEDURE_SCHEM, PROCEDURE_NAME, NUM_INPUT_PARAMS");
582 prep.setString(1, getCatalogPattern(catalogPattern));
583 prep.setString(2, "\\");
584 prep.setString(3, getSchemaPattern(schemaPattern));
585 prep.setString(4, "\\");
586 prep.setString(5, getPattern(procedureNamePattern));
587 prep.setString(6, "\\");
588 return prep.executeQuery();
589 } catch (Exception e) {
590 throw logAndConvert(e);
591 }
592 }
593
594 /**
595 * Gets the list of procedure columns. The result set is sorted by
596 * PROCEDURE_SCHEM, PROCEDURE_NAME, NUM_INPUT_PARAMS, and POS.
597 * There are potentially multiple procedures with the same name, each with a
598 * different number of input parameters.
599 *
600 * <ul>
601 * <li>1 PROCEDURE_CAT (String) catalog </li>
602 * <li>2 PROCEDURE_SCHEM (String) schema </li>
603 * <li>3 PROCEDURE_NAME (String) name </li>
604 * <li>4 COLUMN_NAME (String) column name </li>
605 * <li>5 COLUMN_TYPE (short) column type
606 * (always DatabaseMetaData.procedureColumnIn)</li>
607 * <li>6 DATA_TYPE (short) sql type </li>
608 * <li>7 TYPE_NAME (String) type name </li>
609 * <li>8 PRECISION (int) precision </li>
610 * <li>9 LENGTH (int) length </li>
611 * <li>10 SCALE (short) scale </li>
612 * <li>11 RADIX (int) always 10 </li>
613 * <li>12 NULLABLE (short) nullable
614 * (DatabaseMetaData.columnNoNulls for primitive data types,
615 * DatabaseMetaData.columnNullable otherwise)</li>
616 * <li>13 REMARKS (String) description </li>
617 * <li>14 COLUMN_DEF (String) always null </li>
618 * <li>15 SQL_DATA_TYPE (int) for future use, always 0 </li>
619 * <li>16 SQL_DATETIME_SUB (int) for future use, always 0 </li>
620 * <li>17 CHAR_OCTET_LENGTH (int) always null </li>
621 * <li>18 ORDINAL_POSITION (int) the parameter index
622 * starting from 1 (0 is the return value) </li>
623 * <li>19 IS_NULLABLE (String) always "YES" </li>
624 * <li>20 SPECIFIC_NAME (String) name </li>
625 * </ul>
626 *
627 * @param catalogPattern null or the catalog name
628 * @param schemaPattern null (to get all objects) or a schema name
629 * (uppercase for unquoted names)
630 * @param procedureNamePattern the procedure name pattern
631 * @param columnNamePattern the procedure name pattern
632 * @return the procedure columns
633 * @throws SQLException if the connection is closed
634 */
635 public ResultSet getProcedureColumns(String catalogPattern, String schemaPattern,
636 String procedureNamePattern, String columnNamePattern)
637 throws SQLException {
638 try {
639 if (isDebugEnabled()) {
640 debugCode("getProcedureColumns("
641 +quote(catalogPattern)+", "
642 +quote(schemaPattern)+", "
643 +quote(procedureNamePattern)+", "
644 +quote(columnNamePattern)+");");
645 }
646 checkClosed();
647 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
648 + "ALIAS_CATALOG PROCEDURE_CAT, "
649 + "ALIAS_SCHEMA PROCEDURE_SCHEM, "
650 + "ALIAS_NAME PROCEDURE_NAME, "
651 + "COLUMN_NAME, "
652 + "COLUMN_TYPE, "
653 + "DATA_TYPE, "
654 + "TYPE_NAME, "
655 + "PRECISION, "
656 + "PRECISION LENGTH, "
657 + "SCALE, "
658 + "RADIX, "
659 + "NULLABLE, "
660 + "REMARKS, "
661 + "COLUMN_DEFAULT COLUMN_DEF, "
662 + "ZERO() SQL_DATA_TYPE, "
663 + "ZERO() SQL_DATETIME_SUB, "
664 + "ZERO() CHAR_OCTET_LENGTH, "
665 + "POS ORDINAL_POSITION, "
666 + "? IS_NULLABLE, "
667 + "ALIAS_NAME SPECIFIC_NAME "
668 + "FROM INFORMATION_SCHEMA.FUNCTION_COLUMNS "
669 + "WHERE ALIAS_CATALOG LIKE ? ESCAPE ? "
670 + "AND ALIAS_SCHEMA LIKE ? ESCAPE ? "
671 + "AND ALIAS_NAME LIKE ? ESCAPE ? "
672 + "AND COLUMN_NAME LIKE ? ESCAPE ? "
673 + "ORDER BY PROCEDURE_SCHEM, PROCEDURE_NAME, ORDINAL_POSITION");
674 prep.setString(1, "YES");
675 prep.setString(2, getCatalogPattern(catalogPattern));
676 prep.setString(3, "\\");
677 prep.setString(4, getSchemaPattern(schemaPattern));
678 prep.setString(5, "\\");
679 prep.setString(6, getPattern(procedureNamePattern));
680 prep.setString(7, "\\");
681 prep.setString(8, getPattern(columnNamePattern));
682 prep.setString(9, "\\");
683 return prep.executeQuery();
684 } catch (Exception e) {
685 throw logAndConvert(e);
686 }
687 }
688
689 /**
690 * Gets the list of schemas.
691 * The result set is sorted by TABLE_SCHEM.
692 *
693 * <ul>
694 * <li>1 TABLE_SCHEM (String) schema name
695 * </li><li>2 TABLE_CATALOG (String) catalog name
696 * </li><li>3 IS_DEFAULT (boolean) if this is the default schema
697 * </li></ul>
698 *
699 * @return the schema list
700 * @throws SQLException if the connection is closed
701 */
702 public ResultSet getSchemas() throws SQLException {
703 try {
704 debugCodeCall("getSchemas");
705 checkClosed();
706 PreparedStatement prep = conn
707 .prepareAutoCloseStatement("SELECT "
708 + "SCHEMA_NAME TABLE_SCHEM, "
709 + "CATALOG_NAME TABLE_CATALOG, "
710 +" IS_DEFAULT "
711 + "FROM INFORMATION_SCHEMA.SCHEMATA "
712 + "ORDER BY SCHEMA_NAME");
713 return prep.executeQuery();
714 } catch (Exception e) {
715 throw logAndConvert(e);
716 }
717 }
718
719 /**
720 * Gets the list of catalogs.
721 * The result set is sorted by TABLE_CAT.
722 *
723 * <ul>
724 * <li>1 TABLE_CAT (String) catalog name
725 * </li></ul>
726 *
727 * @return the catalog list
728 * @throws SQLException if the connection is closed
729 */
730 public ResultSet getCatalogs() throws SQLException {
731 try {
732 debugCodeCall("getCatalogs");
733 checkClosed();
734 PreparedStatement prep = conn.prepareAutoCloseStatement(
735 "SELECT CATALOG_NAME TABLE_CAT "
736 + "FROM INFORMATION_SCHEMA.CATALOGS");
737 return prep.executeQuery();
738 } catch (Exception e) {
739 throw logAndConvert(e);
740 }
741 }
742
743 /**
744 * Gets the list of table types. This call returns a result set with three
745 * records: "SYSTEM TABLE", "TABLE", "and "VIEW".
746 * The result set is sorted by TABLE_TYPE.
747 *
748 * <ul>
749 * <li>1 TABLE_TYPE (String) table type
750 * </li></ul>
751 *
752 * @return the table types
753 * @throws SQLException if the connection is closed
754 */
755 public ResultSet getTableTypes() throws SQLException {
756 try {
757 debugCodeCall("getTableTypes");
758 checkClosed();
759 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
760 + "TYPE TABLE_TYPE "
761 + "FROM INFORMATION_SCHEMA.TABLE_TYPES "
762 + "ORDER BY TABLE_TYPE");
763 return prep.executeQuery();
764 } catch (Exception e) {
765 throw logAndConvert(e);
766 }
767 }
768
769 /**
770 * Gets the list of column privileges. The result set is sorted by
771 * COLUMN_NAME and PRIVILEGE
772 *
773 * <ul>
774 * <li>1 TABLE_CAT (String) table catalog </li>
775 * <li>2 TABLE_SCHEM (String) table schema </li>
776 * <li>3 TABLE_NAME (String) table name </li>
777 * <li>4 COLUMN_NAME (String) column name </li>
778 * <li>5 GRANTOR (String) grantor of access </li>
779 * <li>6 GRANTEE (String) grantee of access </li>
780 * <li>7 PRIVILEGE (String) SELECT, INSERT, UPDATE, DELETE or REFERENCES
781 * (only one per row) </li>
782 * <li>8 IS_GRANTABLE (String) YES means the grantee can grant access to
783 * others </li>
784 * </ul>
785 *
786 * @param catalogPattern null (to get all objects) or the catalog name
787 * @param schemaPattern null (to get all objects) or a schema name (uppercase for
788 * unquoted names)
789 * @param table a table name (uppercase for unquoted names)
790 * @param columnNamePattern null (to get all objects) or a column name
791 * (uppercase for unquoted names)
792 * @return the list of privileges
793 * @throws SQLException if the connection is closed
794 */
795 public ResultSet getColumnPrivileges(String catalogPattern, String schemaPattern,
796 String table, String columnNamePattern) throws SQLException {
797 try {
798 if (isDebugEnabled()) {
799 debugCode("getColumnPrivileges("
800 +quote(catalogPattern)+", "
801 +quote(schemaPattern)+", "
802 +quote(table)+", "
803 +quote(columnNamePattern)+");");
804 }
805 checkClosed();
806 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
807 + "TABLE_CATALOG TABLE_CAT, "
808 + "TABLE_SCHEMA TABLE_SCHEM, "
809 + "TABLE_NAME, "
810 + "COLUMN_NAME, "
811 + "GRANTOR, "
812 + "GRANTEE, "
813 + "PRIVILEGE_TYPE PRIVILEGE, "
814 + "IS_GRANTABLE "
815 + "FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES "
816 + "WHERE TABLE_CATALOG LIKE ? ESCAPE ? "
817 + "AND TABLE_SCHEMA LIKE ? ESCAPE ? "
818 + "AND TABLE_NAME = ? "
819 + "AND COLUMN_NAME LIKE ? ESCAPE ? "
820 + "ORDER BY COLUMN_NAME, PRIVILEGE");
821 prep.setString(1, getCatalogPattern(catalogPattern));
822 prep.setString(2, "\\");
823 prep.setString(3, getSchemaPattern(schemaPattern));
824 prep.setString(4, "\\");
825 prep.setString(5, table);
826 prep.setString(6, getPattern(columnNamePattern));
827 prep.setString(7, "\\");
828 return prep.executeQuery();
829 } catch (Exception e) {
830 throw logAndConvert(e);
831 }
832 }
833
834 /**
835 * Gets the list of table privileges. The result set is sorted by
836 * TABLE_SCHEM, TABLE_NAME, and PRIVILEGE.
837 *
838 * <ul>
839 * <li>1 TABLE_CAT (String) table catalog </li>
840 * <li>2 TABLE_SCHEM (String) table schema </li>
841 * <li>3 TABLE_NAME (String) table name </li>
842 * <li>4 GRANTOR (String) grantor of access </li>
843 * <li>5 GRANTEE (String) grantee of access </li>
844 * <li>6 PRIVILEGE (String) SELECT, INSERT, UPDATE, DELETE or REFERENCES
845 * (only one per row) </li>
846 * <li>7 IS_GRANTABLE (String) YES means the grantee can grant access to
847 * others </li>
848 * </ul>
849 *
850 * @param catalogPattern null (to get all objects) or the catalog name
851 * @param schemaPattern null (to get all objects) or a schema name
852 * (uppercase for unquoted names)
853 * @param tableNamePattern null (to get all objects) or a table name
854 * (uppercase for unquoted names)
855 * @return the list of privileges
856 * @throws SQLException if the connection is closed
857 */
858 public ResultSet getTablePrivileges(String catalogPattern, String schemaPattern,
859 String tableNamePattern) throws SQLException {
860 try {
861 if (isDebugEnabled()) {
862 debugCode("getTablePrivileges("
863 +quote(catalogPattern)+", "
864 +quote(schemaPattern)+", "
865 +quote(tableNamePattern)+");");
866 }
867 checkClosed();
868 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
869 + "TABLE_CATALOG TABLE_CAT, "
870 + "TABLE_SCHEMA TABLE_SCHEM, "
871 + "TABLE_NAME, "
872 + "GRANTOR, "
873 + "GRANTEE, "
874 + "PRIVILEGE_TYPE PRIVILEGE, "
875 + "IS_GRANTABLE "
876 + "FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES "
877 + "WHERE TABLE_CATALOG LIKE ? ESCAPE ? "
878 + "AND TABLE_SCHEMA LIKE ? ESCAPE ? "
879 + "AND TABLE_NAME LIKE ? ESCAPE ? "
880 + "ORDER BY TABLE_SCHEM, TABLE_NAME, PRIVILEGE");
881 prep.setString(1, getCatalogPattern(catalogPattern));
882 prep.setString(2, "\\");
883 prep.setString(3, getSchemaPattern(schemaPattern));
884 prep.setString(4, "\\");
885 prep.setString(5, getPattern(tableNamePattern));
886 prep.setString(6, "\\");
887 return prep.executeQuery();
888 } catch (Exception e) {
889 throw logAndConvert(e);
890 }
891 }
892
893 /**
894 * Gets the list of columns that best identifier a row in a table.
895 * The list is ordered by SCOPE.
896 *
897 * <ul>
898 * <li>1 SCOPE (short) scope of result (always bestRowSession)
899 * </li><li>2 COLUMN_NAME (String) column name
900 * </li><li>3 DATA_TYPE (short) SQL data type, see also java.sql.Types
901 * </li><li>4 TYPE_NAME (String) type name
902 * </li><li>5 COLUMN_SIZE (int) precision
903 * (values larger than 2 GB are returned as 2 GB)
904 * </li><li>6 BUFFER_LENGTH (int) unused
905 * </li><li>7 DECIMAL_DIGITS (short) scale
906 * </li><li>8 PSEUDO_COLUMN (short) (always bestRowNotPseudo)
907 * </li></ul>
908 *
909 * @param catalogPattern null (to get all objects) or the catalog name
910 * @param schemaPattern null (to get all objects) or a schema name
911 * (uppercase for unquoted names)
912 * @param tableName table name (must be specified)
913 * @param scope ignored
914 * @param nullable ignored
915 * @return the primary key index
916 * @throws SQLException if the connection is closed
917 */
918 public ResultSet getBestRowIdentifier(String catalogPattern, String schemaPattern,
919 String tableName, int scope, boolean nullable) throws SQLException {
920 try {
921 if (isDebugEnabled()) {
922 debugCode("getBestRowIdentifier("
923 +quote(catalogPattern)+", "
924 +quote(schemaPattern)+", "
925 +quote(tableName)+", "
926 +scope+", "+nullable+");");
927 }
928 checkClosed();
929 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
930 + "CAST(? AS SMALLINT) SCOPE, "
931 + "C.COLUMN_NAME, "
932 + "C.DATA_TYPE, "
933 + "C.TYPE_NAME, "
934 + "C.CHARACTER_MAXIMUM_LENGTH COLUMN_SIZE, "
935 + "C.CHARACTER_MAXIMUM_LENGTH BUFFER_LENGTH, "
936 + "CAST(C.NUMERIC_SCALE AS SMALLINT) DECIMAL_DIGITS, "
937 + "CAST(? AS SMALLINT) PSEUDO_COLUMN "
938 + "FROM INFORMATION_SCHEMA.INDEXES I, "
939 +" INFORMATION_SCHEMA.COLUMNS C "
940 + "WHERE C.TABLE_NAME = I.TABLE_NAME "
941 + "AND C.COLUMN_NAME = I.COLUMN_NAME "
942 + "AND C.TABLE_CATALOG LIKE ? ESCAPE ? "
943 + "AND C.TABLE_SCHEMA LIKE ? ESCAPE ? "
944 + "AND C.TABLE_NAME = ? "
945 + "AND I.PRIMARY_KEY = TRUE "
946 + "ORDER BY SCOPE");
947 // SCOPE
948 prep.setInt(1, DatabaseMetaData.bestRowSession);
949 // PSEUDO_COLUMN
950 prep.setInt(2, DatabaseMetaData.bestRowNotPseudo);
951 prep.setString(3, getCatalogPattern(catalogPattern));
952 prep.setString(4, "\\");
953 prep.setString(5, getSchemaPattern(schemaPattern));
954 prep.setString(6, "\\");
955 prep.setString(7, tableName);
956 return prep.executeQuery();
957 } catch (Exception e) {
958 throw logAndConvert(e);
959 }
960 }
961
962 /**
963 * Get the list of columns that are update when any value is updated.
964 * The result set is always empty.
965 *
966 * <ul>
967 * <li>1 SCOPE (int) not used
968 * </li><li>2 COLUMN_NAME (String) column name
969 * </li><li>3 DATA_TYPE (int) SQL data type - see also java.sql.Types
970 * </li><li>4 TYPE_NAME (String) data type name
971 * </li><li>5 COLUMN_SIZE (int) precision
972 * (values larger than 2 GB are returned as 2 GB)
973 * </li><li>6 BUFFER_LENGTH (int) length (bytes)
974 * </li><li>7 DECIMAL_DIGITS (int) scale
975 * </li><li>8 PSEUDO_COLUMN (int) is this column a pseudo column
976 * </li></ul>
977 *
978 * @param catalog null (to get all objects) or the catalog name
979 * @param schema null (to get all objects) or a schema name
980 * @param tableName table name (must be specified)
981 * @return an empty result set
982 * @throws SQLException if the connection is closed
983 */
984 public ResultSet getVersionColumns(String catalog, String schema,
985 String tableName) throws SQLException {
986 try {
987 if (isDebugEnabled()) {
988 debugCode("getVersionColumns("
989 +quote(catalog)+", "
990 +quote(schema)+", "
991 +quote(tableName)+");");
992 }
993 checkClosed();
994 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
995 + "ZERO() SCOPE, "
996 + "COLUMN_NAME, "
997 + "CAST(DATA_TYPE AS INT) DATA_TYPE, "
998 + "TYPE_NAME, "
999 + "NUMERIC_PRECISION COLUMN_SIZE, "
1000 + "NUMERIC_PRECISION BUFFER_LENGTH, "
1001 + "NUMERIC_PRECISION DECIMAL_DIGITS, "
1002 + "ZERO() PSEUDO_COLUMN "
1003 + "FROM INFORMATION_SCHEMA.COLUMNS "
1004 + "WHERE FALSE");
1005 return prep.executeQuery();
1006 } catch (Exception e) {
1007 throw logAndConvert(e);
1008 }
1009 }
1010
1011 /**
1012 * Gets the list of primary key columns that are referenced by a table. The
1013 * result set is sorted by PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME,
1014 * FK_NAME, KEY_SEQ.
1015 *
1016 * <ul>
1017 * <li>1 PKTABLE_CAT (String) primary catalog </li>
1018 * <li>2 PKTABLE_SCHEM (String) primary schema </li>
1019 * <li>3 PKTABLE_NAME (String) primary table </li>
1020 * <li>4 PKCOLUMN_NAME (String) primary column </li>
1021 * <li>5 FKTABLE_CAT (String) foreign catalog </li>
1022 * <li>6 FKTABLE_SCHEM (String) foreign schema </li>
1023 * <li>7 FKTABLE_NAME (String) foreign table </li>
1024 * <li>8 FKCOLUMN_NAME (String) foreign column </li>
1025 * <li>9 KEY_SEQ (short) sequence number (1, 2, ...) </li>
1026 * <li>10 UPDATE_RULE (short) action on update (see
1027 * DatabaseMetaData.importedKey...) </li>
1028 * <li>11 DELETE_RULE (short) action on delete (see
1029 * DatabaseMetaData.importedKey...) </li>
1030 * <li>12 FK_NAME (String) foreign key name </li>
1031 * <li>13 PK_NAME (String) primary key name </li>
1032 * <li>14 DEFERRABILITY (short) deferrable or not (always
1033 * importedKeyNotDeferrable) </li>
1034 * </ul>
1035 *
1036 * @param catalogPattern null (to get all objects) or the catalog name
1037 * @param schemaPattern the schema name of the foreign table
1038 * @param tableName the name of the foreign table
1039 * @return the result set
1040 * @throws SQLException if the connection is closed
1041 */
1042 public ResultSet getImportedKeys(String catalogPattern, String schemaPattern, String tableName) throws SQLException {
1043 try {
1044 if (isDebugEnabled()) {
1045 debugCode("getImportedKeys("
1046 +quote(catalogPattern)+", "
1047 +quote(schemaPattern)+", "
1048 +quote(tableName)+");");
1049 }
1050 checkClosed();
1051 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
1052 + "PKTABLE_CATALOG PKTABLE_CAT, "
1053 + "PKTABLE_SCHEMA PKTABLE_SCHEM, "
1054 + "PKTABLE_NAME PKTABLE_NAME, "
1055 + "PKCOLUMN_NAME, "
1056 + "FKTABLE_CATALOG FKTABLE_CAT, "
1057 + "FKTABLE_SCHEMA FKTABLE_SCHEM, "
1058 + "FKTABLE_NAME, "
1059 + "FKCOLUMN_NAME, "
1060 + "ORDINAL_POSITION KEY_SEQ, "
1061 + "UPDATE_RULE, "
1062 + "DELETE_RULE, "
1063 + "FK_NAME, "
1064 + "PK_NAME, "
1065 + "DEFERRABILITY "
1066 + "FROM INFORMATION_SCHEMA.CROSS_REFERENCES "
1067 + "WHERE FKTABLE_CATALOG LIKE ? ESCAPE ? "
1068 + "AND FKTABLE_SCHEMA LIKE ? ESCAPE ? "
1069 + "AND FKTABLE_NAME = ? "
1070 + "ORDER BY PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME, FK_NAME, KEY_SEQ");
1071 prep.setString(1, getCatalogPattern(catalogPattern));
1072 prep.setString(2, "\\");
1073 prep.setString(3, getSchemaPattern(schemaPattern));
1074 prep.setString(4, "\\");
1075 prep.setString(5, tableName);
1076 return prep.executeQuery();
1077 } catch (Exception e) {
1078 throw logAndConvert(e);
1079 }
1080 }
1081
1082 /**
1083 * Gets the list of foreign key columns that reference a table. The result
1084 * set is sorted by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, FK_NAME,
1085 * KEY_SEQ.
1086 *
1087 * <ul>
1088 * <li>1 PKTABLE_CAT (String) primary catalog </li>
1089 * <li>2 PKTABLE_SCHEM (String) primary schema </li>
1090 * <li>3 PKTABLE_NAME (String) primary table </li>
1091 * <li>4 PKCOLUMN_NAME (String) primary column </li>
1092 * <li>5 FKTABLE_CAT (String) foreign catalog </li>
1093 * <li>6 FKTABLE_SCHEM (String) foreign schema </li>
1094 * <li>7 FKTABLE_NAME (String) foreign table </li>
1095 * <li>8 FKCOLUMN_NAME (String) foreign column </li>
1096 * <li>9 KEY_SEQ (short) sequence number (1,2,...) </li>
1097 * <li>10 UPDATE_RULE (short) action on update (see
1098 * DatabaseMetaData.importedKey...) </li>
1099 * <li>11 DELETE_RULE (short) action on delete (see
1100 * DatabaseMetaData.importedKey...) </li>
1101 * <li>12 FK_NAME (String) foreign key name </li>
1102 * <li>13 PK_NAME (String) primary key name </li>
1103 * <li>14 DEFERRABILITY (short) deferrable or not (always
1104 * importedKeyNotDeferrable) </li>
1105 * </ul>
1106 *
1107 * @param catalogPattern null or the catalog name
1108 * @param schemaPattern the schema name of the primary table
1109 * @param tableName the name of the primary table
1110 * @return the result set
1111 * @throws SQLException if the connection is closed
1112 */
1113 public ResultSet getExportedKeys(String catalogPattern, String schemaPattern, String tableName)
1114 throws SQLException {
1115 try {
1116 if (isDebugEnabled()) {
1117 debugCode("getExportedKeys("
1118 +quote(catalogPattern)+", "
1119 +quote(schemaPattern)+", "
1120 +quote(tableName)+");");
1121 }
1122 checkClosed();
1123 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
1124 + "PKTABLE_CATALOG PKTABLE_CAT, "
1125 + "PKTABLE_SCHEMA PKTABLE_SCHEM, "
1126 + "PKTABLE_NAME PKTABLE_NAME, "
1127 + "PKCOLUMN_NAME, "
1128 + "FKTABLE_CATALOG FKTABLE_CAT, "
1129 + "FKTABLE_SCHEMA FKTABLE_SCHEM, "
1130 + "FKTABLE_NAME, "
1131 + "FKCOLUMN_NAME, "
1132 + "ORDINAL_POSITION KEY_SEQ, "
1133 + "UPDATE_RULE, "
1134 + "DELETE_RULE, "
1135 + "FK_NAME, "
1136 + "PK_NAME, "
1137 + "DEFERRABILITY "
1138 + "FROM INFORMATION_SCHEMA.CROSS_REFERENCES "
1139 + "WHERE PKTABLE_CATALOG LIKE ? ESCAPE ? "
1140 + "AND PKTABLE_SCHEMA LIKE ? ESCAPE ? "
1141 + "AND PKTABLE_NAME = ? "
1142 + "ORDER BY FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, FK_NAME, KEY_SEQ");
1143 prep.setString(1, getCatalogPattern(catalogPattern));
1144 prep.setString(2, "\\");
1145 prep.setString(3, getSchemaPattern(schemaPattern));
1146 prep.setString(4, "\\");
1147 prep.setString(5, tableName);
1148 return prep.executeQuery();
1149 } catch (Exception e) {
1150 throw logAndConvert(e);
1151 }
1152 }
1153
1154 /**
1155 * Gets the list of foreign key columns that references a table, as well as
1156 * the list of primary key columns that are references by a table. The
1157 * result set is sorted by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME,
1158 * FK_NAME, KEY_SEQ.
1159 *
1160 * <ul>
1161 * <li>1 PKTABLE_CAT (String) primary catalog </li>
1162 * <li>2 PKTABLE_SCHEM (String) primary schema </li>
1163 * <li>3 PKTABLE_NAME (String) primary table </li>
1164 * <li>4 PKCOLUMN_NAME (String) primary column </li>
1165 * <li>5 FKTABLE_CAT (String) foreign catalog </li>
1166 * <li>6 FKTABLE_SCHEM (String) foreign schema </li>
1167 * <li>7 FKTABLE_NAME (String) foreign table </li>
1168 * <li>8 FKCOLUMN_NAME (String) foreign column </li>
1169 * <li>9 KEY_SEQ (short) sequence number (1,2,...) </li>
1170 * <li>10 UPDATE_RULE (short) action on update (see
1171 * DatabaseMetaData.importedKey...) </li>
1172 * <li>11 DELETE_RULE (short) action on delete (see
1173 * DatabaseMetaData.importedKey...) </li>
1174 * <li>12 FK_NAME (String) foreign key name </li>
1175 * <li>13 PK_NAME (String) primary key name </li>
1176 * <li>14 DEFERRABILITY (short) deferrable or not (always
1177 * importedKeyNotDeferrable) </li>
1178 * </ul>
1179 *
1180 * @param primaryCatalogPattern null or the catalog name
1181 * @param primarySchemaPattern the schema name of the primary table
1182 * (optional)
1183 * @param primaryTable the name of the primary table (must be specified)
1184 * @param foreignCatalogPattern null or the catalog name
1185 * @param foreignSchemaPattern the schema name of the foreign table
1186 * (optional)
1187 * @param foreignTable the name of the foreign table (must be specified)
1188 * @return the result set
1189 * @throws SQLException if the connection is closed
1190 */
1191 public ResultSet getCrossReference(String primaryCatalogPattern,
1192 String primarySchemaPattern, String primaryTable, String foreignCatalogPattern,
1193 String foreignSchemaPattern, String foreignTable) throws SQLException {
1194 try {
1195 if (isDebugEnabled()) {
1196 debugCode("getCrossReference("
1197 +quote(primaryCatalogPattern)+", "
1198 +quote(primarySchemaPattern)+", "
1199 +quote(primaryTable)+", "
1200 +quote(foreignCatalogPattern)+", "
1201 +quote(foreignSchemaPattern)+", "
1202 +quote(foreignTable)+");");
1203 }
1204 checkClosed();
1205 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
1206 + "PKTABLE_CATALOG PKTABLE_CAT, "
1207 + "PKTABLE_SCHEMA PKTABLE_SCHEM, "
1208 + "PKTABLE_NAME PKTABLE_NAME, "
1209 + "PKCOLUMN_NAME, "
1210 + "FKTABLE_CATALOG FKTABLE_CAT, "
1211 + "FKTABLE_SCHEMA FKTABLE_SCHEM, "
1212 + "FKTABLE_NAME, "
1213 + "FKCOLUMN_NAME, "
1214 + "ORDINAL_POSITION KEY_SEQ, "
1215 + "UPDATE_RULE, "
1216 + "DELETE_RULE, "
1217 + "FK_NAME, "
1218 + "PK_NAME, "
1219 + "DEFERRABILITY "
1220 + "FROM INFORMATION_SCHEMA.CROSS_REFERENCES "
1221 + "WHERE PKTABLE_CATALOG LIKE ? ESCAPE ? "
1222 + "AND PKTABLE_SCHEMA LIKE ? ESCAPE ? "
1223 + "AND PKTABLE_NAME = ? "
1224 + "AND FKTABLE_CATALOG LIKE ? ESCAPE ? "
1225 + "AND FKTABLE_SCHEMA LIKE ? ESCAPE ? "
1226 + "AND FKTABLE_NAME = ? "
1227 + "ORDER BY FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, FK_NAME, KEY_SEQ");
1228 prep.setString(1, getCatalogPattern(primaryCatalogPattern));
1229 prep.setString(2, "\\");
1230 prep.setString(3, getSchemaPattern(primarySchemaPattern));
1231 prep.setString(4, "\\");
1232 prep.setString(5, primaryTable);
1233 prep.setString(6, getCatalogPattern(foreignCatalogPattern));
1234 prep.setString(7, "\\");
1235 prep.setString(8, getSchemaPattern(foreignSchemaPattern));
1236 prep.setString(9, "\\");
1237 prep.setString(10, foreignTable);
1238 return prep.executeQuery();
1239 } catch (Exception e) {
1240 throw logAndConvert(e);
1241 }
1242 }
1243
1244 /**
1245 * Gets the list of user-defined data types.
1246 * This call returns an empty result set.
1247 *
1248 * <ul>
1249 * <li>1 TYPE_CAT (String) catalog
1250 * </li><li>2 TYPE_SCHEM (String) schema
1251 * </li><li>3 TYPE_NAME (String) type name
1252 * </li><li>4 CLASS_NAME (String) Java class
1253 * </li><li>5 DATA_TYPE (short) SQL Type - see also java.sql.Types
1254 * </li><li>6 REMARKS (String) description
1255 * </li><li>7 BASE_TYPE (short) base type - see also java.sql.Types
1256 * </li></ul>
1257 *
1258 * @param catalog ignored
1259 * @param schemaPattern ignored
1260 * @param typeNamePattern ignored
1261 * @param types ignored
1262 * @return an empty result set
1263 * @throws SQLException if the connection is closed
1264 */
1265 public ResultSet getUDTs(String catalog, String schemaPattern,
1266 String typeNamePattern, int[] types) throws SQLException {
1267 try {
1268 if (isDebugEnabled()) {
1269 debugCode("getUDTs("
1270 +quote(catalog)+", "
1271 +quote(schemaPattern)+", "
1272 +quote(typeNamePattern)+", "
1273 +quoteIntArray(types)+");");
1274 }
1275 checkClosed();
1276 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
1277 + "CAST(NULL AS VARCHAR) TYPE_CAT, "
1278 + "CAST(NULL AS VARCHAR) TYPE_SCHEM, "
1279 + "CAST(NULL AS VARCHAR) TYPE_NAME, "
1280 + "CAST(NULL AS VARCHAR) CLASS_NAME, "
1281 + "CAST(NULL AS SMALLINT) DATA_TYPE, "
1282 + "CAST(NULL AS VARCHAR) REMARKS, "
1283 + "CAST(NULL AS SMALLINT) BASE_TYPE "
1284 + "FROM DUAL WHERE FALSE");
1285 return prep.executeQuery();
1286 } catch (Exception e) {
1287 throw logAndConvert(e);
1288 }
1289 }
1290
1291 /**
1292 * Gets the list of data types. The result set is sorted by DATA_TYPE and
1293 * afterwards by how closely the data type maps to the corresponding JDBC
1294 * SQL type (best match first).
1295 *
1296 * <ul>
1297 * <li>1 TYPE_NAME (String) type name </li>
1298 * <li>2 DATA_TYPE (short) SQL data type - see also java.sql.Types </li>
1299 * <li>3 PRECISION (int) maximum precision </li>
1300 * <li>4 LITERAL_PREFIX (String) prefix used to quote a literal </li>
1301 * <li>5 LITERAL_SUFFIX (String) suffix used to quote a literal </li>
1302 * <li>6 CREATE_PARAMS (String) parameters used (may be null) </li>
1303 * <li>7 NULLABLE (short) typeNoNulls (NULL not allowed) or typeNullable
1304 * </li>
1305 * <li>8 CASE_SENSITIVE (boolean) case sensitive </li>
1306 * <li>9 SEARCHABLE (short) typeSearchable </li>
1307 * <li>10 UNSIGNED_ATTRIBUTE (boolean) unsigned </li>
1308 * <li>11 FIXED_PREC_SCALE (boolean) fixed precision </li>
1309 * <li>12 AUTO_INCREMENT (boolean) auto increment </li>
1310 * <li>13 LOCAL_TYPE_NAME (String) localized version of the data type </li>
1311 * <li>14 MINIMUM_SCALE (short) minimum scale </li>
1312 * <li>15 MAXIMUM_SCALE (short) maximum scale </li>
1313 * <li>16 SQL_DATA_TYPE (int) unused </li>
1314 * <li>17 SQL_DATETIME_SUB (int) unused </li>
1315 * <li>18 NUM_PREC_RADIX (int) 2 for binary, 10 for decimal </li>
1316 * </ul>
1317 *
1318 * @return the list of data types
1319 * @throws SQLException if the connection is closed
1320 */
1321 public ResultSet getTypeInfo() throws SQLException {
1322 try {
1323 debugCodeCall("getTypeInfo");
1324 checkClosed();
1325 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
1326 + "TYPE_NAME, "
1327 + "DATA_TYPE, "
1328 + "PRECISION, "
1329 + "PREFIX LITERAL_PREFIX, "
1330 + "SUFFIX LITERAL_SUFFIX, "
1331 + "PARAMS CREATE_PARAMS, "
1332 + "NULLABLE, "
1333 + "CASE_SENSITIVE, "
1334 + "SEARCHABLE, "
1335 + "FALSE UNSIGNED_ATTRIBUTE, "
1336 + "FALSE FIXED_PREC_SCALE, "
1337 + "AUTO_INCREMENT, "
1338 + "TYPE_NAME LOCAL_TYPE_NAME, "
1339 + "MINIMUM_SCALE, "
1340 + "MAXIMUM_SCALE, "
1341 + "DATA_TYPE SQL_DATA_TYPE, "
1342 + "ZERO() SQL_DATETIME_SUB, "
1343 + "RADIX NUM_PREC_RADIX "
1344 + "FROM INFORMATION_SCHEMA.TYPE_INFO "
1345 + "ORDER BY DATA_TYPE, POS");
1346 ResultSet rs = prep.executeQuery();
1347 return rs;
1348 } catch (Exception e) {
1349 throw logAndConvert(e);
1350 }
1351 }
1352
1353 /**
1354 * Checks if this database store data in local files.
1355 *
1356 * @return true
1357 */
1358 public boolean usesLocalFiles() {
1359 debugCodeCall("usesLocalFiles");
1360 return true;
1361 }
1362
1363 /**
1364 * Checks if this database use one file per table.
1365 *
1366 * @return false
1367 */
1368 public boolean usesLocalFilePerTable() {
1369 debugCodeCall("usesLocalFilePerTable");
1370 return false;
1371 }
1372
1373 /**
1374 * Returns the string used to quote identifiers.
1375 *
1376 * @return a double quote
1377 */
1378 public String getIdentifierQuoteString() {
1379 debugCodeCall("getIdentifierQuoteString");
1380 return "\"";
1381 }
1382
1383 /**
1384 * Gets the comma-separated list of all SQL keywords that are not supported
1385 * as table/column/index name, in addition to the SQL-92 keywords. The list
1386 * returned is:
1387 * <pre>
1388 * LIMIT,MINUS,ROWNUM,SYSDATE,SYSTIME,SYSTIMESTAMP,TODAY
1389 * </pre>
1390 * The complete list of keywords (including SQL-92 keywords) is:
1391 * <pre>
1392 * CROSS, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, DISTINCT,
1393 * EXCEPT, EXISTS, FALSE, FOR, FROM, FULL, GROUP, HAVING, INNER,
1394 * INTERSECT, IS, JOIN, LIKE, LIMIT, MINUS, NATURAL, NOT, NULL, ON,
1395 * ORDER, PRIMARY, ROWNUM, SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP,
1396 * TODAY, TRUE, UNION, UNIQUE, WHERE
1397 * </pre>
1398 *
1399 * @return a list of additional the keywords
1400 */
1401 public String getSQLKeywords() {
1402 debugCodeCall("getSQLKeywords");
1403 return "LIMIT,MINUS,ROWNUM,SYSDATE,SYSTIME,SYSTIMESTAMP,TODAY";
1404 }
1405
1406 /**
1407 * Returns the list of numeric functions supported by this database.
1408 *
1409 * @return the list
1410 */
1411 public String getNumericFunctions() throws SQLException {
1412 debugCodeCall("getNumericFunctions");
1413 return getFunctions("Functions (Numeric)");
1414 }
1415
1416 /**
1417 * Returns the list of string functions supported by this database.
1418 *
1419 * @return the list
1420 */
1421 public String getStringFunctions() throws SQLException {
1422 debugCodeCall("getStringFunctions");
1423 return getFunctions("Functions (String)");
1424 }
1425
1426 /**
1427 * Returns the list of system functions supported by this database.
1428 *
1429 * @return the list
1430 */
1431 public String getSystemFunctions() throws SQLException {
1432 debugCodeCall("getSystemFunctions");
1433 return getFunctions("Functions (System)");
1434 }
1435
1436 /**
1437 * Returns the list of date and time functions supported by this database.
1438 *
1439 * @return the list
1440 */
1441 public String getTimeDateFunctions() throws SQLException {
1442 debugCodeCall("getTimeDateFunctions");
1443 return getFunctions("Functions (Time and Date)");
1444 }
1445
1446 private String getFunctions(String section) throws SQLException {
1447 try {
1448 checkClosed();
1449 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT TOPIC "
1450 + "FROM INFORMATION_SCHEMA.HELP WHERE SECTION = ?");
1451 prep.setString(1, section);
1452 ResultSet rs = prep.executeQuery();
1453 StatementBuilder buff = new StatementBuilder();
1454 while (rs.next()) {
1455 String s = rs.getString(1).trim();
1456 String[] array = StringUtils.arraySplit(s, ',', true);
1457 for (String a : array) {
1458 buff.appendExceptFirst(",");
1459 String f = a.trim();
1460 if (f.indexOf(' ') >= 0) {
1461 // remove 'Function' from 'INSERT Function'
1462 f = f.substring(0, f.indexOf(' ')).trim();
1463 }
1464 buff.append(f);
1465 }
1466 }
1467 rs.close();
1468 prep.close();
1469 return buff.toString();
1470 } catch (Exception e) {
1471 throw logAndConvert(e);
1472 }
1473 }
1474
1475 /**
1476 * Returns the default escape character for DatabaseMetaData search
1477 * patterns.
1478 *
1479 * @return the default escape character (always '\', independent on the
1480 * mode)
1481 */
1482 public String getSearchStringEscape() {
1483 debugCodeCall("getSearchStringEscape");
1484 return "\\";
1485 }
1486
1487 /**
1488 * Returns the characters that are allowed for identifiers in addiction to
1489 * A-Z, a-z, 0-9 and '_'.
1490 *
1491 * @return an empty String ("")
1492 */
1493 public String getExtraNameCharacters() {
1494 debugCodeCall("getExtraNameCharacters");
1495 return "";
1496 }
1497
1498 /**
1499 * Returns whether alter table with add column is supported.
1500 * @return true
1501 */
1502 public boolean supportsAlterTableWithAddColumn() {
1503 debugCodeCall("supportsAlterTableWithAddColumn");
1504 return true;
1505 }
1506
1507 /**
1508 * Returns whether alter table with drop column is supported.
1509 *
1510 * @return true
1511 */
1512 public boolean supportsAlterTableWithDropColumn() {
1513 debugCodeCall("supportsAlterTableWithDropColumn");
1514 return true;
1515 }
1516
1517 /**
1518 * Returns whether column aliasing is supported.
1519 *
1520 * @return true
1521 */
1522 public boolean supportsColumnAliasing() {
1523 debugCodeCall("supportsColumnAliasing");
1524 return true;
1525 }
1526
1527 /**
1528 * Returns whether NULL+1 is NULL or not.
1529 *
1530 * @return true
1531 */
1532 public boolean nullPlusNonNullIsNull() {
1533 debugCodeCall("nullPlusNonNullIsNull");
1534 return true;
1535 }
1536
1537 /**
1538 * Returns whether CONVERT is supported.
1539 *
1540 * @return true
1541 */
1542 public boolean supportsConvert() {
1543 debugCodeCall("supportsConvert");
1544 return true;
1545 }
1546
1547 /**
1548 * Returns whether CONVERT is supported for one datatype to another.
1549 *
1550 * @param fromType the source SQL type
1551 * @param toType the target SQL type
1552 * @return true
1553 */
1554 public boolean supportsConvert(int fromType, int toType) {
1555 if (isDebugEnabled()) {
1556 debugCode("supportsConvert("+fromType+", "+fromType+");");
1557 }
1558 return true;
1559 }
1560
1561 /**
1562 * Returns whether table correlation names (table alias) are supported.
1563 *
1564 * @return true
1565 */
1566 public boolean supportsTableCorrelationNames() {
1567 debugCodeCall("supportsTableCorrelationNames");
1568 return true;
1569 }
1570
1571 /**
1572 * Returns whether table correlation names (table alias) are restricted to
1573 * be different than table names.
1574 *
1575 * @return false
1576 */
1577 public boolean supportsDifferentTableCorrelationNames() {
1578 debugCodeCall("supportsDifferentTableCorrelationNames");
1579 return false;
1580 }
1581
1582 /**
1583 * Returns whether expression in ORDER BY are supported.
1584 *
1585 * @return true
1586 */
1587 public boolean supportsExpressionsInOrderBy() {
1588 debugCodeCall("supportsExpressionsInOrderBy");
1589 return true;
1590 }
1591
1592 /**
1593 * Returns whether ORDER BY is supported if the column is not in the SELECT
1594 * list.
1595 *
1596 * @return true
1597 */
1598 public boolean supportsOrderByUnrelated() {
1599 debugCodeCall("supportsOrderByUnrelated");
1600 return true;
1601 }
1602
1603 /**
1604 * Returns whether GROUP BY is supported.
1605 *
1606 * @return true
1607 */
1608 public boolean supportsGroupBy() {
1609 debugCodeCall("supportsGroupBy");
1610 return true;
1611 }
1612
1613 /**
1614 * Returns whether GROUP BY is supported if the column is not in the SELECT
1615 * list.
1616 *
1617 * @return true
1618 */
1619 public boolean supportsGroupByUnrelated() {
1620 debugCodeCall("supportsGroupByUnrelated");
1621 return true;
1622 }
1623
1624 /**
1625 * Checks whether a GROUP BY clause can use columns that are not in the
1626 * SELECT clause, provided that it specifies all the columns in the SELECT
1627 * clause.
1628 *
1629 * @return true
1630 */
1631 public boolean supportsGroupByBeyondSelect() {
1632 debugCodeCall("supportsGroupByBeyondSelect");
1633 return true;
1634 }
1635
1636 /**
1637 * Returns whether LIKE... ESCAPE is supported.
1638 *
1639 * @return true
1640 */
1641 public boolean supportsLikeEscapeClause() {
1642 debugCodeCall("supportsLikeEscapeClause");
1643 return true;
1644 }
1645
1646 /**
1647 * Returns whether multiple result sets are supported.
1648 *
1649 * @return false
1650 */
1651 public boolean supportsMultipleResultSets() {
1652 debugCodeCall("supportsMultipleResultSets");
1653 return false;
1654 }
1655
1656 /**
1657 * Returns whether multiple transactions (on different connections) are
1658 * supported.
1659 *
1660 * @return true
1661 */
1662 public boolean supportsMultipleTransactions() {
1663 debugCodeCall("supportsMultipleTransactions");
1664 return true;
1665 }
1666
1667 /**
1668 * Returns whether columns with NOT NULL are supported.
1669 *
1670 * @return true
1671 */
1672 public boolean supportsNonNullableColumns() {
1673 debugCodeCall("supportsNonNullableColumns");
1674 return true;
1675 }
1676
1677 /**
1678 * Returns whether ODBC Minimum SQL grammar is supported.
1679 *
1680 * @return true
1681 */
1682 public boolean supportsMinimumSQLGrammar() {
1683 debugCodeCall("supportsMinimumSQLGrammar");
1684 return true;
1685 }
1686
1687 /**
1688 * Returns whether ODBC Core SQL grammar is supported.
1689 *
1690 * @return true
1691 */
1692 public boolean supportsCoreSQLGrammar() {
1693 debugCodeCall("supportsCoreSQLGrammar");
1694 return true;
1695 }
1696
1697 /**
1698 * Returns whether ODBC Extended SQL grammar is supported.
1699 *
1700 * @return false
1701 */
1702 public boolean supportsExtendedSQLGrammar() {
1703 debugCodeCall("supportsExtendedSQLGrammar");
1704 return false;
1705 }
1706
1707 /**
1708 * Returns whether SQL-92 entry level grammar is supported.
1709 *
1710 * @return true
1711 */
1712 public boolean supportsANSI92EntryLevelSQL() {
1713 debugCodeCall("supportsANSI92EntryLevelSQL");
1714 return true;
1715 }
1716
1717 /**
1718 * Returns whether SQL-92 intermediate level grammar is supported.
1719 *
1720 * @return false
1721 */
1722 public boolean supportsANSI92IntermediateSQL() {
1723 debugCodeCall("supportsANSI92IntermediateSQL");
1724 return false;
1725 }
1726
1727 /**
1728 * Returns whether SQL-92 full level grammar is supported.
1729 *
1730 * @return false
1731 */
1732 public boolean supportsANSI92FullSQL() {
1733 debugCodeCall("supportsANSI92FullSQL");
1734 return false;
1735 }
1736
1737 /**
1738 * Returns whether referential integrity is supported.
1739 *
1740 * @return true
1741 */
1742 public boolean supportsIntegrityEnhancementFacility() {
1743 debugCodeCall("supportsIntegrityEnhancementFacility");
1744 return true;
1745 }
1746
1747 /**
1748 * Returns whether outer joins are supported.
1749 *
1750 * @return true
1751 */
1752 public boolean supportsOuterJoins() {
1753 debugCodeCall("supportsOuterJoins");
1754 return true;
1755 }
1756
1757 /**
1758 * Returns whether full outer joins are supported.
1759 *
1760 * @return false
1761 */
1762 public boolean supportsFullOuterJoins() {
1763 debugCodeCall("supportsFullOuterJoins");
1764 return false;
1765 }
1766
1767 /**
1768 * Returns whether limited outer joins are supported.
1769 *
1770 * @return true
1771 */
1772 public boolean supportsLimitedOuterJoins() {
1773 debugCodeCall("supportsLimitedOuterJoins");
1774 return true;
1775 }
1776
1777 /**
1778 * Returns the term for "schema".
1779 *
1780 * @return "schema"
1781 */
1782 public String getSchemaTerm() {
1783 debugCodeCall("getSchemaTerm");
1784 return "schema";
1785 }
1786
1787 /**
1788 * Returns the term for "procedure".
1789 *
1790 * @return "procedure"
1791 */
1792 public String getProcedureTerm() {
1793 debugCodeCall("getProcedureTerm");
1794 return "procedure";
1795 }
1796
1797 /**
1798 * Returns the term for "catalog".
1799 *
1800 * @return "catalog"
1801 */
1802 public String getCatalogTerm() {
1803 debugCodeCall("getCatalogTerm");
1804 return "catalog";
1805 }
1806
1807 /**
1808 * Returns whether the catalog is at the beginning.
1809 *
1810 * @return true
1811 */
1812 public boolean isCatalogAtStart() {
1813 debugCodeCall("isCatalogAtStart");
1814 return true;
1815 }
1816
1817 /**
1818 * Returns the catalog separator.
1819 *
1820 * @return "."
1821 */
1822 public String getCatalogSeparator() {
1823 debugCodeCall("getCatalogSeparator");
1824 return ".";
1825 }
1826
1827 /**
1828 * Returns whether the schema name in INSERT, UPDATE, DELETE is supported.
1829 *
1830 * @return true
1831 */
1832 public boolean supportsSchemasInDataManipulation() {
1833 debugCodeCall("supportsSchemasInDataManipulation");
1834 return true;
1835 }
1836
1837 /**
1838 * Returns whether the schema name in procedure calls is supported.
1839 *
1840 * @return true
1841 */
1842 public boolean supportsSchemasInProcedureCalls() {
1843 debugCodeCall("supportsSchemasInProcedureCalls");
1844 return true;
1845 }
1846
1847 /**
1848 * Returns whether the schema name in CREATE TABLE is supported.
1849 *
1850 * @return true
1851 */
1852 public boolean supportsSchemasInTableDefinitions() {
1853 debugCodeCall("supportsSchemasInTableDefinitions");
1854 return true;
1855 }
1856
1857 /**
1858 * Returns whether the schema name in CREATE INDEX is supported.
1859 *
1860 * @return true
1861 */
1862 public boolean supportsSchemasInIndexDefinitions() {
1863 debugCodeCall("supportsSchemasInIndexDefinitions");
1864 return true;
1865 }
1866
1867 /**
1868 * Returns whether the schema name in GRANT is supported.
1869 *
1870 * @return true
1871 */
1872 public boolean supportsSchemasInPrivilegeDefinitions() {
1873 debugCodeCall("supportsSchemasInPrivilegeDefinitions");
1874 return true;
1875 }
1876
1877 /**
1878 * Returns whether the catalog name in INSERT, UPDATE, DELETE is supported.
1879 *
1880 * @return true
1881 */
1882 public boolean supportsCatalogsInDataManipulation() {
1883 debugCodeCall("supportsCatalogsInDataManipulation");
1884 return true;
1885 }
1886
1887 /**
1888 * Returns whether the catalog name in procedure calls is supported.
1889 *
1890 * @return false
1891 */
1892 public boolean supportsCatalogsInProcedureCalls() {
1893 debugCodeCall("supportsCatalogsInProcedureCalls");
1894 return false;
1895 }
1896
1897 /**
1898 * Returns whether the catalog name in CREATE TABLE is supported.
1899 *
1900 * @return true
1901 */
1902 public boolean supportsCatalogsInTableDefinitions() {
1903 debugCodeCall("supportsCatalogsInTableDefinitions");
1904 return true;
1905 }
1906
1907 /**
1908 * Returns whether the catalog name in CREATE INDEX is supported.
1909 *
1910 * @return true
1911 */
1912 public boolean supportsCatalogsInIndexDefinitions() {
1913 debugCodeCall("supportsCatalogsInIndexDefinitions");
1914 return true;
1915 }
1916
1917 /**
1918 * Returns whether the catalog name in GRANT is supported.
1919 *
1920 * @return true
1921 */
1922 public boolean supportsCatalogsInPrivilegeDefinitions() {
1923 debugCodeCall("supportsCatalogsInPrivilegeDefinitions");
1924 return true;
1925 }
1926
1927 /**
1928 * Returns whether positioned deletes are supported.
1929 *
1930 * @return true
1931 */
1932 public boolean supportsPositionedDelete() {
1933 debugCodeCall("supportsPositionedDelete");
1934 return true;
1935 }
1936
1937 /**
1938 * Returns whether positioned updates are supported.
1939 *
1940 * @return true
1941 */
1942 public boolean supportsPositionedUpdate() {
1943 debugCodeCall("supportsPositionedUpdate");
1944 return true;
1945 }
1946
1947 /**
1948 * Returns whether SELECT ... FOR UPDATE is supported.
1949 *
1950 * @return true
1951 */
1952 public boolean supportsSelectForUpdate() {
1953 debugCodeCall("supportsSelectForUpdate");
1954 return true;
1955 }
1956
1957 /**
1958 * Returns whether stored procedures are supported.
1959 *
1960 * @return false
1961 */
1962 public boolean supportsStoredProcedures() {
1963 debugCodeCall("supportsStoredProcedures");
1964 return false;
1965 }
1966
1967 /**
1968 * Returns whether subqueries (SELECT) in comparisons are supported.
1969 *
1970 * @return true
1971 */
1972 public boolean supportsSubqueriesInComparisons() {
1973 debugCodeCall("supportsSubqueriesInComparisons");
1974 return true;
1975 }
1976
1977 /**
1978 * Returns whether SELECT in EXISTS is supported.
1979 *
1980 * @return true
1981 */
1982 public boolean supportsSubqueriesInExists() {
1983 debugCodeCall("supportsSubqueriesInExists");
1984 return true;
1985 }
1986
1987 /**
1988 * Returns whether IN(SELECT...) is supported.
1989 *
1990 * @return true
1991 */
1992 public boolean supportsSubqueriesInIns() {
1993 debugCodeCall("supportsSubqueriesInIns");
1994 return true;
1995 }
1996
1997 /**
1998 * Returns whether subqueries in quantified expression are supported.
1999 *
2000 * @return true
2001 */
2002 public boolean supportsSubqueriesInQuantifieds() {
2003 debugCodeCall("supportsSubqueriesInQuantifieds");
2004 return true;
2005 }
2006
2007 /**
2008 * Returns whether correlated subqueries are supported.
2009 *
2010 * @return true
2011 */
2012 public boolean supportsCorrelatedSubqueries() {
2013 debugCodeCall("supportsCorrelatedSubqueries");
2014 return true;
2015 }
2016
2017 /**
2018 * Returns whether UNION SELECT is supported.
2019 *
2020 * @return true
2021 */
2022 public boolean supportsUnion() {
2023 debugCodeCall("supportsUnion");
2024 return true;
2025 }
2026
2027 /**
2028 * Returns whether UNION ALL SELECT is supported.
2029 *
2030 * @return true
2031 */
2032 public boolean supportsUnionAll() {
2033 debugCodeCall("supportsUnionAll");
2034 return true;
2035 }
2036
2037 /**
2038 * Returns whether open result sets across commits are supported.
2039 *
2040 * @return false
2041 */
2042 public boolean supportsOpenCursorsAcrossCommit() {
2043 debugCodeCall("supportsOpenCursorsAcrossCommit");
2044 return false;
2045 }
2046
2047 /**
2048 * Returns whether open result sets across rollback are supported.
2049 *
2050 * @return false
2051 */
2052 public boolean supportsOpenCursorsAcrossRollback() {
2053 debugCodeCall("supportsOpenCursorsAcrossRollback");
2054 return false;
2055 }
2056
2057 /**
2058 * Returns whether open statements across commit are supported.
2059 *
2060 * @return true
2061 */
2062 public boolean supportsOpenStatementsAcrossCommit() {
2063 debugCodeCall("supportsOpenStatementsAcrossCommit");
2064 return true;
2065 }
2066
2067 /**
2068 * Returns whether open statements across rollback are supported.
2069 *
2070 * @return true
2071 */
2072 public boolean supportsOpenStatementsAcrossRollback() {
2073 debugCodeCall("supportsOpenStatementsAcrossRollback");
2074 return true;
2075 }
2076
2077 /**
2078 * Returns whether transactions are supported.
2079 *
2080 * @return true
2081 */
2082 public boolean supportsTransactions() {
2083 debugCodeCall("supportsTransactions");
2084 return true;
2085 }
2086
2087 /**
2088 * Returns whether a specific transaction isolation level is supported.
2089 *
2090 * @param level the transaction isolation level (Connection.TRANSACTION_*)
2091 * @return true
2092 */
2093 public boolean supportsTransactionIsolationLevel(int level) {
2094 debugCodeCall("supportsTransactionIsolationLevel");
2095 return true;
2096 }
2097
2098 /**
2099 * Returns whether data manipulation and CREATE/DROP is supported in
2100 * transactions.
2101 *
2102 * @return false
2103 */
2104 public boolean supportsDataDefinitionAndDataManipulationTransactions() {
2105 debugCodeCall("supportsDataDefinitionAndDataManipulationTransactions");
2106 return false;
2107 }
2108
2109 /**
2110 * Returns whether only data manipulations are supported in transactions.
2111 *
2112 * @return true
2113 */
2114 public boolean supportsDataManipulationTransactionsOnly() {
2115 debugCodeCall("supportsDataManipulationTransactionsOnly");
2116 return true;
2117 }
2118
2119 /**
2120 * Returns whether CREATE/DROP commit an open transaction.
2121 *
2122 * @return true
2123 */
2124 public boolean dataDefinitionCausesTransactionCommit() {
2125 debugCodeCall("dataDefinitionCausesTransactionCommit");
2126 return true;
2127 }
2128
2129 /**
2130 * Returns whether CREATE/DROP do not affect transactions.
2131 *
2132 * @return false
2133 */
2134 public boolean dataDefinitionIgnoredInTransactions() {
2135 debugCodeCall("dataDefinitionIgnoredInTransactions");
2136 return false;
2137 }
2138
2139 /**
2140 * Returns whether a specific result set type is supported.
2141 * ResultSet.TYPE_SCROLL_SENSITIVE is not supported.
2142 *
2143 * @param type the result set type
2144 * @return true for all types except ResultSet.TYPE_FORWARD_ONLY
2145 */
2146 public boolean supportsResultSetType(int type) {
2147 debugCodeCall("supportsResultSetType", type);
2148 return type != ResultSet.TYPE_SCROLL_SENSITIVE;
2149 }
2150
2151 /**
2152 * Returns whether a specific result set concurrency is supported.
2153 * ResultSet.TYPE_SCROLL_SENSITIVE is not supported.
2154 *
2155 * @param type the result set type
2156 * @param concurrency the result set concurrency
2157 * @return true if the type is not ResultSet.TYPE_SCROLL_SENSITIVE
2158 */
2159 public boolean supportsResultSetConcurrency(int type, int concurrency) {
2160 if (isDebugEnabled()) {
2161 debugCode("supportsResultSetConcurrency("+type+", "+concurrency+");");
2162 }
2163 return type != ResultSet.TYPE_SCROLL_SENSITIVE;
2164 }
2165
2166 /**
2167 * Returns whether own updates are visible.
2168 *
2169 * @param type the result set type
2170 * @return true
2171 */
2172 public boolean ownUpdatesAreVisible(int type) {
2173 debugCodeCall("ownUpdatesAreVisible", type);
2174 return true;
2175 }
2176
2177 /**
2178 * Returns whether own deletes are visible.
2179 *
2180 * @param type the result set type
2181 * @return false
2182 */
2183 public boolean ownDeletesAreVisible(int type) {
2184 debugCodeCall("ownDeletesAreVisible", type);
2185 return false;
2186 }
2187
2188 /**
2189 * Returns whether own inserts are visible.
2190 *
2191 * @param type the result set type
2192 * @return false
2193 */
2194 public boolean ownInsertsAreVisible(int type) {
2195 debugCodeCall("ownInsertsAreVisible", type);
2196 return false;
2197 }
2198
2199 /**
2200 * Returns whether other updates are visible.
2201 *
2202 * @param type the result set type
2203 * @return false
2204 */
2205 public boolean othersUpdatesAreVisible(int type) {
2206 debugCodeCall("othersUpdatesAreVisible", type);
2207 return false;
2208 }
2209
2210 /**
2211 * Returns whether other deletes are visible.
2212 *
2213 * @param type the result set type
2214 * @return false
2215 */
2216 public boolean othersDeletesAreVisible(int type) {
2217 debugCodeCall("othersDeletesAreVisible", type);
2218 return false;
2219 }
2220
2221 /**
2222 * Returns whether other inserts are visible.
2223 *
2224 * @param type the result set type
2225 * @return false
2226 */
2227 public boolean othersInsertsAreVisible(int type) {
2228 debugCodeCall("othersInsertsAreVisible", type);
2229 return false;
2230 }
2231
2232 /**
2233 * Returns whether updates are detected.
2234 *
2235 * @param type the result set type
2236 * @return false
2237 */
2238 public boolean updatesAreDetected(int type) {
2239 debugCodeCall("updatesAreDetected", type);
2240 return false;
2241 }
2242
2243 /**
2244 * Returns whether deletes are detected.
2245 *
2246 * @param type the result set type
2247 * @return false
2248 */
2249 public boolean deletesAreDetected(int type) {
2250 debugCodeCall("deletesAreDetected", type);
2251 return false;
2252 }
2253
2254 /**
2255 * Returns whether inserts are detected.
2256 *
2257 * @param type the result set type
2258 * @return false
2259 */
2260 public boolean insertsAreDetected(int type) {
2261 debugCodeCall("insertsAreDetected", type);
2262 return false;
2263 }
2264
2265 /**
2266 * Returns whether batch updates are supported.
2267 *
2268 * @return true
2269 */
2270 public boolean supportsBatchUpdates() {
2271 debugCodeCall("supportsBatchUpdates");
2272 return true;
2273 }
2274
2275 /**
2276 * Returns whether the maximum row size includes blobs.
2277 *
2278 * @return false
2279 */
2280 public boolean doesMaxRowSizeIncludeBlobs() {
2281 debugCodeCall("doesMaxRowSizeIncludeBlobs");
2282 return false;
2283 }
2284
2285 /**
2286 * Returns the default transaction isolation level.
2287 *
2288 * @return Connection.TRANSACTION_READ_COMMITTED
2289 */
2290 public int getDefaultTransactionIsolation() {
2291 debugCodeCall("getDefaultTransactionIsolation");
2292 return Connection.TRANSACTION_READ_COMMITTED;
2293 }
2294
2295 /**
2296 * Checks if for CREATE TABLE Test(ID INT), getTables returns Test as the
2297 * table name.
2298 *
2299 * @return false
2300 */
2301 public boolean supportsMixedCaseIdentifiers() {
2302 debugCodeCall("supportsMixedCaseIdentifiers");
2303 return false;
2304 }
2305
2306 /**
2307 * Checks if a table created with CREATE TABLE "Test"(ID INT) is a different
2308 * table than a table created with CREATE TABLE TEST(ID INT).
2309 *
2310 * @return true
2311 */
2312 public boolean supportsMixedCaseQuotedIdentifiers() {
2313 debugCodeCall("supportsMixedCaseQuotedIdentifiers");
2314 return true;
2315 }
2316
2317 /**
2318 * Checks if for CREATE TABLE Test(ID INT), getTables returns TEST as the
2319 * table name.
2320 *
2321 * @return true
2322 */
2323 public boolean storesUpperCaseIdentifiers() {
2324 debugCodeCall("storesUpperCaseIdentifiers");
2325 return true;
2326 }
2327
2328 /**
2329 * Checks if for CREATE TABLE Test(ID INT), getTables returns test as the
2330 * table name.
2331 *
2332 * @return false
2333 */
2334 public boolean storesLowerCaseIdentifiers() {
2335 debugCodeCall("storesLowerCaseIdentifiers");
2336 return false;
2337 }
2338
2339 /**
2340 * Checks if for CREATE TABLE Test(ID INT), getTables returns Test as the
2341 * table name.
2342 *
2343 * @return false
2344 */
2345 public boolean storesMixedCaseIdentifiers() {
2346 debugCodeCall("storesMixedCaseIdentifiers");
2347 return false;
2348 }
2349
2350 /**
2351 * Checks if for CREATE TABLE "Test"(ID INT), getTables returns TEST as the
2352 * table name.
2353 *
2354 * @return false
2355 */
2356 public boolean storesUpperCaseQuotedIdentifiers() {
2357 debugCodeCall("storesUpperCaseQuotedIdentifiers");
2358 return false;
2359 }
2360
2361 /**
2362 * Checks if for CREATE TABLE "Test"(ID INT), getTables returns test as the
2363 * table name.
2364 *
2365 * @return false
2366 */
2367 public boolean storesLowerCaseQuotedIdentifiers() {
2368 debugCodeCall("storesLowerCaseQuotedIdentifiers");
2369 return false;
2370 }
2371
2372 /**
2373 * Checks if for CREATE TABLE "Test"(ID INT), getTables returns Test as the
2374 * table name.
2375 *
2376 * @return true
2377 */
2378 public boolean storesMixedCaseQuotedIdentifiers() {
2379 debugCodeCall("storesMixedCaseQuotedIdentifiers");
2380 return true;
2381 }
2382
2383 /**
2384 * Returns the maximum length for hex values (characters).
2385 *
2386 * @return 0 for limit is unknown
2387 */
2388 public int getMaxBinaryLiteralLength() {
2389 debugCodeCall("getMaxBinaryLiteralLength");
2390 return 0;
2391 }
2392
2393 /**
2394 * Returns the maximum length for literals.
2395 *
2396 * @return 0 for limit is unknown
2397 */
2398 public int getMaxCharLiteralLength() {
2399 debugCodeCall("getMaxCharLiteralLength");
2400 return 0;
2401 }
2402
2403 /**
2404 * Returns the maximum length for column names.
2405 *
2406 * @return 0 for limit is unknown
2407 */
2408 public int getMaxColumnNameLength() {
2409 debugCodeCall("getMaxColumnNameLength");
2410 return 0;
2411 }
2412
2413 /**
2414 * Returns the maximum number of columns in GROUP BY.
2415 *
2416 * @return 0 for limit is unknown
2417 */
2418 public int getMaxColumnsInGroupBy() {
2419 debugCodeCall("getMaxColumnsInGroupBy");
2420 return 0;
2421 }
2422
2423 /**
2424 * Returns the maximum number of columns in CREATE INDEX.
2425 *
2426 * @return 0 for limit is unknown
2427 */
2428 public int getMaxColumnsInIndex() {
2429 debugCodeCall("getMaxColumnsInIndex");
2430 return 0;
2431 }
2432
2433 /**
2434 * Returns the maximum number of columns in ORDER BY.
2435 *
2436 * @return 0 for limit is unknown
2437 */
2438 public int getMaxColumnsInOrderBy() {
2439 debugCodeCall("getMaxColumnsInOrderBy");
2440 return 0;
2441 }
2442
2443 /**
2444 * Returns the maximum number of columns in SELECT.
2445 *
2446 * @return 0 for limit is unknown
2447 */
2448 public int getMaxColumnsInSelect() {
2449 debugCodeCall("getMaxColumnsInSelect");
2450 return 0;
2451 }
2452
2453 /**
2454 * Returns the maximum number of columns in CREATE TABLE.
2455 *
2456 * @return 0 for limit is unknown
2457 */
2458 public int getMaxColumnsInTable() {
2459 debugCodeCall("getMaxColumnsInTable");
2460 return 0;
2461 }
2462
2463 /**
2464 * Returns the maximum number of open connection.
2465 *
2466 * @return 0 for limit is unknown
2467 */
2468 public int getMaxConnections() {
2469 debugCodeCall("getMaxConnections");
2470 return 0;
2471 }
2472
2473 /**
2474 * Returns the maximum length for a cursor name.
2475 *
2476 * @return 0 for limit is unknown
2477 */
2478 public int getMaxCursorNameLength() {
2479 debugCodeCall("getMaxCursorNameLength");
2480 return 0;
2481 }
2482
2483 /**
2484 * Returns the maximum length for an index (in bytes).
2485 *
2486 * @return 0 for limit is unknown
2487 */
2488 public int getMaxIndexLength() {
2489 debugCodeCall("getMaxIndexLength");
2490 return 0;
2491 }
2492
2493 /**
2494 * Returns the maximum length for a schema name.
2495 *
2496 * @return 0 for limit is unknown
2497 */
2498 public int getMaxSchemaNameLength() {
2499 debugCodeCall("getMaxSchemaNameLength");
2500 return 0;
2501 }
2502
2503 /**
2504 * Returns the maximum length for a procedure name.
2505 *
2506 * @return 0 for limit is unknown
2507 */
2508 public int getMaxProcedureNameLength() {
2509 debugCodeCall("getMaxProcedureNameLength");
2510 return 0;
2511 }
2512
2513 /**
2514 * Returns the maximum length for a catalog name.
2515 *
2516 * @return 0 for limit is unknown
2517 */
2518 public int getMaxCatalogNameLength() {
2519 debugCodeCall("getMaxCatalogNameLength");
2520 return 0;
2521 }
2522
2523 /**
2524 * Returns the maximum size of a row (in bytes).
2525 *
2526 * @return 0 for limit is unknown
2527 */
2528 public int getMaxRowSize() {
2529 debugCodeCall("getMaxRowSize");
2530 return 0;
2531 }
2532
2533 /**
2534 * Returns the maximum length of a statement.
2535 *
2536 * @return 0 for limit is unknown
2537 */
2538 public int getMaxStatementLength() {
2539 debugCodeCall("getMaxStatementLength");
2540 return 0;
2541 }
2542
2543 /**
2544 * Returns the maximum number of open statements.
2545 *
2546 * @return 0 for limit is unknown
2547 */
2548 public int getMaxStatements() {
2549 debugCodeCall("getMaxStatements");
2550 return 0;
2551 }
2552
2553 /**
2554 * Returns the maximum length for a table name.
2555 *
2556 * @return 0 for limit is unknown
2557 */
2558 public int getMaxTableNameLength() {
2559 debugCodeCall("getMaxTableNameLength");
2560 return 0;
2561 }
2562
2563 /**
2564 * Returns the maximum number of tables in a SELECT.
2565 *
2566 * @return 0 for limit is unknown
2567 */
2568 public int getMaxTablesInSelect() {
2569 debugCodeCall("getMaxTablesInSelect");
2570 return 0;
2571 }
2572
2573 /**
2574 * Returns the maximum length for a user name.
2575 *
2576 * @return 0 for limit is unknown
2577 */
2578 public int getMaxUserNameLength() {
2579 debugCodeCall("getMaxUserNameLength");
2580 return 0;
2581 }
2582
2583 /**
2584 * Does the database support savepoints.
2585 *
2586 * @return true
2587 */
2588 public boolean supportsSavepoints() {
2589 debugCodeCall("supportsSavepoints");
2590 return true;
2591 }
2592
2593 /**
2594 * Does the database support named parameters.
2595 *
2596 * @return false
2597 */
2598 public boolean supportsNamedParameters() {
2599 debugCodeCall("supportsNamedParameters");
2600 return false;
2601 }
2602
2603 /**
2604 * Does the database support multiple open result sets.
2605 *
2606 * @return true
2607 */
2608 public boolean supportsMultipleOpenResults() {
2609 debugCodeCall("supportsMultipleOpenResults");
2610 return true;
2611 }
2612
2613 /**
2614 * Does the database support getGeneratedKeys.
2615 *
2616 * @return true
2617 */
2618 public boolean supportsGetGeneratedKeys() {
2619 debugCodeCall("supportsGetGeneratedKeys");
2620 return true;
2621 }
2622
2623 /**
2624 * [Not supported]
2625 */
2626 public ResultSet getSuperTypes(String catalog, String schemaPattern,
2627 String typeNamePattern) throws SQLException {
2628 throw unsupported("superTypes");
2629 }
2630
2631 /**
2632 * Get the list of super tables of a table. This method currently returns an
2633 * empty result set.
2634 * <ul>
2635 * <li>1 TABLE_CAT (String) table catalog</li>
2636 * <li>2 TABLE_SCHEM (String) table schema</li>
2637 * <li>3 TABLE_NAME (String) table name</li>
2638 * <li>4 SUPERTABLE_NAME (String) the name of the super table</li>
2639 * </ul>
2640 *
2641 * @param catalog null (to get all objects) or the catalog name
2642 * @param schemaPattern null (to get all objects) or a schema name (uppercase for
2643 * unquoted names)
2644 * @param tableNamePattern null (to get all objects) or a table name pattern
2645 * (uppercase for unquoted names)
2646 * @return an empty result set
2647 */
2648 public ResultSet getSuperTables(String catalog, String schemaPattern,
2649 String tableNamePattern) throws SQLException {
2650 try {
2651 if (isDebugEnabled()) {
2652 debugCode("getSuperTables("
2653 +quote(catalog)+", "
2654 +quote(schemaPattern)+", "
2655 +quote(tableNamePattern)+");");
2656 }
2657 checkClosed();
2658 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
2659 + "CATALOG_NAME TABLE_CAT, "
2660 + "CATALOG_NAME TABLE_SCHEM, "
2661 + "CATALOG_NAME TABLE_NAME, "
2662 + "CATALOG_NAME SUPERTABLE_NAME "
2663 + "FROM INFORMATION_SCHEMA.CATALOGS "
2664 + "WHERE FALSE");
2665 return prep.executeQuery();
2666 } catch (Exception e) {
2667 throw logAndConvert(e);
2668 }
2669 }
2670
2671 /**
2672 * [Not supported]
2673 */
2674 public ResultSet getAttributes(String catalog, String schemaPattern,
2675 String typeNamePattern, String attributeNamePattern)
2676 throws SQLException {
2677 throw unsupported("attributes");
2678 }
2679
2680 /**
2681 * Does this database supports a result set holdability.
2682 *
2683 * @param holdability ResultSet.HOLD_CURSORS_OVER_COMMIT or
2684 * CLOSE_CURSORS_AT_COMMIT
2685 * @return true if the holdability is ResultSet.CLOSE_CURSORS_AT_COMMIT
2686 */
2687 public boolean supportsResultSetHoldability(int holdability) {
2688 debugCodeCall("supportsResultSetHoldability", holdability);
2689 return holdability == ResultSet.CLOSE_CURSORS_AT_COMMIT;
2690 }
2691
2692 /**
2693 * Gets the result set holdability.
2694 *
2695 * @return ResultSet.CLOSE_CURSORS_AT_COMMIT
2696 */
2697 public int getResultSetHoldability() {
2698 debugCodeCall("getResultSetHoldability");
2699 return ResultSet.CLOSE_CURSORS_AT_COMMIT;
2700 }
2701
2702 /**
2703 * Gets the major version of the database.
2704 *
2705 * @return the major version
2706 */
2707 public int getDatabaseMajorVersion() {
2708 debugCodeCall("getDatabaseMajorVersion");
2709 return Constants.VERSION_MAJOR;
2710 }
2711
2712 /**
2713 * Gets the minor version of the database.
2714 *
2715 * @return the minor version
2716 */
2717 public int getDatabaseMinorVersion() {
2718 debugCodeCall("getDatabaseMinorVersion");
2719 return Constants.VERSION_MINOR;
2720 }
2721
2722 /**
2723 * Gets the major version of the supported JDBC API.
2724 * This method returns 4 when the driver is compiled using Java 5 or 6.
2725 * It returns 3 otherwise.
2726 *
2727 * @return the major version (4 or 3)
2728 */
2729 public int getJDBCMajorVersion() {
2730 debugCodeCall("getJDBCMajorVersion");
2731 int majorVersion = 3;
2732 //## Java 1.6 ##
2733 majorVersion = 4;
2734 //*/
2735 return majorVersion;
2736 }
2737
2738 /**
2739 * Gets the minor version of the supported JDBC API.
2740 *
2741 * @return the minor version (0)
2742 */
2743 public int getJDBCMinorVersion() {
2744 debugCodeCall("getJDBCMinorVersion");
2745 return 0;
2746 }
2747
2748 /**
2749 * Gets the SQL State type.
2750 *
2751 * @return DatabaseMetaData.sqlStateSQL99
2752 */
2753 public int getSQLStateType() {
2754 debugCodeCall("getSQLStateType");
2755 return DatabaseMetaData.sqlStateSQL99;
2756 }
2757
2758 /**
2759 * Does the database make a copy before updating.
2760 *
2761 * @return false
2762 */
2763 public boolean locatorsUpdateCopy() {
2764 debugCodeCall("locatorsUpdateCopy");
2765 return false;
2766 }
2767
2768 /**
2769 * Does the database support statement pooling.
2770 *
2771 * @return false
2772 */
2773 public boolean supportsStatementPooling() {
2774 debugCodeCall("supportsStatementPooling");
2775 return false;
2776 }
2777
2778 // =============================================================
2779
2780 private void checkClosed() {
2781 conn.checkClosed();
2782 }
2783
2784 private static String getPattern(String pattern) {
2785 return pattern == null ? "%" : pattern;
2786 }
2787
2788 private static String getSchemaPattern(String pattern) {
2789 return pattern == null ? "%" : pattern.length() == 0 ? Constants.SCHEMA_MAIN : pattern;
2790 }
2791
2792 private static String getCatalogPattern(String catalogPattern) {
2793 // Workaround for OpenOffice: getColumns is called with "" as the catalog
2794 return catalogPattern == null || catalogPattern.length() == 0 ? "%" : catalogPattern;
2795 }
2796
2797 /**
2798 * Get the lifetime of a rowid.
2799 *
2800 * @return ROWID_UNSUPPORTED
2801 */
2802 //## Java 1.6 ##
2803 public RowIdLifetime getRowIdLifetime() {
2804 debugCodeCall("getRowIdLifetime");
2805 return RowIdLifetime.ROWID_UNSUPPORTED;
2806 }
2807 //*/
2808
2809 /**
2810 * [Not supported] Gets the list of schemas.
2811 */
2812 //## Java 1.6 ##
2813 public ResultSet getSchemas(String catalog, String schemaPattern)
2814 throws SQLException {
2815 throw unsupported("getSchemas(., .)");
2816 }
2817 //*/
2818
2819 /**
2820 * Returns whether the database supports calling functions using the call syntax.
2821 *
2822 * @return true
2823 */
2824 public boolean supportsStoredFunctionsUsingCallSyntax() {
2825 debugCodeCall("supportsStoredFunctionsUsingCallSyntax");
2826 return true;
2827 }
2828
2829 /**
2830 * Returns whether an exception while auto commit is on closes all result sets.
2831 *
2832 * @return false
2833 */
2834 public boolean autoCommitFailureClosesAllResultSets() {
2835 debugCodeCall("autoCommitFailureClosesAllResultSets");
2836 return false;
2837 }
2838
2839 /**
2840 * [Not supported] Returns the client info properties.
2841 */
2842 public ResultSet getClientInfoProperties() throws SQLException {
2843 throw unsupported("clientInfoProperties");
2844 }
2845
2846 /**
2847 * [Not supported] Return an object of this class if possible.
2848 */
2849 //## Java 1.6 ##
2850 public <T> T unwrap(Class<T> iface) throws SQLException {
2851 throw unsupported("unwrap");
2852 }
2853 //*/
2854
2855 /**
2856 * [Not supported] Checks if unwrap can return an object of this class.
2857 */
2858 //## Java 1.6 ##
2859 public boolean isWrapperFor(Class<?> iface) throws SQLException {
2860 throw unsupported("isWrapperFor");
2861 }
2862 //*/
2863
2864 /**
2865 * [Not supported] Gets the list of function columns.
2866 */
2867 //## Java 1.6 ##
2868 public ResultSet getFunctionColumns(String catalog, String schemaPattern,
2869 String functionNamePattern, String columnNamePattern)
2870 throws SQLException {
2871 throw unsupported("getFunctionColumns");
2872 }
2873 //*/
2874
2875 /**
2876 * [Not supported] Gets the list of functions.
2877 */
2878 //## Java 1.6 ##
2879 public ResultSet getFunctions(String catalog, String schemaPattern,
2880 String functionNamePattern) throws SQLException {
2881 throw unsupported("getFunctions");
2882 }
2883 //*/
2884
2885 /**
2886 * [Not supported]
2887 */
2888 /*## Java 1.7 ##
2889 public boolean generatedKeyAlwaysReturned() {
2890 return true;
2891 }
2892 //*/
2893
2894 /**
2895 * [Not supported]
2896 *
2897 * @param catalog null (to get all objects) or the catalog name
2898 * @param schemaPattern null (to get all objects) or a schema name
2899 * (uppercase for unquoted names)
2900 * @param tableNamePattern null (to get all objects) or a table name
2901 * (uppercase for unquoted names)
2902 * @param columnNamePattern null (to get all objects) or a column name
2903 * (uppercase for unquoted names)
2904 */
2905 /*## Java 1.7 ##
2906 public ResultSet getPseudoColumns(String catalog, String schemaPattern,
2907 String tableNamePattern, String columnNamePattern) {
2908 return null;
2909 }
2910 //*/
2911
2912 /**
2913 * INTERNAL
2914 */
2915 public String toString() {
2916 return getTraceObjectName() + ": " + conn;
2917 }
2918
2919 }
2920