1 5 package org.h2.jdbc; 6 7 import java.sql.*; 8 9 import org.h2.engine.Constants; 10 import org.h2.message.Message; 11 import org.h2.message.Trace; 12 import org.h2.message.TraceObject; 13 import org.h2.util.StringUtils; 14 15 18 public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaData { 19 20 private JdbcConnection conn; 21 22 27 public int getDriverMajorVersion() { 28 debugCodeCall("getDriverMajorVersion"); 29 return Constants.VERSION_MAJOR; 30 } 31 32 37 public int getDriverMinorVersion() { 38 debugCodeCall("getDriverMinorVersion"); 39 return Constants.VERSION_MINOR; 40 } 41 42 47 public String getDatabaseProductName() { 48 debugCodeCall("getDatabaseProductName"); 49 return Constants.PRODUCT_NAME; 50 } 51 52 57 public String getDatabaseProductVersion() { 58 debugCodeCall("getDatabaseProductVersion"); 59 return Constants.getVersion(); 60 } 61 62 67 public String getDriverName() { 68 debugCodeCall("getDriverName"); 69 return Constants.DRIVER_NAME; 70 } 71 72 78 public String getDriverVersion() { 79 debugCodeCall("getDriverVersion"); 80 return Constants.getVersion(); 81 } 82 83 104 public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String [] types) throws SQLException { 105 try { 106 if(debug()) { 107 debugCode("getTables(" 108 +quote(catalog)+", " 109 +quote(schemaPattern)+", " 110 +quote(tableNamePattern)+", " 111 +quoteArray(types)+");"); 112 } 113 checkClosed(); 114 String tableType; 115 if (types != null && types.length>0) { 116 StringBuffer buff = new StringBuffer ("TABLE_TYPE IN("); 117 for (int i = 0; i < types.length; i++) { 118 if (i>0) { 119 buff.append(", "); 120 } 121 buff.append("?"); 122 } 123 buff.append(")"); 124 tableType = buff.toString(); 125 } else { 126 tableType = "TRUE"; 127 } 128 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 129 + "TABLE_CATALOG TABLE_CAT, " 130 + "TABLE_SCHEMA TABLE_SCHEM, " 131 + "TABLE_NAME, " 132 + "TABLE_TYPE, " 133 + "REMARKS, " 134 + "SQL " 135 + "FROM INFORMATION_SCHEMA.TABLES " 136 + "WHERE TABLE_CATALOG LIKE ? " 137 + "AND TABLE_SCHEMA LIKE ? " 138 + "AND TABLE_NAME LIKE ? " 139 + "AND (" + tableType + ") " 140 + "ORDER BY TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME"); 141 prep.setString(1, getCatalogPattern(catalog)); 142 prep.setString(2, getSchemaPattern(schemaPattern)); 143 prep.setString(3, getPattern(tableNamePattern)); 144 for (int i = 0; types != null && i < types.length; i++) { 145 prep.setString(4 + i, types[i]); 146 } 147 return prep.executeQuery(); 148 } catch(Throwable e) { 149 throw logAndConvert(e); 150 } 151 } 152 153 185 public ResultSet getColumns(String catalog, String schemaPattern, 186 String tableNamePattern, String columnNamePattern) 187 throws SQLException { 188 try { 189 if(debug()) { 190 debugCode("getColumns(" 191 +quote(catalog)+", " 192 +quote(schemaPattern)+", " 193 +quote(tableNamePattern)+", " 194 +quote(columnNamePattern)+");"); 195 } 196 checkClosed(); 197 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 198 + "TABLE_CATALOG TABLE_CAT, " 199 + "TABLE_SCHEMA TABLE_SCHEM, " 200 + "TABLE_NAME, " 201 + "COLUMN_NAME, " 202 + "DATA_TYPE, " 203 + "TYPE_NAME, " 204 + "CHARACTER_MAXIMUM_LENGTH COLUMN_SIZE, " 205 + "CHARACTER_MAXIMUM_LENGTH BUFFER_LENGTH, " 206 + "NUMERIC_SCALE DECIMAL_DIGITS, " 207 + "NUMERIC_PRECISION_RADIX NUM_PREC_RADIX, " 208 + "NULLABLE, " 209 + "REMARKS, " 210 + "COLUMN_DEFAULT COLUMN_DEF, " 211 + "DATA_TYPE SQL_DATA_TYPE, " 212 + "ZERO() SQL_DATETIME_SUB, " 213 + "CHARACTER_OCTET_LENGTH CHAR_OCTET_LENGTH, " 214 + "ORDINAL_POSITION, " 215 + "IS_NULLABLE IS_NULLABLE " 216 + "FROM INFORMATION_SCHEMA.COLUMNS " 217 + "WHERE TABLE_CATALOG LIKE ? " 218 + "AND TABLE_SCHEMA LIKE ? " 219 + "AND TABLE_NAME LIKE ? " 220 + "AND COLUMN_NAME LIKE ? " 221 + "ORDER BY TABLE_SCHEM, TABLE_NAME, ORDINAL_POSITION"); 222 prep.setString(1, getCatalogPattern(catalog)); 223 prep.setString(2, getSchemaPattern(schemaPattern)); 224 prep.setString(3, getPattern(tableNamePattern)); 225 prep.setString(4, getPattern(columnNamePattern)); 226 return prep.executeQuery(); 227 } catch(Throwable e) { 228 throw logAndConvert(e); 229 } 230 } 231 232 261 public ResultSet getIndexInfo(String catalog, String schema, String tableName, boolean unique, boolean approximate) 262 throws SQLException { 263 try { 264 if(debug()) { 265 debugCode("getIndexInfo(" 266 +quote(catalog)+", " 267 +quote(schema)+", " 268 +quote(tableName)+", " 269 +unique+", " 270 +approximate+");"); 271 } 272 String uniqueCondition; 273 if(unique) { 274 uniqueCondition = "NON_UNIQUE=FALSE"; 275 } else { 276 uniqueCondition = "TRUE"; 277 } 278 checkClosed(); 279 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 280 + "TABLE_CATALOG TABLE_CAT, " 281 + "TABLE_SCHEMA TABLE_SCHEM, " 282 + "TABLE_NAME, " 283 + "NON_UNIQUE, " 284 + "TABLE_CATALOG INDEX_QUALIFIER, " 285 + "INDEX_NAME, " 286 + "INDEX_TYPE TYPE, " 287 + "ORDINAL_POSITION, " 288 + "COLUMN_NAME, " 289 + "ASC_OR_DESC, " 290 + "CARDINALITY, " + "PAGES, " 292 + "FILTER_CONDITION " 293 + "FROM INFORMATION_SCHEMA.INDEXES " 294 + "WHERE TABLE_CATALOG LIKE ? " 295 + "AND TABLE_SCHEMA LIKE ? " 296 + "AND (" + uniqueCondition + ") " 297 + "AND TABLE_NAME = ? " 298 + "ORDER BY NON_UNIQUE, TYPE, TABLE_SCHEM, INDEX_NAME, ORDINAL_POSITION"); 299 prep.setString(1, getCatalogPattern(catalog)); 300 prep.setString(2, getSchemaPattern(schema)); 301 prep.setString(3, tableName); 302 return prep.executeQuery(); 303 } catch(Throwable e) { 304 throw logAndConvert(e); 305 } 306 } 307 308 327 public ResultSet getPrimaryKeys(String catalog, String schema, String tableName) throws SQLException { 328 try { 329 if(debug()) { 330 debugCode("getPrimaryKeys(" 331 +quote(catalog)+", " 332 +quote(schema)+", " 333 +quote(tableName)+");"); 334 } 335 checkClosed(); 336 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 337 + "TABLE_CATALOG TABLE_CAT, " 338 + "TABLE_SCHEMA TABLE_SCHEM, " 339 + "TABLE_NAME, " 340 + "COLUMN_NAME, " 341 + "ORDINAL_POSITION KEY_SEQ, " 342 + "INDEX_NAME PK_NAME " 343 + "FROM INFORMATION_SCHEMA.INDEXES " 344 + "WHERE TABLE_CATALOG LIKE ? " 345 + "AND TABLE_SCHEMA LIKE ? " 346 + "AND TABLE_NAME = ? " 347 + "AND PRIMARY_KEY = TRUE " 348 + "ORDER BY COLUMN_NAME"); 349 prep.setString(1, getCatalogPattern(catalog)); 350 prep.setString(2, getSchemaPattern(schema)); 351 prep.setString(3, tableName); 352 return prep.executeQuery(); 353 } catch(Throwable e) { 354 throw logAndConvert(e); 355 } 356 } 357 358 363 public boolean allProceduresAreCallable() { 364 debugCodeCall("allProceduresAreCallable"); 365 return true; 366 } 367 368 373 public boolean allTablesAreSelectable() { 374 debugCodeCall("allTablesAreSelectable"); 375 return true; 376 } 377 378 383 public String getURL() throws SQLException { 384 try { 385 debugCodeCall("getURL"); 386 return conn.getURL(); 387 } catch(Throwable e) { 388 throw logAndConvert(e); 389 } 390 } 391 392 397 public String getUserName() throws SQLException { 398 try { 399 debugCodeCall("getUserName"); 400 return conn.getUser(); 401 } catch(Throwable e) { 402 throw logAndConvert(e); 403 } 404 } 405 406 411 public boolean isReadOnly() throws SQLException { 412 try { 413 debugCodeCall("isReadOnly"); 414 return conn.isReadOnly(); 415 } catch(Throwable e) { 416 throw logAndConvert(e); 417 } 418 } 419 420 425 public boolean nullsAreSortedHigh() { 426 debugCodeCall("nullsAreSortedHigh"); 427 return Constants.NULL_SORT_DEFAULT == Constants.NULL_SORT_HIGH; 428 } 429 430 435 public boolean nullsAreSortedLow() { 436 debugCodeCall("nullsAreSortedLow"); 437 return Constants.NULL_SORT_DEFAULT == Constants.NULL_SORT_LOW; 438 } 439 440 445 public boolean nullsAreSortedAtStart() { 446 debugCodeCall("nullsAreSortedAtStart"); 447 return Constants.NULL_SORT_DEFAULT == Constants.NULL_SORT_START; 448 } 449 450 455 public boolean nullsAreSortedAtEnd() { 456 debugCodeCall("nullsAreSortedAtEnd"); 457 return Constants.NULL_SORT_DEFAULT == Constants.NULL_SORT_END; 458 } 459 460 465 public Connection getConnection() { 466 debugCodeCall("getConnection"); 467 return conn; 468 } 469 470 489 public ResultSet getProcedures(String catalog, String schemaPattern, 490 String procedureNamePattern) throws SQLException { 491 try { 492 if(debug()) { 493 debugCode("getProcedures(" 494 +quote(catalog)+", " 495 +quote(schemaPattern)+", " 496 +quote(procedureNamePattern)+");"); 497 } 498 checkClosed(); 499 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 500 + "ALIAS_CATALOG PROCEDURE_CAT, " 501 + "ALIAS_SCHEMA PROCEDURE_SCHEM, " 502 + "ALIAS_NAME PROCEDURE_NAME, " 503 + "ZERO() NUM_INPUT_PARAMS, " 504 + "ZERO() NUM_OUTPUT_PARAMS, " 505 + "ZERO() NUM_RESULT_SETS, " 506 + "REMARKS, " 507 + "RETURNS_RESULT PROCEDURE_TYPE " 508 + "FROM INFORMATION_SCHEMA.FUNCTION_ALIASES " 509 + "WHERE ALIAS_CATALOG LIKE ? " 510 + "AND ALIAS_SCHEMA LIKE ? " 511 + "AND ALIAS_NAME LIKE ? " 512 + "ORDER BY PROCEDURE_SCHEM, PROCEDURE_NAME"); 513 prep.setString(1, getCatalogPattern(catalog)); 514 prep.setString(2, getSchemaPattern(schemaPattern)); 515 prep.setString(3, getPattern(procedureNamePattern)); 516 return prep.executeQuery(); 517 } catch(Throwable e) { 518 throw logAndConvert(e); 519 } 520 } 521 522 543 public ResultSet getProcedureColumns(String catalog, String schemaPattern, 544 String procedureNamePattern, String columnNamePattern) 545 throws SQLException { 546 try { 547 if(debug()) { 548 debugCode("getProcedureColumns(" 549 +quote(catalog)+", " 550 +quote(schemaPattern)+", " 551 +quote(procedureNamePattern)+", " 552 +quote(columnNamePattern)+");"); 553 } 554 checkClosed(); 555 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 556 + "ALIAS_CATALOG PROCEDURE_CAT, " 557 + "ALIAS_SCHEMA PROCEDURE_SCHEM, " 558 + "ALIAS_NAME PROCEDURE_NAME, " 559 + "COLUMN_NAME, " 560 + "COLUMN_TYPE, " 561 + "DATA_TYPE, " 562 + "TYPE_NAME, " 563 + "PRECISION, " 564 + "PRECISION LENGTH, " 565 + "SCALE, " 566 + "RADIX, " 567 + "NULLABLE, " 568 + "REMARKS " 569 + "FROM INFORMATION_SCHEMA.FUNCTION_COLUMNS " 570 + "WHERE ALIAS_CATALOG LIKE ? " 571 + "AND ALIAS_SCHEMA LIKE ? " 572 + "AND ALIAS_NAME LIKE ? " 573 + "AND COLUMN_NAME LIKE ?"); 574 prep.setString(1, getCatalogPattern(catalog)); 575 prep.setString(2, getSchemaPattern(schemaPattern)); 576 prep.setString(3, getPattern(procedureNamePattern)); 577 prep.setString(4, getPattern(columnNamePattern)); 578 return prep.executeQuery(); 579 } catch(Throwable e) { 580 throw logAndConvert(e); 581 } 582 } 583 584 597 public ResultSet getSchemas() throws SQLException { 598 try { 599 debugCodeCall("getSchemas"); 600 checkClosed(); 601 PreparedStatement prep = conn 602 .prepareAutoCloseStatement("SELECT " 603 + "SCHEMA_NAME TABLE_SCHEM, " 604 + "CATALOG_NAME TABLE_CATALOG, " 605 +" IS_DEFAULT " 606 + "FROM INFORMATION_SCHEMA.SCHEMATA " 607 + "ORDER BY SCHEMA_NAME"); 608 return prep.executeQuery(); 609 } catch(Throwable e) { 610 throw logAndConvert(e); 611 } 612 } 613 614 625 public ResultSet getCatalogs() throws SQLException { 626 try { 627 debugCodeCall("getCatalogs"); 628 checkClosed(); 629 PreparedStatement prep = conn.prepareAutoCloseStatement( 630 "SELECT CATALOG_NAME TABLE_CAT " 631 + "FROM INFORMATION_SCHEMA.CATALOGS"); 632 return prep.executeQuery(); 633 } catch(Throwable e) { 634 throw logAndConvert(e); 635 } 636 } 637 638 650 public ResultSet getTableTypes() throws SQLException { 651 try { 652 debugCodeCall("getTableTypes"); 653 checkClosed(); 654 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 655 + "TYPE TABLE_TYPE " 656 + "FROM INFORMATION_SCHEMA.TABLE_TYPES " 657 + "ORDER BY TABLE_TYPE"); 658 return prep.executeQuery(); 659 } catch(Throwable e) { 660 throw logAndConvert(e); 661 } 662 } 663 664 686 public ResultSet getColumnPrivileges(String catalog, String schema, 687 String table, String columnNamePattern) throws SQLException { 688 try { 689 if(debug()) { 690 debugCode("getColumnPrivileges(" 691 +quote(catalog)+", " 692 +quote(schema)+", " 693 +quote(table)+", " 694 +quote(columnNamePattern)+");"); 695 } 696 checkClosed(); 697 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 698 + "TABLE_CATALOG TABLE_CAT, " 699 + "TABLE_SCHEMA TABLE_SCHEM, " 700 + "TABLE_NAME, " 701 + "COLUMN_NAME, " 702 + "GRANTOR, " 703 + "GRANTEE, " 704 + "PRIVILEGE_TYPE PRIVILEGE, " 705 + "IS_GRANTABLE " 706 + "FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES " 707 + "WHERE TABLE_CATALOG LIKE ? " 708 + "AND TABLE_SCHEMA LIKE ? " 709 + "AND TABLE_NAME = ? " 710 + "AND COLUMN_NAME LIKE ? " 711 + "ORDER BY COLUMN_NAME, PRIVILEGE"); 712 prep.setString(1, getCatalogPattern(catalog)); 713 prep.setString(2, getSchemaPattern(schema)); 714 prep.setString(3, table); 715 prep.setString(4, getPattern(columnNamePattern)); 716 return prep.executeQuery(); 717 } catch(Throwable e) { 718 throw logAndConvert(e); 719 } 720 } 721 722 742 public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException { 743 try { 744 if(debug()) { 745 debugCode("getTablePrivileges(" 746 +quote(catalog)+", " 747 +quote(schemaPattern)+", " 748 +quote(tableNamePattern)+");"); 749 } 750 checkClosed(); 751 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 752 + "TABLE_CATALOG TABLE_CAT, " 753 + "TABLE_SCHEMA TABLE_SCHEM, " 754 + "TABLE_NAME, " 755 + "GRANTOR, " 756 + "GRANTEE, " 757 + "PRIVILEGE_TYPE PRIVILEGE, " 758 + "IS_GRANTABLE " 759 + "FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES " 760 + "WHERE TABLE_CATALOG LIKE ? " 761 + "AND TABLE_SCHEMA LIKE ? " 762 + "AND TABLE_NAME LIKE ? " 763 + "ORDER BY TABLE_SCHEM, TABLE_NAME, PRIVILEGE"); 764 prep.setString(1, getCatalogPattern(catalog)); 765 prep.setString(2, getSchemaPattern(schemaPattern)); 766 prep.setString(3, getPattern(tableNamePattern)); 767 return prep.executeQuery(); 768 } catch(Throwable e) { 769 throw logAndConvert(e); 770 } 771 } 772 773 796 public ResultSet getBestRowIdentifier(String catalog, String schema, 797 String tableName, int scope, boolean nullable) throws SQLException { 798 try { 799 if(debug()) { 800 debugCode("getBestRowIdentifier(" 801 +quote(catalog)+", " 802 +quote(schema)+", " 803 +quote(tableName)+", " 804 +scope+", "+nullable+");"); 805 } 806 checkClosed(); 807 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 808 + "CAST(? AS SMALLINT) SCOPE, " 809 + "C.COLUMN_NAME, " 810 + "C.DATA_TYPE, " 811 + "C.TYPE_NAME, " 812 + "C.CHARACTER_MAXIMUM_LENGTH COLUMN_SIZE, " 813 + "C.CHARACTER_MAXIMUM_LENGTH BUFFER_LENGTH, " 814 + "CAST(C.NUMERIC_SCALE AS SMALLINT) DECIMAL_DIGITS, " 815 + "CAST(? AS SMALLINT) PSEUDO_COLUMN " 816 + "FROM INFORMATION_SCHEMA.INDEXES I, " 817 +" INFORMATION_SCHEMA.COLUMNS C " 818 + "WHERE C.TABLE_NAME = I.TABLE_NAME " 819 + "AND C.COLUMN_NAME = I.COLUMN_NAME " 820 + "AND C.TABLE_CATALOG LIKE ? " 821 + "AND C.TABLE_SCHEMA LIKE ? " 822 + "AND C.TABLE_NAME = ? " 823 + "AND I.PRIMARY_KEY = TRUE " 824 + "ORDER BY SCOPE"); 825 prep.setInt(1, DatabaseMetaData.bestRowSession); prep.setInt(2, DatabaseMetaData.bestRowNotPseudo); prep.setString(3, getCatalogPattern(catalog)); 828 prep.setString(4, getSchemaPattern(schema)); 829 prep.setString(5, tableName); 830 return prep.executeQuery(); 831 } catch(Throwable e) { 832 throw logAndConvert(e); 833 } 834 } 835 836 856 public ResultSet getVersionColumns(String catalog, String schema, 857 String tableName) throws SQLException { 858 try { 859 if(debug()) { 860 debugCode("getVersionColumns(" 861 +quote(catalog)+", " 862 +quote(schema)+", " 863 +quote(tableName)+");"); 864 } 865 checkClosed(); 866 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 867 + "ZERO() SCOPE, " 868 + "COLUMN_NAME, " 869 + "CAST(DATA_TYPE AS INT) DATA_TYPE, " 870 + "TYPE_NAME, " 871 + "NUMERIC_PRECISION COLUMN_SIZE, " 872 + "NUMERIC_PRECISION BUFFER_LENGTH, " 873 + "NUMERIC_PRECISION DECIMAL_DIGITS, " 874 + "ZERO() PSEUDO_COLUMN " 875 + "FROM INFORMATION_SCHEMA.COLUMNS " 876 + "WHERE FALSE"); 877 return prep.executeQuery(); 878 } catch(Throwable e) { 879 throw logAndConvert(e); 880 } 881 } 882 883 910 public ResultSet getImportedKeys(String catalog, String schema, String tableName) throws SQLException { 911 try { 912 if(debug()) { 913 debugCode("getImportedKeys(" 914 +quote(catalog)+", " 915 +quote(schema)+", " 916 +quote(tableName)+");"); 917 } 918 checkClosed(); 919 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 920 + "PKTABLE_CATALOG PKTABLE_CAT, " 921 + "PKTABLE_SCHEMA PKTABLE_SCHEM, " 922 + "PKTABLE_NAME PKTABLE_NAME, " 923 + "PKCOLUMN_NAME, " 924 + "FKTABLE_CATALOG FKTABLE_CAT, " 925 + "FKTABLE_SCHEMA FKTABLE_SCHEM, " 926 + "FKTABLE_NAME, " 927 + "FKCOLUMN_NAME, " 928 + "ORDINAL_POSITION KEY_SEQ, " 929 + "UPDATE_RULE, " 930 + "DELETE_RULE, " 931 + "FK_NAME, " 932 + "PK_NAME, " 933 + "DEFERRABILITY " 934 + "FROM INFORMATION_SCHEMA.CROSS_REFERENCES " 935 + "WHERE FKTABLE_CATALOG LIKE ? " 936 + "AND FKTABLE_SCHEMA LIKE ? " 937 + "AND FKTABLE_NAME = ? " 938 + "ORDER BY PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME, FK_NAME, KEY_SEQ"); 939 prep.setString(1, getCatalogPattern(catalog)); 940 prep.setString(2, getSchemaPattern(schema)); 941 prep.setString(3, tableName); 942 return prep.executeQuery(); 943 } catch(Throwable e) { 944 throw logAndConvert(e); 945 } 946 } 947 948 975 public ResultSet getExportedKeys(String catalog, String schema, String tableName) 976 throws SQLException { 977 try { 978 if(debug()) { 979 debugCode("getExportedKeys(" 980 +quote(catalog)+", " 981 +quote(schema)+", " 982 +quote(tableName)+");"); 983 } 984 checkClosed(); 985 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 986 + "PKTABLE_CATALOG PKTABLE_CAT, " 987 + "PKTABLE_SCHEMA PKTABLE_SCHEM, " 988 + "PKTABLE_NAME PKTABLE_NAME, " 989 + "PKCOLUMN_NAME, " 990 + "FKTABLE_CATALOG FKTABLE_CAT, " 991 + "FKTABLE_SCHEMA FKTABLE_SCHEM, " 992 + "FKTABLE_NAME, " 993 + "FKCOLUMN_NAME, " 994 + "ORDINAL_POSITION KEY_SEQ, " 995 + "UPDATE_RULE, " 996 + "DELETE_RULE, " 997 + "FK_NAME, " 998 + "PK_NAME, " 999 + "DEFERRABILITY " 1000 + "FROM INFORMATION_SCHEMA.CROSS_REFERENCES " 1001 + "WHERE PKTABLE_CATALOG LIKE ? " 1002 + "AND PKTABLE_SCHEMA LIKE ? " 1003 + "AND PKTABLE_NAME = ? " 1004 + "ORDER BY FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, FK_NAME, KEY_SEQ"); 1005 prep.setString(1, getCatalogPattern(catalog)); 1006 prep.setString(2, getSchemaPattern(schema)); 1007 prep.setString(3, tableName); 1008 return prep.executeQuery(); 1009 } catch(Throwable e) { 1010 throw logAndConvert(e); 1011 } 1012 } 1013 1014 1045 public ResultSet getCrossReference(String primaryCatalog, 1046 String primarySchema, String primaryTable, String foreignCatalog, 1047 String foreignSchema, String foreignTable) throws SQLException { 1048 try { 1049 if(debug()) { 1050 debugCode("getCrossReference(" 1051 +quote(primaryCatalog)+", " 1052 +quote(primarySchema)+", " 1053 +quote(primaryTable)+", " 1054 +quote(foreignCatalog)+", " 1055 +quote(foreignSchema)+", " 1056 +quote(foreignTable)+");"); 1057 } 1058 checkClosed(); 1059 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 1060 + "PKTABLE_CATALOG PKTABLE_CAT, " 1061 + "PKTABLE_SCHEMA PKTABLE_SCHEM, " 1062 + "PKTABLE_NAME PKTABLE_NAME, " 1063 + "PKCOLUMN_NAME, " 1064 + "FKTABLE_CATALOG FKTABLE_CAT, " 1065 + "FKTABLE_SCHEMA FKTABLE_SCHEM, " 1066 + "FKTABLE_NAME, " 1067 + "FKCOLUMN_NAME, " 1068 + "ORDINAL_POSITION KEY_SEQ, " 1069 + "UPDATE_RULE, " 1070 + "DELETE_RULE, " 1071 + "FK_NAME, " 1072 + "PK_NAME, " 1073 + "DEFERRABILITY " 1074 + "FROM INFORMATION_SCHEMA.CROSS_REFERENCES " 1075 + "WHERE PKTABLE_CATALOG LIKE ? " 1076 + "AND PKTABLE_SCHEMA LIKE ? " 1077 + "AND PKTABLE_NAME = ? " 1078 + "AND FKTABLE_CATALOG LIKE ? " 1079 + "AND FKTABLE_SCHEMA LIKE ? " 1080 + "AND FKTABLE_NAME = ? " 1081 + "ORDER BY FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, FK_NAME, KEY_SEQ"); 1082 prep.setString(1, getCatalogPattern(primaryCatalog)); 1083 prep.setString(2, getSchemaPattern(primarySchema)); 1084 prep.setString(3, primaryTable); 1085 prep.setString(4, getCatalogPattern(foreignCatalog)); 1086 prep.setString(5, getSchemaPattern(foreignSchema)); 1087 prep.setString(6, foreignTable); 1088 return prep.executeQuery(); 1089 } catch(Throwable e) { 1090 throw logAndConvert(e); 1091 } 1092 } 1093 1094 1115 public ResultSet getUDTs(String catalog, String schemaPattern, 1116 String typeNamePattern, int[] types) throws SQLException { 1117 try { 1118 if(debug()) { 1119 debugCode("getUDTs(" 1120 +quote(catalog)+", " 1121 +quote(schemaPattern)+", " 1122 +quote(typeNamePattern)+", " 1123 +quoteIntArray(types)+");"); 1124 } 1125 checkClosed(); 1126 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 1127 + "CATALOG_NAME TYPE_CAT, " 1128 + "CATALOG_NAME TYPE_SCHEM, " 1129 + "CATALOG_NAME TYPE_NAME, " 1130 + "CATALOG_NAME CLASS_NAME, " 1131 + "CAST(ZERO() AS SMALLINT) DATA_TYPE, " 1132 + "CATALOG_NAME REMARKS, " 1133 + "CAST(ZERO() AS SMALLINT) BASE_TYPE " 1134 + "FROM INFORMATION_SCHEMA.CATALOGS " 1135 + "WHERE FALSE"); 1136 return prep.executeQuery(); 1137 } catch(Throwable e) { 1138 throw logAndConvert(e); 1139 } 1140 } 1141 1142 1172 public ResultSet getTypeInfo() throws SQLException { 1173 try { 1174 debugCodeCall("getTypeInfo"); 1175 checkClosed(); 1176 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 1177 + "TYPE_NAME, " 1178 + "DATA_TYPE, " 1179 + "PRECISION, " 1180 + "PREFIX LITERAL_PREFIX, " 1181 + "SUFFIX LITERAL_SUFFIX, " 1182 + "PARAMS CREATE_PARAMS, " 1183 + "NULLABLE, " 1184 + "CASE_SENSITIVE, " 1185 + "SEARCHABLE, " 1186 + "FALSE UNSIGNED_ATTRIBUTE, " 1187 + "FALSE FIXED_PREC_SCALE, " 1188 + "AUTO_INCREMENT, " 1189 + "TYPE_NAME LOCAL_TYPE_NAME, " 1190 + "MINIMUM_SCALE, " 1191 + "MAXIMUM_SCALE, " 1192 + "DATA_TYPE SQL_DATA_TYPE, " 1193 + "ZERO() SQL_DATETIME_SUB, " 1194 + "RADIX NUM_PREC_RADIX " 1195 + "FROM INFORMATION_SCHEMA.TYPE_INFO " 1196 + "ORDER BY DATA_TYPE, POS"); 1197 ResultSet rs = prep.executeQuery(); 1198 return rs; 1199 } catch(Throwable e) { 1200 throw logAndConvert(e); 1201 } 1202 } 1203 1204 1209 public boolean usesLocalFiles() { 1210 debugCodeCall("usesLocalFiles"); 1211 return true; 1212 } 1213 1214 1219 public boolean usesLocalFilePerTable() { 1220 debugCodeCall("usesLocalFilePerTable"); 1221 return false; 1222 } 1223 1224 1229 public String getIdentifierQuoteString() { 1230 debugCodeCall("getIdentifierQuoteString"); 1231 return "\""; 1232 } 1233 1234 1240 public String getSQLKeywords() { 1241 debugCodeCall("getSQLKeywords"); 1242 return ""; 1243 } 1244 1245 1250 public String getNumericFunctions() throws SQLException { 1251 debugCodeCall("getNumericFunctions"); 1252 return getFunctions("Functions (Numeric)"); 1253 } 1254 1255 1260 public String getStringFunctions() throws SQLException { 1261 debugCodeCall("getStringFunctions"); 1262 return getFunctions("Functions (String)"); 1263 } 1264 1265 1270 public String getSystemFunctions() throws SQLException { 1271 debugCodeCall("getSystemFunctions"); 1272 return getFunctions("Functions (System)"); 1273 } 1274 1275 1280 public String getTimeDateFunctions() throws SQLException { 1281 debugCodeCall("getTimeDateFunctions"); 1282 return getFunctions("Functions (Time and Date)"); 1283 } 1284 1285 private String getFunctions(String section) throws SQLException { 1286 try { 1287 StringBuffer buff = new StringBuffer (); 1288 checkClosed(); 1289 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT TOPIC " 1290 + "FROM INFORMATION_SCHEMA.HELP WHERE SECTION = ?"); 1291 prep.setString(1, section); 1292 ResultSet rs = prep.executeQuery(); 1293 while(rs.next()) { 1294 String s = rs.getString(1).trim(); 1295 String [] array = StringUtils.arraySplit(s, ',', true); 1296 for(int i=0; i<array.length; i++) { 1297 if(buff.length()>0) { 1298 buff.append(","); 1299 } 1300 String f = array[i].trim(); 1301 if(f.indexOf(' ') >= 0) { 1302 f = f.substring(0, f.indexOf(' ')).trim(); 1304 } 1305 buff.append(f); 1306 } 1307 } 1308 rs.close(); 1309 prep.close(); 1310 return buff.toString(); 1311 } catch(Throwable e) { 1312 throw logAndConvert(e); 1313 } 1314 } 1315 1316 1321 public String getSearchStringEscape() { 1322 debugCodeCall("getSearchStringEscape"); 1323 return "" + Constants.DEFAULT_ESCAPE_CHAR; 1324 } 1325 1326 1332 public String getExtraNameCharacters() { 1333 debugCodeCall("getExtraNameCharacters"); 1334 return ""; 1335 } 1336 1337 1341 public boolean supportsAlterTableWithAddColumn() { 1342 debugCodeCall("supportsAlterTableWithAddColumn"); 1343 return true; 1344 } 1345 1346 1351 public boolean supportsAlterTableWithDropColumn() { 1352 debugCodeCall("supportsAlterTableWithDropColumn"); 1353 return true; 1354 } 1355 1356 1361 public boolean supportsColumnAliasing() { 1362 debugCodeCall("supportsColumnAliasing"); 1363 return true; 1364 } 1365 1366 1371 public boolean nullPlusNonNullIsNull() { 1372 debugCodeCall("nullPlusNonNullIsNull"); 1373 return true; 1374 } 1375 1376 1381 public boolean supportsConvert() { 1382 debugCodeCall("supportsConvert"); 1383 return true; 1384 } 1385 1386 1391 public boolean supportsConvert(int fromType, int toType) { 1392 if(debug()) { 1393 debugCode("supportsConvert("+fromType+", "+fromType+");"); 1394 } 1395 return true; 1396 } 1397 1398 1403 public boolean supportsTableCorrelationNames() { 1404 debugCodeCall("supportsTableCorrelationNames"); 1405 return true; 1406 } 1407 1408 1414 public boolean supportsDifferentTableCorrelationNames() { 1415 debugCodeCall("supportsDifferentTableCorrelationNames"); 1416 return false; 1417 } 1418 1419 1424 public boolean supportsExpressionsInOrderBy() { 1425 debugCodeCall("supportsExpressionsInOrderBy"); 1426 return true; 1427 } 1428 1429 1435 public boolean supportsOrderByUnrelated() { 1436 debugCodeCall("supportsOrderByUnrelated"); 1437 return true; 1438 } 1439 1440 1445 public boolean supportsGroupBy() { 1446 debugCodeCall("supportsGroupBy"); 1447 return true; 1448 } 1449 1450 1456 public boolean supportsGroupByUnrelated() { 1457 debugCodeCall("supportsGroupByUnrelated"); 1458 return true; 1459 } 1460 1461 1468 public boolean supportsGroupByBeyondSelect() { 1469 debugCodeCall("supportsGroupByBeyondSelect"); 1470 return true; 1471 } 1472 1473 1478 public boolean supportsLikeEscapeClause() { 1479 debugCodeCall("supportsLikeEscapeClause"); 1480 return true; 1481 } 1482 1483 1488 public boolean supportsMultipleResultSets() { 1489 debugCodeCall("supportsMultipleResultSets"); 1490 return false; 1491 } 1492 1493 1499 public boolean supportsMultipleTransactions() { 1500 debugCodeCall("supportsMultipleTransactions"); 1501 return true; 1502 } 1503 1504 1509 public boolean supportsNonNullableColumns() { 1510 debugCodeCall("supportsNonNullableColumns"); 1511 return true; 1512 } 1513 1514 1519 public boolean supportsMinimumSQLGrammar() { 1520 debugCodeCall("supportsMinimumSQLGrammar"); 1521 return true; 1522 } 1523 1524 1529 public boolean supportsCoreSQLGrammar() { 1530 debugCodeCall("supportsCoreSQLGrammar"); 1531 return true; 1532 } 1533 1534 1539 public boolean supportsExtendedSQLGrammar() { 1540 debugCodeCall("supportsExtendedSQLGrammar"); 1541 return false; 1542 } 1543 1544 1549 public boolean supportsANSI92EntryLevelSQL() { 1550 debugCodeCall("supportsANSI92EntryLevelSQL"); 1551 return true; 1552 } 1553 1554 1559 public boolean supportsANSI92IntermediateSQL() { 1560 debugCodeCall("supportsANSI92IntermediateSQL"); 1561 return false; 1562 } 1563 1564 1569 public boolean supportsANSI92FullSQL() { 1570 debugCodeCall("supportsANSI92FullSQL"); 1571 return false; 1572 } 1573 1574 1579 public boolean supportsIntegrityEnhancementFacility() { 1580 debugCodeCall("supportsIntegrityEnhancementFacility"); 1581 return true; 1582 } 1583 1584 1589 public boolean supportsOuterJoins() { 1590 debugCodeCall("supportsOuterJoins"); 1591 return true; 1592 } 1593 1594 1599 public boolean supportsFullOuterJoins() { 1600 debugCodeCall("supportsFullOuterJoins"); 1601 return false; 1602 } 1603 1604 1609 public boolean supportsLimitedOuterJoins() { 1610 debugCodeCall("supportsLimitedOuterJoins"); 1611 return true; 1612 } 1613 1614 1619 public String getSchemaTerm() { 1620 debugCodeCall("getSchemaTerm"); 1621 return "schema"; 1622 } 1623 1624 1629 public String getProcedureTerm() { 1630 debugCodeCall("getProcedureTerm"); 1631 return "procedure"; 1632 } 1633 1634 1639 public String getCatalogTerm() { 1640 debugCodeCall("getCatalogTerm"); 1641 return "catalog"; 1642 } 1643 1644 1649 public boolean isCatalogAtStart() { 1650 debugCodeCall("isCatalogAtStart"); 1651 return true; 1652 } 1653 1654 1659 public String getCatalogSeparator() { 1660 debugCodeCall("getCatalogSeparator"); 1661 return "."; 1662 } 1663 1664 1669 public boolean supportsSchemasInDataManipulation() { 1670 debugCodeCall("supportsSchemasInDataManipulation"); 1671 return true; 1672 } 1673 1674 1679 public boolean supportsSchemasInProcedureCalls() { 1680 debugCodeCall("supportsSchemasInProcedureCalls"); 1681 return true; 1682 } 1683 1684 1689 public boolean supportsSchemasInTableDefinitions() { 1690 debugCodeCall("supportsSchemasInTableDefinitions"); 1691 return true; 1692 } 1693 1694 1699 public boolean supportsSchemasInIndexDefinitions() { 1700 debugCodeCall("supportsSchemasInIndexDefinitions"); 1701 return true; 1702 } 1703 1704 1709 public boolean supportsSchemasInPrivilegeDefinitions() { 1710 debugCodeCall("supportsSchemasInPrivilegeDefinitions"); 1711 return true; 1712 } 1713 1714 1719 public boolean supportsCatalogsInDataManipulation() { 1720 debugCodeCall("supportsCatalogsInDataManipulation"); 1721 return false; 1722 } 1723 1724 1729 public boolean supportsCatalogsInProcedureCalls() { 1730 debugCodeCall("supportsCatalogsInProcedureCalls"); 1731 return false; 1732 } 1733 1734 1739 public boolean supportsCatalogsInTableDefinitions() { 1740 debugCodeCall("supportsCatalogsInTableDefinitions"); 1741 return false; 1742 } 1743 1744 1749 public boolean supportsCatalogsInIndexDefinitions() { 1750 debugCodeCall("supportsCatalogsInIndexDefinitions"); 1751 return false; 1752 } 1753 1754 1759 public boolean supportsCatalogsInPrivilegeDefinitions() { 1760 debugCodeCall("supportsCatalogsInPrivilegeDefinitions"); 1761 return false; 1762 } 1763 1764 1769 public boolean supportsPositionedDelete() { 1770 debugCodeCall("supportsPositionedDelete"); 1771 return true; 1772 } 1773 1774 1779 public boolean supportsPositionedUpdate() { 1780 debugCodeCall("supportsPositionedUpdate"); 1781 return true; 1782 } 1783 1784 1789 public boolean supportsSelectForUpdate() { 1790 debugCodeCall("supportsSelectForUpdate"); 1791 return true; 1792 } 1793 1794 1799 public boolean supportsStoredProcedures() { 1800 debugCodeCall("supportsStoredProcedures"); 1801 return false; 1802 } 1803 1804 1809 public boolean supportsSubqueriesInComparisons() { 1810 debugCodeCall("supportsSubqueriesInComparisons"); 1811 return true; 1812 } 1813 1814 1819 public boolean supportsSubqueriesInExists() { 1820 debugCodeCall("supportsSubqueriesInExists"); 1821 return true; 1822 } 1823 1824 1829 public boolean supportsSubqueriesInIns() { 1830 debugCodeCall("supportsSubqueriesInIns"); 1831 return true; 1832 } 1833 1834 1839 public boolean supportsSubqueriesInQuantifieds() { 1840 debugCodeCall("supportsSubqueriesInQuantifieds"); 1841 return true; 1842 } 1843 1844 1849 public boolean supportsCorrelatedSubqueries() { 1850 debugCodeCall("supportsCorrelatedSubqueries"); 1851 return true; 1852 } 1853 1854 1859 public boolean supportsUnion() { 1860 debugCodeCall("supportsUnion"); 1861 return true; 1862 } 1863 1864 1869 public boolean supportsUnionAll() { 1870 debugCodeCall("supportsUnionAll"); 1871 return true; 1872 } 1873 1874 1879 public boolean supportsOpenCursorsAcrossCommit() { 1880 debugCodeCall("supportsOpenCursorsAcrossCommit"); 1881 return false; 1882 } 1883 1884 1889 public boolean supportsOpenCursorsAcrossRollback() { 1890 debugCodeCall("supportsOpenCursorsAcrossRollback"); 1891 return false; 1892 } 1893 1894 1899 public boolean supportsOpenStatementsAcrossCommit() { 1900 debugCodeCall("supportsOpenStatementsAcrossCommit"); 1901 return true; 1902 } 1903 1904 1909 public boolean supportsOpenStatementsAcrossRollback() { 1910 debugCodeCall("supportsOpenStatementsAcrossRollback"); 1911 return true; 1912 } 1913 1914 1919 public boolean supportsTransactions() { 1920 debugCodeCall("supportsTransactions"); 1921 return true; 1922 } 1923 1924 1929 public boolean supportsTransactionIsolationLevel(int level) { 1930 debugCodeCall("supportsTransactionIsolationLevel"); 1931 return true; 1932 } 1933 1934 1940 public boolean supportsDataDefinitionAndDataManipulationTransactions() { 1941 debugCodeCall("supportsDataDefinitionAndDataManipulationTransactions"); 1942 return false; 1943 } 1944 1945 1950 public boolean supportsDataManipulationTransactionsOnly() { 1951 debugCodeCall("supportsDataManipulationTransactionsOnly"); 1952 return true; 1953 } 1954 1955 1960 public boolean dataDefinitionCausesTransactionCommit() { 1961 debugCodeCall("dataDefinitionCausesTransactionCommit"); 1962 return true; 1963 } 1964 1965 1970 public boolean dataDefinitionIgnoredInTransactions() { 1971 debugCodeCall("dataDefinitionIgnoredInTransactions"); 1972 return false; 1973 } 1974 1975 1981 public boolean supportsResultSetType(int type) { 1982 debugCodeCall("supportsResultSetType", type); 1983 return type != ResultSet.TYPE_SCROLL_SENSITIVE; 1984 } 1985 1986 1992 public boolean supportsResultSetConcurrency(int type, int concurrency) { 1993 if(debug()) { 1994 debugCode("supportsResultSetConcurrency("+type+", "+concurrency+");"); 1995 } 1996 return type != ResultSet.TYPE_SCROLL_SENSITIVE; 1997 } 1998 1999 2004 public boolean ownUpdatesAreVisible(int type) { 2005 debugCodeCall("ownUpdatesAreVisible", type); 2006 return false; 2007 } 2008 2009 2014 public boolean ownDeletesAreVisible(int type) { 2015 debugCodeCall("ownDeletesAreVisible", type); 2016 return false; 2017 } 2018 2019 2023 public boolean ownInsertsAreVisible(int type) { 2024 debugCodeCall("ownInsertsAreVisible", type); 2025 return false; 2026 } 2027 2028 2032 public boolean othersUpdatesAreVisible(int type) { 2033 debugCodeCall("othersUpdatesAreVisible", type); 2034 return false; 2035 } 2036 2037 2041 public boolean othersDeletesAreVisible(int type) { 2042 debugCodeCall("othersDeletesAreVisible", type); 2043 return false; 2044 } 2045 2046 2050 public boolean othersInsertsAreVisible(int type) { 2051 debugCodeCall("othersInsertsAreVisible", type); 2052 return false; 2053 } 2054 2055 2059 public boolean updatesAreDetected(int type) { 2060 debugCodeCall("updatesAreDetected", type); 2061 return false; 2062 } 2063 2064 2068 public boolean deletesAreDetected(int type) { 2069 debugCodeCall("deletesAreDetected", type); 2070 return false; 2071 } 2072 2073 2077 public boolean insertsAreDetected(int type) { 2078 debugCodeCall("insertsAreDetected", type); 2079 return false; 2080 } 2081 2082 2086 public boolean supportsBatchUpdates() { 2087 debugCodeCall("supportsBatchUpdates"); 2088 return true; 2089 } 2090 2091 2095 public boolean doesMaxRowSizeIncludeBlobs() { 2096 debugCodeCall("doesMaxRowSizeIncludeBlobs"); 2097 return false; 2098 } 2099 2100 2104 public int getDefaultTransactionIsolation() { 2105 debugCodeCall("getDefaultTransactionIsolation"); 2106 return Connection.TRANSACTION_READ_COMMITTED; 2107 } 2108 2109 2114 public boolean supportsMixedCaseIdentifiers() { 2115 debugCodeCall("supportsMixedCaseIdentifiers"); 2116 return false; 2117 } 2118 2119 2124 public boolean supportsMixedCaseQuotedIdentifiers() { 2125 debugCodeCall("supportsMixedCaseQuotedIdentifiers"); 2126 return true; 2127 } 2128 2129 2134 public boolean storesUpperCaseIdentifiers() { 2135 debugCodeCall("storesUpperCaseIdentifiers"); 2136 return true; 2137 } 2138 2139 2144 public boolean storesLowerCaseIdentifiers() { 2145 debugCodeCall("storesLowerCaseIdentifiers"); 2146 return false; 2147 } 2148 2149 2154 public boolean storesMixedCaseIdentifiers() { 2155 debugCodeCall("storesMixedCaseIdentifiers"); 2156 return false; 2157 } 2158 2159 2164 public boolean storesUpperCaseQuotedIdentifiers() { 2165 debugCodeCall("storesUpperCaseQuotedIdentifiers"); 2166 return false; 2167 } 2168 2169 2174 public boolean storesLowerCaseQuotedIdentifiers() { 2175 debugCodeCall("storesLowerCaseQuotedIdentifiers"); 2176 return false; 2177 } 2178 2179 2184 public boolean storesMixedCaseQuotedIdentifiers() { 2185 debugCodeCall("storesMixedCaseQuotedIdentifiers"); 2186 return true; 2187 } 2188 2189 2193 public int getMaxBinaryLiteralLength() { 2194 debugCodeCall("getMaxBinaryLiteralLength"); 2195 return 0; 2196 } 2197 2198 2202 public int getMaxCharLiteralLength() { 2203 debugCodeCall("getMaxCharLiteralLength"); 2204 return 0; 2205 } 2206 2207 2211 public int getMaxColumnNameLength() { 2212 debugCodeCall("getMaxColumnNameLength"); 2213 return 0; 2214 } 2215 2216 2220 public int getMaxColumnsInGroupBy() { 2221 debugCodeCall("getMaxColumnsInGroupBy"); 2222 return 0; 2223 } 2224 2225 2229 public int getMaxColumnsInIndex() { 2230 debugCodeCall("getMaxColumnsInIndex"); 2231 return 0; 2232 } 2233 2234 2238 public int getMaxColumnsInOrderBy() { 2239 debugCodeCall("getMaxColumnsInOrderBy"); 2240 return 0; 2241 } 2242 2243 2247 public int getMaxColumnsInSelect() { 2248 debugCodeCall("getMaxColumnsInSelect"); 2249 return 0; 2250 } 2251 2252 2256 public int getMaxColumnsInTable() { 2257 debugCodeCall("getMaxColumnsInTable"); 2258 return 0; 2259 } 2260 2261 2265 public int getMaxConnections() { 2266 debugCodeCall("getMaxConnections"); 2267 return 0; 2268 } 2269 2270 2274 public int getMaxCursorNameLength() { 2275 debugCodeCall("getMaxCursorNameLength"); 2276 return 0; 2277 } 2278 2279 2283 public int getMaxIndexLength() { 2284 debugCodeCall("getMaxIndexLength"); 2285 return 0; 2286 } 2287 2288 2292 public int getMaxSchemaNameLength() { 2293 debugCodeCall("getMaxSchemaNameLength"); 2294 return 0; 2295 } 2296 2297 2301 public int getMaxProcedureNameLength() { 2302 debugCodeCall("getMaxProcedureNameLength"); 2303 return 0; 2304 } 2305 2306 2310 public int getMaxCatalogNameLength() { 2311 debugCodeCall("getMaxCatalogNameLength"); 2312 return 0; 2313 } 2314 2315 2319 public int getMaxRowSize() { 2320 debugCodeCall("getMaxRowSize"); 2321 return 0; 2322 } 2323 2324 2328 public int getMaxStatementLength() { 2329 debugCodeCall("getMaxStatementLength"); 2330 return 0; 2331 } 2332 2333 2337 public int getMaxStatements() { 2338 debugCodeCall("getMaxStatements"); 2339 return 0; 2340 } 2341 2342 2346 public int getMaxTableNameLength() { 2347 debugCodeCall("getMaxTableNameLength"); 2348 return 0; 2349 } 2350 2351 2355 public int getMaxTablesInSelect() { 2356 debugCodeCall("getMaxTablesInSelect"); 2357 return 0; 2358 } 2359 2360 2364 public int getMaxUserNameLength() { 2365 debugCodeCall("getMaxUserNameLength"); 2366 return 0; 2367 } 2368 2369 2373 public boolean supportsSavepoints() { 2374 debugCodeCall("supportsSavepoints"); 2375 return true; 2376 } 2377 2378 2382 public boolean supportsNamedParameters() { 2383 debugCodeCall("supportsNamedParameters"); 2384 return false; 2385 } 2386 2387 2391 public boolean supportsMultipleOpenResults() { 2392 debugCodeCall("supportsMultipleOpenResults"); 2393 return true; 2394 } 2395 2396 2400 public boolean supportsGetGeneratedKeys() { 2401 debugCodeCall("supportsGetGeneratedKeys"); 2402 return true; 2403 } 2404 2405 2411 public ResultSet getSuperTypes(String catalog, String schemaPattern, 2412 String typeNamePattern) throws SQLException { 2413 try { 2414 if(debug()) { 2415 debugCode("getSuperTypes(" 2416 +quote(catalog)+", " 2417 +quote(schemaPattern)+", " 2418 +quote(typeNamePattern)+");"); 2419 } 2420 throw Message.getUnsupportedException(); 2421 } catch(Throwable e) { 2422 throw logAndConvert(e); 2423 } 2424 } 2425 2426 2439 public ResultSet getSuperTables(String catalog, String schemaPattern, 2440 String tableNamePattern) throws SQLException { 2441 try { 2442 if(debug()) { 2443 debugCode("getSuperTables(" 2444 +quote(catalog)+", " 2445 +quote(schemaPattern)+", " 2446 +quote(tableNamePattern)+");"); 2447 } 2448 checkClosed(); 2449 PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " 2450 + "CATALOG_NAME TABLE_CAT, " 2451 + "CATALOG_NAME TABLE_SCHEM, " 2452 + "CATALOG_NAME TABLE_NAME, " 2453 + "CATALOG_NAME SUPERTABLE_NAME " 2454 + "FROM INFORMATION_SCHEMA.CATALOGS " 2455 + "WHERE FALSE"); 2456 return prep.executeQuery(); 2457 } catch(Throwable e) { 2458 throw logAndConvert(e); 2459 } 2460 } 2461 2462 2468 public ResultSet getAttributes(String catalog, String schemaPattern, 2469 String typeNamePattern, String attributeNamePattern) 2470 throws SQLException { 2471 try { 2472 if(debug()) { 2473 debugCode("getAttributes(" 2474 +quote(catalog)+", " 2475 +quote(schemaPattern)+", " 2476 +quote(typeNamePattern)+", " 2477 +quote(attributeNamePattern)+");"); 2478 } 2479 throw Message.getUnsupportedException(); 2480 } catch(Throwable e) { 2481 throw logAndConvert(e); 2482 } 2483 } 2484 2485 2491 public boolean supportsResultSetHoldability(int holdability) { 2493 debugCodeCall("supportsResultSetHoldability", holdability); 2494 return holdability == ResultSet.CLOSE_CURSORS_AT_COMMIT; 2495 } 2496 2498 2502 public int getResultSetHoldability() { 2504 debugCodeCall("getResultSetHoldability"); 2505 return ResultSet.CLOSE_CURSORS_AT_COMMIT; 2506 } 2507 2509 2513 public int getDatabaseMajorVersion() { 2514 debugCodeCall("getDatabaseMajorVersion"); 2515 return Constants.VERSION_MAJOR; 2516 } 2517 2518 2522 public int getDatabaseMinorVersion() { 2523 debugCodeCall("getDatabaseMinorVersion"); 2524 return Constants.VERSION_MINOR; 2525 } 2526 2527 2531 public int getJDBCMajorVersion() throws SQLException { 2532 debugCodeCall("getJDBCMajorVersion"); 2533 return Constants.VERSION_JDBC_MAJOR; 2534 } 2535 2536 2540 public int getJDBCMinorVersion() throws SQLException { 2541 debugCodeCall("getJDBCMinorVersion"); 2542 return Constants.VERSION_JDBC_MINOR; 2543 } 2544 2545 2549 public int getSQLStateType() { 2551 debugCodeCall("getSQLStateType"); 2552 return DatabaseMetaData.sqlStateSQL99; 2553 } 2554 2556 2560 public boolean locatorsUpdateCopy() { 2561 debugCodeCall("locatorsUpdateCopy"); 2562 return false; 2563 } 2564 2565 2569 public boolean supportsStatementPooling() { 2570 debugCodeCall("supportsStatementPooling"); 2571 return false; 2572 } 2573 2574 2576 JdbcDatabaseMetaData(JdbcConnection conn, Trace trace, int id) { 2577 setTrace(trace, TraceObject.DATABASE_META_DATA, id); 2578 this.conn = conn; 2579 } 2580 2581 private void checkClosed() throws SQLException { 2582 conn.checkClosed(); 2583 } 2584 2585 private String getPattern(String pattern) { 2586 return pattern == null ? "%" : pattern; 2587 } 2588 2589 private String getSchemaPattern(String pattern) { 2590 return pattern == null ? "%" : pattern.length() == 0 ? Constants.SCHEMA_MAIN : pattern; 2591 } 2592 2593 private String getCatalogPattern(String catalogPattern) { 2594 return catalogPattern == null || catalogPattern.length()==0 ? "%" : catalogPattern; 2596 } 2597 2598 2602 2609 2611 2615 public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException { 2616 debugCodeCall("getSchemas"); 2617 throw Message.getUnsupportedException(); 2618 } 2619 2620 2624 public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException { 2625 debugCodeCall("supportsStoredFunctionsUsingCallSyntax"); 2626 return true; 2627 } 2628 2629 2633 public boolean autoCommitFailureClosesAllResultSets() throws SQLException { 2634 debugCodeCall("autoCommitFailureClosesAllResultSets"); 2635 return false; 2636 } 2637 2638 2642 public ResultSet getClientInfoProperties() throws SQLException { 2643 debugCodeCall("getClientInfoProperties"); 2644 throw Message.getUnsupportedException(); 2645 } 2646 2647 2651 2658 2660 2664 2671 2673 2677 public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern) throws SQLException { 2678 debugCodeCall("getFunctionColumns"); 2679 throw Message.getUnsupportedException(); 2680 } 2681 2682 2686 public ResultSet getFunctions(String arg0, String arg1, String arg2) throws SQLException { 2687 debugCodeCall("getFunctions"); 2688 throw Message.getUnsupportedException(); 2689 } 2690 2691} 2692 2693 | Popular Tags |