1 package in.co.daffodil.db.jdbc; 2 3 import java.sql.*; 4 import com.daffodilwoods.database.resource.*; 5 import java.util.*; 6 import java.io.*; 7 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.Datatype; 8 import com.daffodilwoods.daffodildb.client._RecordSetBuffer; 9 import com.daffodilwoods.daffodildb.client._RecordSetBufferIterator; 10 import com.daffodilwoods.daffodildb.client._Record; 11 import com.daffodilwoods.daffodildb.server.datadictionarysystem.SystemTables; 12 import in.co.daffodil.db.general.*; 13 import com.daffodilwoods.daffodildb.client.RecordSet; 14 import com.daffodilwoods.daffodildb.server.sql99.dql.listenerevents.IteratorConstants; 15 16 37 public class DaffodilDBDatabaseMetaData 38 implements DatabaseMetaData { 39 40 42 44 private static int COLUMN_OFFSET = 1; 45 DaffodilDBConnection systemConnection; 46 DaffodilDBConnection userConnection; 47 String url; 48 49 public DaffodilDBDatabaseMetaData(DaffodilDBConnection userCon, 50 DaffodilDBConnection systemCon, 51 String url0) { 52 systemConnection = systemCon; 53 userConnection = userCon; 54 url = url0; 55 } 56 57 public Connection getConnection() { 58 return userConnection; 59 } 60 61 62 69 public boolean allProceduresAreCallable() throws SQLException { 70 return DatabaseProperties.allProceduresAreCallable; 71 } 72 73 80 public boolean allTablesAreSelectable() throws SQLException { 81 return DatabaseProperties.allTablesAreSelectable; 82 } 83 84 90 public String getURL() throws SQLException { 91 return url; 92 } 93 94 100 public String getUserName() throws SQLException { 101 try { 102 return userConnection.getServerConnection().getCurrentUser(); 103 } 104 catch (DException ex) { 105 throw ex.getSqlException(systemConnection.getLocale()); 106 } 107 } 108 109 115 public boolean isReadOnly() throws SQLException { 116 return systemConnection.isReadOnly(); 117 } 118 119 125 public boolean nullsAreSortedHigh() throws SQLException { 126 return DatabaseProperties.nullsAreSortedHigh; 127 } 128 129 135 public boolean nullsAreSortedLow() throws SQLException { 136 return DatabaseProperties.nullsAreSortedLow; 137 } 138 139 145 public boolean nullsAreSortedAtStart() throws SQLException { 146 return DatabaseProperties.nullsAreSortedAtStart; 147 } 148 149 155 public boolean nullsAreSortedAtEnd() throws SQLException { 156 return DatabaseProperties.nullsAreSortedAtEnd; 157 } 158 159 165 public String getDatabaseProductName() throws SQLException { 166 return DatabaseProperties.databaseProductName; 167 } 168 169 175 public String getDatabaseProductVersion() throws SQLException { 176 return DatabaseProperties.databaseProductVersion; 177 } 178 179 185 public String getDriverName() throws SQLException { 186 return DatabaseProperties.driverName; 187 } 188 189 195 public String getDriverVersion() throws SQLException { 196 return DatabaseProperties.driverVersion; 197 } 198 199 204 public int getDriverMajorVersion() { 205 return DatabaseProperties.driverMajorVersion; 206 } 207 208 213 public int getDriverMinorVersion() { 214 return DatabaseProperties.driverMinorVersion; 215 } 216 217 223 public boolean usesLocalFiles() throws SQLException { 224 return DatabaseProperties.usesLocalFiles; 225 } 226 227 233 public boolean usesLocalFilePerTable() throws SQLException { 234 return DatabaseProperties.usesLocalFilePerTable; 235 } 236 237 246 public boolean supportsMixedCaseIdentifiers() throws SQLException { 247 return DatabaseProperties.supportsMixedCaseIdentifiers; 248 } 249 250 257 public boolean storesUpperCaseIdentifiers() throws SQLException { 258 return DatabaseProperties.storesUpperCaseIdentifiers; 259 } 260 261 268 public boolean storesLowerCaseIdentifiers() throws SQLException { 269 return DatabaseProperties.storesLowerCaseIdentifiers; 270 } 271 272 279 public boolean storesMixedCaseIdentifiers() throws SQLException { 280 return DatabaseProperties.storesMixedCaseIdentifiers; 281 } 282 283 292 public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { 293 return DatabaseProperties.supportsMixedCaseQuotedIdentifiers; 294 } 295 296 303 public boolean storesUpperCaseQuotedIdentifiers() throws SQLException { 304 return DatabaseProperties.storesUpperCaseQuotedIdentifiers; 305 } 306 307 314 public boolean storesLowerCaseQuotedIdentifiers() throws SQLException { 315 return DatabaseProperties.storesLowerCaseQuotedIdentifiers; 316 } 317 318 325 public boolean storesMixedCaseQuotedIdentifiers() throws SQLException { 326 return DatabaseProperties.storesMixedCaseQuotedIdentifiers; 327 } 328 329 339 public String getIdentifierQuoteString() throws SQLException { 340 return DatabaseProperties.identifierQuoteString; 341 } 342 343 350 public String getSQLKeywords() throws SQLException { 351 return DatabaseProperties.getSQLKeywords(); 352 } 353 354 362 public String getNumericFunctions() throws SQLException { 363 return DatabaseProperties.getNumericFunctions(); 364 } 365 366 374 public String getStringFunctions() throws SQLException { 375 return DatabaseProperties.getStringFunctions(); 376 } 377 378 386 public String getSystemFunctions() throws SQLException { 387 return DatabaseProperties.getSystemFunctions(); 388 } 389 390 396 public String getTimeDateFunctions() throws SQLException { 397 return DatabaseProperties.getTimeDateFunctions(); 398 } 399 400 412 public String getSearchStringEscape() throws SQLException { 413 return DatabaseProperties.getSearchStringEscape(); 414 } 415 416 423 public String getExtraNameCharacters() throws SQLException { 424 return DatabaseProperties.getExtraNameCharacters(); 425 } 426 427 428 434 public boolean supportsAlterTableWithAddColumn() throws SQLException { 435 return DatabaseProperties.supportsAlterTableWithAddColumn; 436 } 437 438 444 public boolean supportsAlterTableWithDropColumn() throws SQLException { 445 return DatabaseProperties.supportsAlterTableWithDropColumn; 446 } 447 448 460 public boolean supportsColumnAliasing() throws SQLException { 461 return DatabaseProperties.supportsColumnAliasing; 462 } 463 464 472 public boolean nullPlusNonNullIsNull() throws SQLException { 473 return DatabaseProperties.nullPlusNonNullIsNull; 474 } 475 476 482 public boolean supportsConvert() throws SQLException { 483 return DatabaseProperties.supportsConvert; 484 } 485 486 495 public boolean supportsConvert(int fromType, int toType) throws SQLException { 496 return DatabaseProperties.supportsConvert(fromType, toType); 497 } 498 499 507 public boolean supportsTableCorrelationNames() throws SQLException { 508 return DatabaseProperties.supportsTableCorrelationNames; 509 } 510 511 518 public boolean supportsDifferentTableCorrelationNames() throws SQLException { 519 return DatabaseProperties.supportsDifferentTableCorrelationNames; 520 } 521 522 528 public boolean supportsExpressionsInOrderBy() throws SQLException { 529 return DatabaseProperties.supportsExpressionsInOrderBy; 530 } 531 532 538 public boolean supportsOrderByUnrelated() throws SQLException { 539 return DatabaseProperties.supportsOrderByUnrelated; 540 } 541 542 548 public boolean supportsGroupBy() throws SQLException { 549 return DatabaseProperties.supportsGroupBy; 550 } 551 552 558 public boolean supportsGroupByUnrelated() throws SQLException { 559 return DatabaseProperties.supportsGroupByUnrelated; 560 } 561 562 569 public boolean supportsGroupByBeyondSelect() throws SQLException { 570 return DatabaseProperties.supportsGroupByBeyondSelect; 571 } 572 573 581 public boolean supportsLikeEscapeClause() throws SQLException { 582 return DatabaseProperties.supportsLikeEscapeClause; 583 } 584 585 591 public boolean supportsMultipleResultSets() throws SQLException { 592 return DatabaseProperties.supportsMultipleResultSets; 593 } 594 595 602 public boolean supportsMultipleTransactions() throws SQLException { 603 return DatabaseProperties.supportsMultipleTransactions; 604 } 605 606 614 public boolean supportsNonNullableColumns() throws SQLException { 615 return DatabaseProperties.supportsNonNullableColumns; 616 } 617 618 626 public boolean supportsMinimumSQLGrammar() throws SQLException { 627 return DatabaseProperties.supportsMinimumSQLGrammar; 628 } 629 630 636 public boolean supportsCoreSQLGrammar() throws SQLException { 637 return DatabaseProperties.supportsCoreSQLGrammar; 638 } 639 640 646 public boolean supportsExtendedSQLGrammar() throws SQLException { 647 return DatabaseProperties.supportsExtendedSQLGrammar; 648 } 649 650 658 public boolean supportsANSI92EntryLevelSQL() throws SQLException { 659 return DatabaseProperties.supportsANSI92EntryLevelSQL; 660 } 661 662 668 public boolean supportsANSI92IntermediateSQL() throws SQLException { 669 return DatabaseProperties.supportsANSI92IntermediateSQL; 670 } 671 672 678 public boolean supportsANSI92FullSQL() throws SQLException { 679 return DatabaseProperties.supportsANSI92FullSQL; 680 } 681 682 688 public boolean supportsIntegrityEnhancementFacility() throws SQLException { 689 return DatabaseProperties.supportsIntegrityEnhancementFacility; 690 } 691 692 698 public boolean supportsOuterJoins() throws SQLException { 699 return DatabaseProperties.supportsOuterJoins; 700 } 701 702 708 public boolean supportsFullOuterJoins() throws SQLException { 709 return DatabaseProperties.supportsFullOuterJoins; 710 } 711 712 719 public boolean supportsLimitedOuterJoins() throws SQLException { 720 return DatabaseProperties.supportsLimitedOuterJoins; 721 } 722 723 729 public String getSchemaTerm() throws SQLException { 730 return DatabaseProperties.schemaTerm; 731 } 732 733 739 public String getProcedureTerm() throws SQLException { 740 return DatabaseProperties.procedureTerm; 741 } 742 743 749 public String getCatalogTerm() throws SQLException { 750 return DatabaseProperties.catalogTerm; 751 } 752 753 760 public boolean isCatalogAtStart() throws SQLException { 761 return DatabaseProperties.isCatalogAtStart; 762 } 763 764 770 public String getCatalogSeparator() throws SQLException { 771 return DatabaseProperties.catalogSeparator; 772 } 773 774 780 public boolean supportsSchemasInDataManipulation() throws SQLException { 781 return DatabaseProperties.supportsSchemasInDataManipulation; 782 } 783 784 790 public boolean supportsSchemasInProcedureCalls() throws SQLException { 791 return DatabaseProperties.supportsSchemasInProcedureCalls; 792 } 793 794 800 public boolean supportsSchemasInTableDefinitions() throws SQLException { 801 return DatabaseProperties.supportsSchemasInTableDefinitions; 802 } 803 804 810 public boolean supportsSchemasInIndexDefinitions() throws SQLException { 811 return DatabaseProperties.supportsSchemasInIndexDefinitions; 812 } 813 814 820 public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException { 821 return DatabaseProperties.supportsSchemasInPrivilegeDefinitions; 822 } 823 824 830 public boolean supportsCatalogsInDataManipulation() throws SQLException { 831 return DatabaseProperties.supportsCatalogsInDataManipulation; 832 } 833 834 840 public boolean supportsCatalogsInProcedureCalls() throws SQLException { 841 return DatabaseProperties.supportsCatalogsInProcedureCalls; 842 } 843 844 850 public boolean supportsCatalogsInTableDefinitions() throws SQLException { 851 return DatabaseProperties.supportsCatalogsInTableDefinitions; 852 } 853 854 860 public boolean supportsCatalogsInIndexDefinitions() throws SQLException { 861 return DatabaseProperties.supportsCatalogsInIndexDefinitions; 862 } 863 864 870 public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException { 871 return DatabaseProperties.supportsCatalogsInPrivilegeDefinitions; 872 } 873 874 880 public boolean supportsPositionedDelete() throws SQLException { 881 return DatabaseProperties.supportsPositionedDelete; 882 } 883 884 890 public boolean supportsPositionedUpdate() throws SQLException { 891 return DatabaseProperties.supportsPositionedUpdate; 892 } 893 894 900 public boolean supportsSelectForUpdate() throws SQLException { 901 return DatabaseProperties.supportsSelectForUpdate; 902 } 903 904 911 public boolean supportsStoredProcedures() throws SQLException { 912 return DatabaseProperties.supportsStoredProcedures; 913 } 914 915 923 public boolean supportsSubqueriesInComparisons() throws SQLException { 924 return DatabaseProperties.supportsSubqueriesInComparisons; 925 } 926 927 935 public boolean supportsSubqueriesInExists() throws SQLException { 936 return DatabaseProperties.supportsSubqueriesInExists; 937 } 938 939 947 public boolean supportsSubqueriesInIns() throws SQLException { 948 return DatabaseProperties.supportsSubqueriesInIns; 949 } 950 951 959 public boolean supportsSubqueriesInQuantifieds() throws SQLException { 960 return DatabaseProperties.supportsSubqueriesInQuantifieds; 961 } 962 963 971 public boolean supportsCorrelatedSubqueries() throws SQLException { 972 return DatabaseProperties.supportsCorrelatedSubqueries; 973 } 974 975 981 public boolean supportsUnion() throws SQLException { 982 return DatabaseProperties.supportsUnion; 983 } 984 985 991 public boolean supportsUnionAll() throws SQLException { 992 return DatabaseProperties.supportsUnionAll; 993 } 994 995 1002 public boolean supportsOpenCursorsAcrossCommit() throws SQLException { 1003 return DatabaseProperties.supportsOpenCursorsAcrossCommit; 1004 } 1005 1006 1013 public boolean supportsOpenCursorsAcrossRollback() throws SQLException { 1014 return DatabaseProperties.supportsOpenCursorsAcrossRollback; 1015 } 1016 1017 1024 public boolean supportsOpenStatementsAcrossCommit() throws SQLException { 1025 return DatabaseProperties.supportsOpenStatementsAcrossCommit; 1026 } 1027 1028 1035 public boolean supportsOpenStatementsAcrossRollback() throws SQLException { 1036 return DatabaseProperties.supportsOpenCursorsAcrossRollback; 1037 } 1038 1039 1040 1047 public int getMaxBinaryLiteralLength() throws SQLException { 1048 return DatabaseProperties.maxBinaryLiteralLength; 1049 } 1050 1051 1058 public int getMaxCharLiteralLength() throws SQLException { 1059 return DatabaseProperties.maxCharLiteralLength; 1060 } 1061 1062 1069 public int getMaxColumnNameLength() throws SQLException { 1070 return DatabaseProperties.maxColumnNameLength; 1071 } 1072 1073 1080 public int getMaxColumnsInGroupBy() throws SQLException { 1081 return DatabaseProperties.maxColumnsInGroupBy; 1082 } 1083 1084 1091 public int getMaxColumnsInIndex() throws SQLException { 1092 return DatabaseProperties.maxColumnsInIndex; 1093 } 1094 1095 1102 public int getMaxColumnsInOrderBy() throws SQLException { 1103 return DatabaseProperties.maxColumnsInOrderBy; 1104 } 1105 1106 1113 public int getMaxColumnsInSelect() throws SQLException { 1114 return DatabaseProperties.maxColumnsInSelect; 1115 } 1116 1117 1124 public int getMaxColumnsInTable() throws SQLException { 1125 return DatabaseProperties.maxColumnsInTable; 1126 } 1127 1128 1135 public int getMaxConnections() throws SQLException { 1136 return DatabaseProperties.maxConnections; 1137 } 1138 1139 1146 public int getMaxCursorNameLength() throws SQLException { 1147 return DatabaseProperties.maxCursorNameLength; 1148 } 1149 1150 1159 public int getMaxIndexLength() throws SQLException { 1160 return DatabaseProperties.maxIndexLength; 1161 } 1162 1163 1170 public int getMaxSchemaNameLength() throws SQLException { 1171 return DatabaseProperties.maxSchemaNameLength; 1172 } 1173 1174 1181 public int getMaxProcedureNameLength() throws SQLException { 1182 return DatabaseProperties.maxProcedureNameLength; 1183 } 1184 1185 1192 public int getMaxCatalogNameLength() throws SQLException { 1193 return DatabaseProperties.maxCatalogNameLength; 1194 } 1195 1196 1203 public int getMaxRowSize() throws SQLException { 1204 return DatabaseProperties.maxRowSize; 1205 } 1206 1207 1214 public boolean doesMaxRowSizeIncludeBlobs() throws SQLException { 1215 return DatabaseProperties.doesMaxRowSizeIncludeBlobs; 1216 } 1217 1218 1225 public int getMaxStatementLength() throws SQLException { 1226 return DatabaseProperties.maxStatementLength; 1227 } 1228 1229 1237 public int getMaxStatements() throws SQLException { 1238 return DatabaseProperties.maxStatements; 1239 } 1240 1241 1248 public int getMaxTableNameLength() throws SQLException { 1249 return DatabaseProperties.maxTableNameLength; 1250 } 1251 1252 1259 public int getMaxTablesInSelect() throws SQLException { 1260 return DatabaseProperties.maxTablesInSelect; 1261 } 1262 1263 1270 public int getMaxUserNameLength() throws SQLException { 1271 return DatabaseProperties.maxUserNameLength; 1272 } 1273 1274 1275 1283 public int getDefaultTransactionIsolation() throws SQLException { 1284 return DatabaseProperties.defaultTransactionIsolation; 1285 } 1286 1287 1295 public boolean supportsTransactions() throws SQLException { 1296 return DatabaseProperties.supportsTransactions; 1297 } 1298 1299 1307 public boolean supportsTransactionIsolationLevel(int level) throws 1308 SQLException { 1309 return DatabaseProperties.supportsTransactionIsolationLevel(level); 1310 } 1311 1312 1319 public boolean supportsDataDefinitionAndDataManipulationTransactions() throws 1320 SQLException { 1321 return DatabaseProperties. 1322 supportsDataDefinitionAndDataManipulationTransactions; 1323 } 1324 1325 1332 public boolean supportsDataManipulationTransactionsOnly() throws SQLException { 1333 return DatabaseProperties.supportsDataManipulationTransactionsOnly; 1334 } 1335 1336 1343 public boolean dataDefinitionCausesTransactionCommit() throws SQLException { 1344 return DatabaseProperties.dataDefinitionCausesTransactionCommit; 1345 } 1346 1347 1353 public boolean dataDefinitionIgnoredInTransactions() throws SQLException { 1354 return DatabaseProperties.dataDefinitionIgnoredInTransactions; 1355 } 1356 1357 1392 1393 public ResultSet getProcedures(String catalog, String schemaPattern, 1394 String procedureNamePattern) throws 1395 SQLException { 1396 String query = DatabaseProperties.getProceduresQuery(catalog, schemaPattern, 1397 procedureNamePattern); 1398 return getTempResultSetForProcedures(query); 1399 } 1400 1401 1408 1415 1422 1480 1481 public ResultSet getProcedureColumns(String catalog, String schemaPattern, 1482 String procedureNamePattern, 1483 String columnNamePattern) throws 1484 SQLException { 1485 String query = DatabaseProperties.getProcedureColumnsQuery(catalog, 1486 schemaPattern, procedureNamePattern, columnNamePattern); 1487 return getTempResultSetForProcedureColumns(query); 1488 } 1489 1490 1497 1504 1511 1518 1525 1532 1539 1546 1554 1586 public ResultSet getTables(String catalog, String schemaPattern, 1587 String tableNamePattern, String types[]) throws 1588 SQLException { 1589 String query = DatabaseProperties.getTablesQuery(catalog, 1590 schemaPattern, tableNamePattern, types); 1591 return getTempResultSetForTables(query); 1592 } 1593 1594 1608 1609 public ResultSet getSchemas() throws SQLException { 1610 String query = DatabaseProperties.getSchemasQuery(); 1611 return getTempResultSetForSchemas(query); 1612 } 1613 1614 1628 1629 public ResultSet getCatalogs() throws SQLException { 1630 String query = DatabaseProperties.getCatalogsQuery(); 1631 return getTempResultSetForCatalogs(query); 1632 } 1633 1634 1650 1651 public ResultSet getTableTypes() throws SQLException { 1652 try { 1653 String [] columnNames = new String [] { 1654 "TABLE_TYPE"}; 1655 Object [][] metaData = new Object [1][20]; 1656 metaData[0][0] = null; 1657 metaData[0][1] = null; 1658 metaData[0][2] = null; 1659 metaData[0][3] = "TABLE_TYPE"; 1660 metaData[0][4] = new Integer (Types.VARCHAR); 1661 metaData[0][5] = "TABLE_TYPE"; 1662 metaData[0][6] = new Integer (Utilities.getPrecision(Types.VARCHAR)); 1663 metaData[0][7] = null; 1664 metaData[0][8] = new Integer ("TABLE_TYPE".length()); 1665 metaData[0][9] = "java.lang.String"; 1666 metaData[0][10] = Utilities.getCorrespondingJavaClassesOfSqlTypes(Types. 1667 VARCHAR); 1668 metaData[0][11] = Utilities.getBooleanValue(false); 1669 metaData[0][12] = Utilities.getBooleanValue(false); 1670 metaData[0][13] = Utilities.getBooleanValue(false); 1671 metaData[0][14] = Utilities.getBooleanValue(false); 1672 metaData[0][15] = Utilities.getBooleanValue(false); 1673 metaData[0][16] = Utilities.getBooleanValue(true); 1674 metaData[0][17] = Utilities.getBooleanValue(true); 1675 metaData[0][18] = Utilities.getBooleanValue(true); 1676 metaData[0][19] = new Integer (ResultSetMetaData.columnNullableUnknown); 1677 TempResultSetMetaData resultSetMetaData = new TempResultSetMetaData( 1678 metaData); 1679 String [] tableTypes = DatabaseProperties.getTableTypes(); 1680 int length = tableTypes.length; 1681 Object [][] values = new Object [length][1]; 1682 for (int i = 0; i < length; i++) 1683 values[i][0] = tableTypes[i]; 1684 TempResultSet resultSet = new TempResultSet(values, columnNames); 1685 resultSet.setConnection(systemConnection); 1686 resultSet.setMetaData(resultSetMetaData); 1687 return resultSet; 1688 } 1689 catch (DException de) { 1690 throw de.getSqlException(systemConnection.getLocale()); 1691 } 1692 } 1693 1694 1747 1748 public ResultSet getColumns(String catalog, String schemaPattern, 1749 String tableNamePattern, String columnNamePattern) throws 1750 SQLException { 1751 String query = DatabaseProperties.getColumnsQuery(catalog, schemaPattern, 1752 tableNamePattern, columnNamePattern); 1753 return getTempResultSetForColumns(query); 1754 } 1755 1756 1810 1811 public ResultSet getColumnPrivileges(String catalog, String schema, 1812 String table, 1813 String columnNamePattern) throws 1814 SQLException { 1815 String query = DatabaseProperties.getColumnPrivilegesQuery(catalog, 1816 schema, table, columnNamePattern); 1817 Statement statement = systemConnection.createStatement(); 1818 return statement.executeQuery(query); 1819 } 1820 1821 1854 1855 public ResultSet getTablePrivileges(String catalog, String schemaPattern, 1856 String tableNamePattern) throws 1857 SQLException { 1858 String query = DatabaseProperties.getTablePrivilegesQuery(catalog, 1859 schemaPattern, tableNamePattern); 1860 Statement statement = systemConnection.createStatement(); 1861 return statement.executeQuery(query); 1862 } 1863 1864 1902 1903 public ResultSet getBestRowIdentifier(String catalog, String schema, 1904 String table, int scope, 1905 boolean nullable) throws SQLException { 1906 String query = DatabaseProperties.getBestRowIdentifierQuery(catalog, schema, 1907 table, scope, nullable); 1908 if (query == null) { 1909 DException dex = new DException("DSE16", 1910 new Object [] {"getBestRowIdentifier"}); 1911 } 1912 return getTempResultSetForBestRowIdentifier(query); 1913 } 1914 1915 1998 1999 public ResultSet getVersionColumns(String catalog, String schema, 2000 String table) throws SQLException { 2001 String query = DatabaseProperties.getVersionColumnsQuery(catalog, 2002 schema, table); 2003 if (query == null) { 2004 DException dex = new DException("DSE16", 2005 new Object [] {"getVersionColumns"}); 2006 } 2007 return getTempResultSetForVersionColumns(query); 2008 } 2009 2010 2057 2058 public ResultSet getPrimaryKeys(String catalog, String schema, 2059 String table) throws SQLException { 2060 String query = DatabaseProperties.getPrimaryKeysQuery(catalog, schema, 2061 table); 2062 return getTempResultSetForPrimaryKeys(query); 2063 } 2064 2065 2134 2135 public ResultSet getImportedKeys(String catalog, String schema, String table) throws 2136 SQLException { 2137 String query = DatabaseProperties.getImportedKeysQuery(catalog, schema, 2138 table); 2139 return getTempResultSetForImportedKeys(query); 2140 } 2141 2142 2305 2306 public ResultSet getExportedKeys(String catalog, String schema, 2307 String table) throws SQLException { 2308 String query = DatabaseProperties.getExportedKeysQuery(catalog, 2309 schema, table); 2310 return getTempResultSetForExportedKeys(query); 2311 } 2312 2313 2390 2391 public ResultSet getCrossReference(String primaryCatalog, 2392 String primarySchema, String primaryTable, 2393 String foreignCatalog, 2394 String foreignSchema, String foreignTable) throws 2395 SQLException { 2396 String query = DatabaseProperties.getCrossReferenceQuery(primaryCatalog, 2397 primarySchema, primaryTable, foreignCatalog, foreignSchema, 2398 foreignTable); 2399 return getTempResultSetForCrossReference(query); 2400 } 2401 2402 2449 2450 public ResultSet getTypeInfo() throws SQLException { 2451 try { 2452 String [] columnNames = new String [] { 2453 "TYPE_NAME", "DATA_TYPE", "PRECISION", "LITERAL_PREFIX", 2454 "LITERAL_SUFFIX", "CREATE_PARAMS", "NULLABLE", "CASE_SENSITIVE", 2455 "SEARCHABLE", "UNSIGNED_ATTRIBUTE", "FIXED_PREC_SCALE", 2456 "AUTO_INCREMENT", 2457 "LOCAL_TYPE_NAME", "MINIMUM_SCALE", "MAXIMUM_SCALE", "SQL_DATA_TYPE", 2458 "SQL_DATETIME_SUB", "NUM_PREC_RADIX"}; 2459 Object [][] typeInfo = DatabaseProperties.getTypeInfo(); 2460 for (int i = 0, size = typeInfo.length; i < size; i++) { 2461 Object [] currentTypeInfo = new Object [typeInfo[i].length + 2]; 2462 currentTypeInfo[0] = currentTypeInfo[1] = new Long (i + 1); 2463 System.arraycopy(typeInfo[i], 0, currentTypeInfo, 2, typeInfo[i].length); 2464 } 2465 int rowCount = columnNames.length; 2466 Object [][] metaData = new Object [rowCount][20]; 2467 for (int i = 0; i < columnNames.length; i++) { 2468 metaData[i][0] = null; 2469 metaData[i][1] = null; 2470 metaData[i][2] = null; 2471 metaData[i][3] = columnNames[i]; 2472 metaData[i][4] = new Integer (getColumnTypeForTypeInfo(i + 1)); 2473 metaData[i][5] = columnNames[i]; 2474 metaData[i][6] = new Integer (Utilities.getPrecision( 2475 getColumnTypeForTypeInfo(i + 1))); 2476 metaData[i][7] = null; 2477 metaData[i][8] = new Integer (columnNames[i].length()); 2478 metaData[i][9] = getColumnTypeForTypeInfo(i + 1) == Types.SMALLINT ? 2479 "java.lang.String" : "short"; 2480 metaData[i][10] = Utilities.getCorrespondingJavaClassesOfSqlTypes( 2481 getColumnTypeForTypeInfo(i + 1)); 2482 metaData[i][11] = Utilities.getBooleanValue(false); 2483 metaData[i][12] = Utilities.getBooleanValue(false); 2484 metaData[i][13] = Utilities.getBooleanValue(false); 2485 metaData[i][14] = getColumnTypeForTypeInfo(i + 1) == Types.SMALLINT ? 2486 Utilities.getBooleanValue(true) : Utilities.getBooleanValue(false); 2487 metaData[i][15] = Utilities.getBooleanValue(false); 2488 metaData[i][16] = Utilities.getBooleanValue(true); 2489 metaData[i][17] = Utilities.getBooleanValue(true); 2490 metaData[i][18] = Utilities.getBooleanValue(true); 2491 metaData[i][19] = new Integer (ResultSetMetaData.columnNullableUnknown); 2492 } 2493 TempResultSetMetaData tempMetaData = new TempResultSetMetaData(metaData); 2494 TempResultSet resultSet = new TempResultSet(typeInfo, columnNames); 2495 resultSet.setConnection(systemConnection); 2496 resultSet.setMetaData(tempMetaData); 2497 return resultSet; 2498 } 2499 catch (DException dse) { 2500 throw dse.getSqlException(systemConnection.getLocale()); 2501 } 2502 } 2503 2504 private int getColumnTypeForTypeInfo(int index) throws SQLException { 2505 switch (index) { 2506 case 1: 2507 return Types.VARCHAR; 2508 case 2: 2509 return Types.SMALLINT; 2510 case 3: 2511 return Types.INTEGER; 2512 case 4: 2513 return Types.VARCHAR; 2514 case 5: 2515 return Types.VARCHAR; 2516 case 6: 2517 return Types.VARCHAR; 2518 case 7: 2519 return Types.SMALLINT; 2520 case 8: 2521 return 16; case 9: 2523 return Types.SMALLINT; 2524 case 10: 2525 return 16; case 11: 2527 return 16; case 12: 2529 return 16; case 13: 2531 return Types.VARCHAR; 2532 case 14: 2533 return Types.SMALLINT; 2534 case 15: 2535 return Types.SMALLINT; 2536 case 16: 2537 return Types.INTEGER; 2538 case 17: 2539 return Types.INTEGER; 2540 case 18: 2541 return Types.INTEGER; 2542 default: 2543 DException dex = new DException("DSE504", null); 2544 throw dex.getSqlException(systemConnection.getLocale()); 2545 } 2546 } 2547 2548 2657 2658 public ResultSet getIndexInfo(String catalog, String schema, 2659 String table, boolean unique, 2660 boolean approximate) throws SQLException { 2661 String query = DatabaseProperties.getIndexInfoQuery(catalog, schema, 2662 table, unique, approximate); 2663 if (query == null) { 2664 DException dex = new DException("DSE16", 2665 new Object [] {"getIndexInfo"}); 2666 } 2667 return getTempResultSetForIndexInfo(query); 2668 } 2669 2670 2711 public boolean supportsResultSetType(int type) throws SQLException { 2712 return DatabaseProperties.supportsResultSetType(type); 2713 } 2714 2715 2727 public boolean supportsResultSetConcurrency(int type, int concurrency) throws 2728 SQLException { 2729 return DatabaseProperties.supportsResultSetConcurrency(type, concurrency); 2730 } 2731 2732 2743 public boolean ownUpdatesAreVisible(int type) throws SQLException { 2744 return DatabaseProperties.ownUpdatesAreVisible(type); 2745 } 2746 2747 2758 public boolean ownDeletesAreVisible(int type) throws SQLException { 2759 return DatabaseProperties.ownDeletesAreVisible(type); 2760 } 2761 2762 2773 public boolean ownInsertsAreVisible(int type) throws SQLException { 2774 return DatabaseProperties.ownInsertsAreVisible(type); 2775 } 2776 2777 2789 public boolean othersUpdatesAreVisible(int type) throws SQLException { 2790 return DatabaseProperties.othersUpdatesAreVisible(type); 2791 } 2792 2793 2805 public boolean othersDeletesAreVisible(int type) throws SQLException { 2806 return DatabaseProperties.othersDeletesAreVisible(type); 2807 } 2808 2809 2822 public boolean othersInsertsAreVisible(int type) throws SQLException { 2823 return DatabaseProperties.othersInsertsAreVisible(type); 2824 } 2825 2826 2838 public boolean updatesAreDetected(int type) throws SQLException { 2839 return DatabaseProperties.updatesAreDetected(type); 2840 } 2841 2842 2854 public boolean deletesAreDetected(int type) throws SQLException { 2855 return DatabaseProperties.deletesAreDetected(type); 2856 } 2857 2858 2869 public boolean insertsAreDetected(int type) throws SQLException { 2870 return DatabaseProperties.insertsAreDetected(type); 2871 } 2872 2873 2880 public boolean supportsBatchUpdates() throws SQLException { 2881 return DatabaseProperties.supportsBatchUpdates; 2882 } 2883 2884 2924 public ResultSet getUDTs(String catalog, String schemaPattern, 2925 String typeNamePattern, int[] types) throws 2926 SQLException { 2927 try { 2928 String [] columnNames = new String [] { 2929 "TYPE_CAT", "TYPE_SCHEM", "TYPE_NAME", "CLASS_NAME", "DATA_TYPE", 2930 "REMARKS"}; 2931 int rowCount = columnNames.length; 2932 Object [][] metaData = new Object [rowCount][20]; 2933 for (int i = 0; i < columnNames.length; i++) { 2934 metaData[i][0] = null; 2935 metaData[i][1] = null; 2936 metaData[i][2] = null; 2937 metaData[i][3] = columnNames[i]; 2938 metaData[i][4] = new Integer (Types.VARCHAR); 2939 metaData[i][5] = columnNames[i]; 2940 metaData[i][6] = new Integer (Utilities.getPrecision(Types.VARCHAR)); 2941 metaData[i][7] = null; 2942 metaData[i][8] = new Integer (columnNames[i].length()); 2943 metaData[i][9] = "java.lang.String"; 2944 metaData[i][10] = "java.lang.String"; 2945 metaData[i][11] = Utilities.getBooleanValue(false); 2946 metaData[i][12] = Utilities.getBooleanValue(false); 2947 metaData[i][13] = Utilities.getBooleanValue(false); 2948 metaData[i][14] = Utilities.getBooleanValue(false); 2949 metaData[i][15] = Utilities.getBooleanValue(false); 2950 metaData[i][16] = Utilities.getBooleanValue(true); 2951 metaData[i][17] = Utilities.getBooleanValue(true); 2952 metaData[i][18] = Utilities.getBooleanValue(true); 2953 metaData[i][19] = new Integer (ResultSetMetaData.columnNullableUnknown); 2954 } 2955 TempResultSetMetaData tempMetaData = new TempResultSetMetaData(metaData); 2956 TempResultSet resultSet = new TempResultSet(new Object [0][0], columnNames); 2957 resultSet.setConnection(systemConnection); 2958 resultSet.setMetaData(tempMetaData); 2959 return resultSet; 2960 } 2961 catch (DException dxe) { 2962 throw dxe.getSqlException(systemConnection.getLocale()); 2963 } 2964 } 2965 2966 2967 2975 public boolean supportsSavepoints() throws SQLException { 2976 DException dex = new DException("DSE16", new Object [] {"supportsSavepoints"}); 2977 throw dex.getSqlException(systemConnection.getLocale()); 2978 } 2979 2980 2988 2989 public boolean supportsNamedParameters() throws SQLException { 2990 DException dex = new DException("DSE16", 2991 new Object [] {"supportsNamedParameters"}); 2992 throw dex.getSqlException(systemConnection.getLocale()); 2993 } 2994 2995 3006 public boolean supportsMultipleOpenResults() throws SQLException { 3007 DException dex = new DException("DSE16", 3008 new Object [] {"supportsMultipleOpenResults"}); 3009 throw dex.getSqlException(systemConnection.getLocale()); 3010 } 3011 3012 3021 public boolean supportsGetGeneratedKeys() throws SQLException { 3022 DException dex = new DException("DSE16", 3023 new Object [] {"supportsGetGeneratedKeys"}); 3024 throw dex.getSqlException(systemConnection.getLocale()); 3025 } 3026 3027 3068 public ResultSet getSuperTypes(String catalog, String schemaPattern, 3069 String typeNamePattern) throws SQLException { 3070 DException dex = new DException("DSE16", new Object [] {"getSuperTypes"}); 3071 throw dex.getSqlException(systemConnection.getLocale()); 3072 } 3073 3074 3108 3109 public ResultSet getSuperTables(String catalog, String schemaPattern, 3110 String tableNamePattern) throws SQLException { 3111 DException dex = new DException("DSE16", new Object [] {"getSuperTables"}); 3112 throw dex.getSqlException(systemConnection.getLocale()); 3113 } 3114 3115 3122 short attributeNoNulls = 0; 3123 3124 3131 short attributeNullable = 1; 3132 3133 3141 short attributeNullableUnknown = 2; 3142 3143 3213 3214 public ResultSet getAttributes(String catalog, String schemaPattern, 3215 String typeNamePattern, 3216 String attributeNamePattern) throws 3217 SQLException { 3218 DException dex = new DException("DSE16", new Object [] {"getAttributes"}); 3219 throw dex.getSqlException(systemConnection.getLocale()); 3220 } 3221 3222 3233 public boolean supportResultSetHoldability(int holdability) throws 3234 SQLException { 3235 return false; 3236 } 3237 3238 public boolean supportsResultSetHoldability(int holdability) throws SQLException{ 3239 return false; 3240 } 3241 3242 3252 public int getResultSetHoldability() throws SQLException { 3253 return ResultSet.CLOSE_CURSORS_AT_COMMIT; 3254 } 3255 3256 3263 public int getDatabaseMajorVersion() throws SQLException { 3264 return DatabaseProperties.databaseMajorVersion; 3265 } 3266 3267 3274 public int getDatabaseMinorVersion() throws SQLException { 3275 return DatabaseProperties.databaseMinorVersion; 3276 } 3277 3278 3286 public int getJDBCMajorVersion() throws SQLException { 3287 return DatabaseProperties.JDBCMajorVersion; 3288 } 3289 3290 3298 public int getJDBCMinorVersion() throws SQLException { 3299 return DatabaseProperties.JDBCMinorVersion; 3300 } 3301 3302 3310 int sqlStateXOpen = 1; 3311 3312 3319 int sqlStateSQL99 = 2; 3320 3321 3330 public int getSQLStateType() throws SQLException { 3331 return sqlStateSQL99; 3332 } 3333 3334 3335 3398 3399 private ResultSet getTempResultSetForColumns(String query) throws 3400 SQLException { 3401 try { 3402 String [] columnNames = { 3403 "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", 3404 "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH", 3405 "DECIMAL_DIGITS", "NUM_PREC_RADIX", 3406 "NULLABLE", "REMARKS", "COLUMN_DEF", "SQL_DATA_TYPE", 3407 "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH", 3408 "ORDINAL_POSITION", "IS_NULLABLE"}; 3409 _RecordSetBuffer recordSetBuffer = (_RecordSetBuffer) getRecordSetBuffer( 3410 query); 3411 _RecordSetBufferIterator iterator = recordSetBuffer.getIterator(); 3412 ArrayList arr = new ArrayList(); 3413 if (iterator.top()) { 3414 do { 3415 Object [] objs = new Object [columnNames.length]; 3416 _Record record = iterator.getRecord(); 3417 int j = 0; 3418 for (; j < 4; j++) 3419 objs[j] = record.getColumnValue(COLUMN_OFFSET + j); 3420 objs[5] = record.getColumnValue(COLUMN_OFFSET + 4); 3421 objs[4] = new Short ( (short) Utilities. 3422 getCorrespondingSqlTypeOfDatabaseType(Utilities. 3423 getDataBaseType( (String ) objs[5]))); 3424 Object characterLengthObj = record.getColumnValue(COLUMN_OFFSET + 8); 3425 int characterLength = characterLengthObj == null ? 0 : 3426 characterLengthObj.hashCode(); 3427 Integer i12 = (Integer ) record.getColumnValue(COLUMN_OFFSET + 12); 3428 Integer i13 = (Integer ) record.getColumnValue(COLUMN_OFFSET + 13); 3429 Integer i14 = (Integer ) record.getColumnValue(COLUMN_OFFSET + 14); 3430 objs[6] = new Integer (getColumnSize(characterLength, 3431 i12 == null ? 0 : i12.intValue(), 3432 i13 == null ? 0 : i13.intValue(), 3433 i14 == null ? 0 : i14.intValue())); 3434 objs[7] = null; objs[8] = record.getColumnValue(COLUMN_OFFSET + 5); objs[9] = record.getColumnValue(COLUMN_OFFSET + 6); objs[12] = record.getColumnValue(COLUMN_OFFSET + 7); 3438 objs[13] = new Integer ( ( (Short ) objs[4]).intValue()); objs[14] = new Integer (0); objs[15] = record.getColumnValue(COLUMN_OFFSET + 9); objs[11] = "null"; objs[16] = record.getColumnValue(COLUMN_OFFSET + 10); objs[17] = record.getColumnValue(COLUMN_OFFSET + 11); objs[10] = new Integer (getNullablility( (String ) objs[17])); arr.add(objs); 3446 } 3447 while (iterator.next()); 3448 } 3449 Object [][] objs = (Object [][]) arr.toArray(new Object [arr.size()][]); 3450 int count = columnNames.length; 3451 Object [][] metaData = new Object [count][20]; 3452 for (int i = 0; i < columnNames.length; i++) { 3453 metaData[i][0] = null; 3454 metaData[i][1] = null; 3455 metaData[i][2] = null; 3456 metaData[i][3] = columnNames[i]; 3457 metaData[i][4] = new Integer (getColumnTypeForColumns(i + 1)); 3458 metaData[i][5] = columnNames[i]; 3459 metaData[i][6] = new Integer (Utilities.getPrecision( 3460 getColumnTypeForColumns(i + 1))); 3461 metaData[i][7] = null; 3462 metaData[i][8] = new Integer (columnNames[i].length()); 3463 metaData[i][9] = getColumnTypeForColumns(i + 1) == Types.SMALLINT ? 3464 "java.lang.String" : "short"; 3465 metaData[i][10] = Utilities.getCorrespondingJavaClassesOfSqlTypes( 3466 getColumnTypeForColumns(i + 1)); 3467 metaData[i][11] = Utilities.getBooleanValue(false); 3468 metaData[i][12] = Utilities.getBooleanValue(false); 3469 metaData[i][13] = Utilities.getBooleanValue(false); 3470 metaData[i][14] = getColumnTypeForColumns(i + 1) == Types.SMALLINT ? 3471 Utilities.getBooleanValue(true) : Utilities.getBooleanValue(false); 3472 metaData[i][15] = Utilities.getBooleanValue(false); 3473 metaData[i][16] = Utilities.getBooleanValue(true); 3474 metaData[i][17] = Utilities.getBooleanValue(true); 3475 metaData[i][18] = Utilities.getBooleanValue(true); 3476 metaData[i][19] = new Integer (ResultSetMetaData.columnNullableUnknown); 3477 } 3478 TempResultSetMetaData tempMetaData = new TempResultSetMetaData(metaData); 3479 TempResultSet resultSet = new TempResultSet(objs, columnNames); 3480 resultSet.setConnection(systemConnection); 3481 resultSet.setMetaData(tempMetaData); 3482 return resultSet; 3483 } 3484 catch (DException e) { 3485 throw e.getSqlException(systemConnection.getLocale()); 3486 } 3487 } 3488 3489 3490 private int getNullablility(String nullable) { 3491 if (nullable.equalsIgnoreCase("yes")) 3492 return columnNullable; 3493 if (nullable.equalsIgnoreCase("no")) 3494 return columnNoNulls; 3495 return columnNullableUnknown; 3496 } 3497 3498 private int getColumnTypeForColumns(int index) throws SQLException { 3499 switch (index) { 3500 case 1: 3501 return Types.VARCHAR; 3502 case 2: 3503 return Types.VARCHAR; 3504 case 3: 3505 return Types.VARCHAR; 3506 case 4: 3507 return Types.VARCHAR; 3508 case 5: 3509 return Types.SMALLINT; 3510 case 6: 3511 return Types.VARCHAR; 3512 case 7: 3513 return Types.INTEGER; 3514 case 8: 3515 return Types.NULL; 3516 case 9: 3517 return Types.INTEGER; 3518 case 10: 3519 return Types.INTEGER; 3520 case 11: 3521 return Types.INTEGER; 3522 case 12: 3523 return Types.VARCHAR; 3524 case 13: 3525 return Types.VARCHAR; 3526 case 14: 3527 return Types.INTEGER; 3528 case 15: 3529 return Types.INTEGER; 3530 case 16: 3531 return Types.INTEGER; 3532 case 17: 3533 return Types.INTEGER; 3534 case 18: 3535 return Types.VARCHAR; 3536 default: 3537 DException dex = new DException("DSE504", null); 3538 throw dex.getSqlException(systemConnection.getLocale()); 3539 } 3540 } 3541 3542 private int getColumnSize(int charLength, int numPrecision, 3543 int datePrecision, int intervalPrecision) { 3544 return charLength != 0 ? charLength 3545 : numPrecision != 0 ? numPrecision 3546 : datePrecision != 0 ? datePrecision 3547 : intervalPrecision; 3548 } 3549 3550 3566 private ResultSet getTempResultSetForTables(String query) throws SQLException { 3567 Statement statement = systemConnection.createStatement(); 3568 return statement.executeQuery(query); 3569 } 3570 3571 3577 3578 private ResultSet getTempResultSetForSchemas(String query) throws 3579 SQLException { 3580 Statement statement = systemConnection.createStatement(); 3581 return statement.executeQuery(query); 3582 } 3583 3584 3590 3591 private ResultSet getTempResultSetForCatalogs(String query) throws 3592 SQLException { 3593 Statement statement = systemConnection.createStatement(); 3594 return statement.executeQuery(query); 3595 } 3596 3597 3619 private ResultSet getTempResultSetForProcedures(String query) throws 3620 SQLException { 3621 Statement statement = systemConnection.createStatement(); 3622 return statement.executeQuery(query); 3623 } 3624 3625 3669 private ResultSet getTempResultSetForProcedureColumns(String query) throws 3670 SQLException { 3671 String [] columnNames = new String [] { 3672 "PROCEDURE_CAT", "PROCEDURE_SCHEM", "PROCEDURE_NAME", "COLUMN_NAME", 3673 "COLUMN_TYPE", "DATA_TYPE", "TYPE_NAME", "PRECISION", "LENGTH", 3674 "SCALE", "RADIX", "NULLABLE", "REMARKS"}; 3675 TempResultSet resultSet = null; 3676 ArrayList arr = new ArrayList(); 3677 3692 Object [][] objs = (Object [][]) arr.toArray(new Object [arr.size()][]); 3693 int rowCount = columnNames.length; 3694 Object [][] metaData = new Object [rowCount][20]; 3695 try { 3696 for (int i = 0; i < columnNames.length; i++) { 3697 metaData[i][0] = null; 3698 metaData[i][1] = null; 3699 metaData[i][2] = null; 3700 metaData[i][3] = columnNames[i]; 3701 metaData[i][4] = new Integer (getColumnTypeForProcedureColumns(i + 1)); 3702 metaData[i][5] = columnNames[i]; 3703 metaData[i][6] = new Integer (Utilities.getPrecision( 3704 getColumnTypeForProcedureColumns(i + 1))); 3705 metaData[i][7] = null; 3706 metaData[i][8] = new Integer (columnNames[i].length()); 3707 metaData[i][9] = getColumnTypeForProcedureColumns(i + 1) == 3708 Types.SMALLINT ? "short" : "java.lang.String"; metaData[i][10] = Utilities.getCorrespondingJavaClassesOfSqlTypes( 3710 getColumnTypeForProcedureColumns(i + 1)); 3711 metaData[i][11] = Utilities.getBooleanValue(false); 3712 metaData[i][12] = Utilities.getBooleanValue(false); 3713 metaData[i][13] = Utilities.getBooleanValue(false); 3714 metaData[i][14] = getColumnTypeForProcedureColumns(i + 1) == 3715 Types.SMALLINT ? Utilities.getBooleanValue(true) : Utilities.getBooleanValue(false); 3716 metaData[i][15] = Utilities.getBooleanValue(false); 3717 metaData[i][16] = Utilities.getBooleanValue(true); 3718 metaData[i][17] = Utilities.getBooleanValue(true); 3719 metaData[i][18] = Utilities.getBooleanValue(true); 3720 metaData[i][19] = new Integer (ResultSetMetaData.columnNullableUnknown); 3721 } 3722 TempResultSetMetaData tempMetaData = new TempResultSetMetaData(metaData); 3723 resultSet = new TempResultSet(objs, columnNames); 3724 resultSet.setConnection(systemConnection); 3725 resultSet.setMetaData(tempMetaData); 3726 return resultSet; 3727 } 3728 catch (DException des) { 3729 throw des.getSqlException(systemConnection.getLocale()); 3730 } 3731 } 3732 3733 private int getColumnTypeForProcedureColumns(int index) throws SQLException { 3734 switch (index) { 3735 case 1: 3736 return Types.VARCHAR; 3737 case 2: 3738 return Types.VARCHAR; 3739 case 3: 3740 return Types.VARCHAR; 3741 case 4: 3742 return Types.VARCHAR; 3743 case 5: 3744 return Types.SMALLINT; 3745 case 6: 3746 return Types.SMALLINT; 3747 case 7: 3748 return Types.VARCHAR; 3749 case 8: 3750 return Types.INTEGER; 3751 case 9: 3752 return Types.INTEGER; 3753 case 10: 3754 return Types.SMALLINT; 3755 case 11: 3756 return Types.SMALLINT; 3757 case 12: 3758 return Types.SMALLINT; 3759 case 13: 3760 return Types.VARCHAR; 3761 default: 3762 DException dex = new DException("DSE504", null); 3763 throw dex.getSqlException(systemConnection.getLocale()); 3764 } 3765 } 3766 3767 3816 private ResultSet getTempResultSetForIndexInfo(String query) throws 3817 SQLException { 3818 String [] columnNames = new String [] { 3819 "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "NON_UNIQUE", 3820 "INDEX_QUALIFIER", "INDEX_NAME", "TYPE", "ORDINAL_POSITION", 3821 "COLUMN_NAME", 3822 "ASC_OR_DESC", "CARDINALITY", "PAGES", "FILTER_CONDITION"}; 3823 TempResultSet resultSet = null; 3824 _RecordSetBuffer recordSetBuffer = getRecordSetBuffer(query); 3825 _RecordSetBufferIterator iterator = recordSetBuffer.getIterator(); 3826 ArrayList arr = new ArrayList(); 3827 if (iterator.top()) { 3828 do { 3829 _Record record = iterator.getRecord(); 3830 Object [] objs1 = new Object [13]; 3831 int j = 0; 3832 for (; j < 3; j++) 3833 objs1[j] = iterator.getColumnValue(COLUMN_OFFSET + j); 3834 objs1[j++] = Boolean.TRUE; 3835 objs1[j++] = null; 3836 objs1[j++] = iterator.getColumnValue(COLUMN_OFFSET + 3); 3837 objs1[j++] = new Short (tableIndexOther); 3838 objs1[j++] = new Short ( ( (Integer ) iterator.getColumnValue( 3839 COLUMN_OFFSET + 4)).shortValue()); 3840 objs1[j++] = iterator.getColumnValue(COLUMN_OFFSET + 5); 3841 objs1[j++] = iterator.getColumnValue(COLUMN_OFFSET + 3842 6).equals(Boolean.TRUE) ? "A" : "D"; 3843 objs1[j++] = null; 3844 objs1[j++] = null; 3845 objs1[j++] = null; 3846 arr.add(objs1); 3847 } 3848 while (iterator.next()); 3849 } 3850 Object [][] objs = (Object [][]) arr.toArray(new Object [arr.size()][]); 3851 int rowCount = columnNames.length; 3852 Object [][] metaData = new Object [rowCount][20]; 3853 try { 3854 for (int i = 0; i < columnNames.length; i++) { 3855 metaData[i][0] = null; 3856 metaData[i][1] = null; 3857 metaData[i][2] = null; 3858 metaData[i][3] = columnNames[i]; 3859 metaData[i][4] = new Integer (getColumnTypeForIndexInfo(i + 1)); 3860 metaData[i][5] = columnNames[i]; 3861 metaData[i][6] = new Integer (Utilities.getPrecision( 3862 getColumnTypeForProcedureColumns(i + 1))); 3863 metaData[i][7] = null; 3864 metaData[i][8] = new Integer (columnNames[i].length()); 3865 metaData[i][9] = getColumnTypeForIndexInfo(i + 1) == Types.SMALLINT ? 3866 "java.lang.String" : "short"; 3867 metaData[i][10] = Utilities.getCorrespondingJavaClassesOfSqlTypes( 3868 getColumnTypeForIndexInfo(i + 1)); 3869 metaData[i][11] = Utilities.getBooleanValue(false); 3870 metaData[i][12] = Utilities.getBooleanValue(false); 3871 metaData[i][13] = Utilities.getBooleanValue(false); 3872 metaData[i][14] = getColumnTypeForIndexInfo(i + 1) == Types.SMALLINT ? 3873 Utilities.getBooleanValue(true) : Utilities.getBooleanValue(false); 3874 metaData[i][15] = Utilities.getBooleanValue(false); 3875 metaData[i][16] = Utilities.getBooleanValue(true); 3876 metaData[i][17] = Utilities.getBooleanValue(true); 3877 metaData[i][18] = Utilities.getBooleanValue(true); 3878 metaData[i][19] = new Integer (ResultSetMetaData.columnNullableUnknown); 3879 } 3880 TempResultSetMetaData tempMetaData = new TempResultSetMetaData(metaData); 3881 resultSet = new TempResultSet(objs, columnNames); 3882 resultSet.setConnection(systemConnection); 3883 resultSet.setMetaData(tempMetaData); 3884 return resultSet; 3885 } 3886 catch (DException dse) { 3887 throw dse.getSqlException(systemConnection.getLocale()); 3888 } 3889 } 3890 3891 private int getColumnTypeForIndexInfo(int index) throws SQLException { 3892 switch (index) { 3893 case 1: 3894 return Types.VARCHAR; 3895 case 2: 3896 return Types.VARCHAR; 3897 case 3: 3898 return Types.VARCHAR; 3899 case 4: 3900 return Types.BIT; 3901 case 5: 3902 return Types.VARCHAR; 3903 case 6: 3904 return Types.VARCHAR; 3905 case 7: 3906 return Types.SMALLINT; 3907 case 8: 3908 return Types.SMALLINT; 3909 case 9: 3910 return Types.VARCHAR; 3911 case 10: 3912 return Types.VARCHAR; 3913 case 11: 3914 return Types.INTEGER; 3915 case 12: 3916 return Types.INTEGER; 3917 case 13: 3918 return Types.VARCHAR; 3919 default: 3920 DException dex = new DException("DSE504", null); 3921 throw dex.getSqlException(systemConnection.getLocale()); 3922 } 3923 } 3924 3925 3957 private ResultSet getTempResultSetForBestRowIdentifier(String query) throws 3958 SQLException { 3959 String [] columnNames = new String [] { 3960 "SCOPE", "COLUMN_NAME", "DATA_TYPE", 3961 "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH", "DECIMAL_DIGITS", 3962 "PSEUDO_COLUMN"}; 3963 TempResultSet resultSet = null; 3964 ArrayList arr = new ArrayList(); 3965 3980 Object [][] objs = (Object [][]) arr.toArray(new Object [arr.size()][]); 3981 resultSet = new TempResultSet(objs, columnNames); 3982 resultSet.setConnection(systemConnection); 3983 int rowCount = columnNames.length; 3984 Object [][] metaData = new Object [rowCount][20]; 3985 try { 3986 for (int i = 0; i < columnNames.length; i++) { 3987 metaData[i][0] = null; 3988 metaData[i][1] = null; 3989 metaData[i][2] = null; 3990 metaData[i][3] = columnNames[i]; 3991 metaData[i][4] = new Integer (getColumnTypeForBestRowIdentifier(i + 1)); 3992 metaData[i][5] = columnNames[i]; 3993 metaData[i][6] = new Integer (Utilities.getPrecision( 3994 getColumnTypeForBestRowIdentifier(i + 1))); 3995 metaData[i][7] = null; 3996 metaData[i][8] = new Integer (columnNames[i].length()); 3997 metaData[i][9] = getColumnTypeForBestRowIdentifier(i + 1) == 3998 Types.SMALLINT ? "java.lang.String" : "short"; 3999 metaData[i][10] = Utilities.getCorrespondingJavaClassesOfSqlTypes( 4000 getColumnTypeForBestRowIdentifier(i + 1)); 4001 metaData[i][11] = Utilities.getBooleanValue(false); 4002 metaData[i][12] = Utilities.getBooleanValue(false); 4003 metaData[i][13] = Utilities.getBooleanValue(false); 4004 metaData[i][14] = getColumnTypeForBestRowIdentifier(i + 1) == 4005 Types.SMALLINT ? Utilities.getBooleanValue(true) : Utilities.getBooleanValue(false); 4006 metaData[i][15] = Utilities.getBooleanValue(false); 4007 metaData[i][16] = Utilities.getBooleanValue(true); 4008 metaData[i][17] = Utilities.getBooleanValue(true); 4009 metaData[i][18] = Utilities.getBooleanValue(true); 4010 metaData[i][19] = new Integer (ResultSetMetaData.columnNullableUnknown); 4011 } 4012 TempResultSetMetaData tempMetaData = new TempResultSetMetaData(metaData); 4013 resultSet.setMetaData(tempMetaData); 4014 resultSet.setConnection(systemConnection); 4015 return resultSet; 4016 } 4017 catch (DException dse) { 4018 throw dse.getSqlException(systemConnection.getLocale()); 4019 } 4020 } 4021 4022 private int getColumnTypeForBestRowIdentifier(int index) throws SQLException { 4023 switch (index) { 4024 case 1: 4025 return Types.SMALLINT; 4026 case 2: 4027 return Types.VARCHAR; 4028 case 3: 4029 return Types.SMALLINT; 4030 case 4: 4031 return Types.VARCHAR; 4032 case 5: 4033 return Types.INTEGER; 4034 case 6: 4035 return Types.INTEGER; 4036 case 7: 4037 return Types.SMALLINT; 4038 case 8: 4039 return Types.SMALLINT; 4040 default: 4041 DException dex = new DException("DSE504", null); 4042 throw dex.getSqlException(systemConnection.getLocale()); 4043 } 4044 } 4045 4046 private ResultSet getTempResultSetForUDTs(String query) throws SQLException { 4047 DException dex = new DException("DSE16", 4048 new Object [] {"getTempResultSetForUDTs"}); 4049 throw dex.getSqlException(systemConnection.getLocale()); 4050 } 4051 4052 4119 4120 private ResultSet getTempResultSetForCrossReference(String query) throws 4121 SQLException { 4122 String [] columnNames = new String [] { 4123 "PKTABLE_CAT", "PKTABLE_SCHEM", "PKTABLE_NAME", 4124 "PKCOLUMN_NAME", "FKTABLE_CAT", "FKTABLE_SCHEM", "FKTABLE_NAME", 4125 "FKCOLUMN_NAME", 4126 "KEY_SEQ", "UPDATE_RULE", "DELETE_RULE", "FK_NAME", "PK_NAME", 4127 "DEFERRABILITY"}; 4128 _RecordSetBuffer recordSetBuffer = getRecordSetBuffer(query); 4129 _RecordSetBufferIterator iterator = recordSetBuffer.getIterator(); 4130 ArrayList arr = new ArrayList(); 4131 if (iterator.top()) { 4132 do { 4133 Object [] objs = new Object [14]; 4134 _Record record = iterator.getRecord(); 4135 int j = 0; 4136 for (; j < 9; j++) 4137 objs[j] = iterator.getColumnValue(COLUMN_OFFSET + j); 4138 objs[j++] = new Short ( (short) getUpdateDeleteRule( (String ) iterator. 4139 getColumnValue(COLUMN_OFFSET + 9))); 4140 objs[j++] = new Short ( (short) getUpdateDeleteRule( (String ) iterator. 4141 getColumnValue(COLUMN_OFFSET + 10))); 4142 objs[j++] = iterator.getColumnValue(COLUMN_OFFSET + 11); 4143 objs[j++] = iterator.getColumnValue(COLUMN_OFFSET + 12); 4144 objs[j++] = new Short ( (short) getDeferrability( (String ) iterator. 4145 getColumnValue(COLUMN_OFFSET + 13), 4146 (String ) iterator.getColumnValue(14))); 4147 arr.add(objs); 4148 } 4149 while (iterator.next()); 4150 } 4151 Object [][] objs = (Object [][]) arr.toArray(new Object [arr.size()][]); 4152 int rowCount = columnNames.length; 4153 Object [][] metaData = new Object [rowCount][20]; 4154 try { 4155 for (int i = 0; i < rowCount; i++) { 4156 metaData[i][0] = null; 4157 metaData[i][1] = null; 4158 metaData[i][2] = null; 4159 metaData[i][3] = columnNames[i]; 4160 metaData[i][4] = new Integer (getColumnTypeForCrossReference(i + 1)); 4161 metaData[i][5] = columnNames[i]; 4162 metaData[i][6] = new Integer (Utilities.getPrecision( 4163 getColumnTypeForCrossReference(i + 1))); 4164 metaData[i][7] = null; 4165 metaData[i][8] = new Integer (columnNames[i].length()); 4166 metaData[i][9] = getColumnTypeForCrossReference(i + 1) == 4167 Types.SMALLINT ? "java.lang.String" : "short"; 4168 metaData[i][10] = Utilities.getCorrespondingJavaClassesOfSqlTypes( 4169 getColumnTypeForCrossReference(i + 1)); 4170 metaData[i][11] = Utilities.getBooleanValue(false); 4171 metaData[i][12] = Utilities.getBooleanValue(false); 4172 metaData[i][13] = Utilities.getBooleanValue(false); 4173 metaData[i][14] = getColumnTypeForCrossReference(i + 1) == 4174 Types.SMALLINT ? Utilities.getBooleanValue(true) : Utilities.getBooleanValue(false); 4175 metaData[i][15] = Utilities.getBooleanValue(false); 4176 metaData[i][16] = Utilities.getBooleanValue(true); 4177 metaData[i][17] = Utilities.getBooleanValue(true); 4178 metaData[i][18] = Utilities.getBooleanValue(true); 4179 metaData[i][19] = new Integer (ResultSetMetaData.columnNullableUnknown); 4180 } 4181 TempResultSetMetaData tempMetaData = new TempResultSetMetaData(metaData); 4182 TempResultSet resultSet = new TempResultSet(objs, columnNames); 4183 resultSet.setConnection(systemConnection); 4184 resultSet.setMetaData(tempMetaData); 4185 return resultSet; 4186 } 4187 catch (DException dse) { 4188 throw dse.getSqlException(systemConnection.getLocale()); 4189 } 4190 } 4191 4192 private int getColumnTypeForCrossReference(int index) throws SQLException { 4193 switch (index) { 4194 case 1: 4195 return Types.VARCHAR; 4196 case 2: 4197 return Types.VARCHAR; 4198 case 3: 4199 return Types.VARCHAR; 4200 case 4: 4201 return Types.VARCHAR; 4202 case 5: 4203 return Types.VARCHAR; 4204 case 6: 4205 return Types.VARCHAR; 4206 case 7: 4207 return Types.VARCHAR; 4208 case 8: 4209 return Types.VARCHAR; 4210 case 9: 4211 return Types.SMALLINT; 4212 case 10: 4213 return Types.SMALLINT; 4214 case 11: 4215 return Types.SMALLINT; 4216 case 12: 4217 return Types.VARCHAR; 4218 case 13: 4219 return Types.VARCHAR; 4220 case 14: 4221 return Types.SMALLINT; 4222 default: 4223 DException dex = new DException("DSE504", null); 4224 throw dex.getSqlException(systemConnection.getLocale()); 4225 } 4226 } 4227 4228 public int getDeferrability(String deferrability, String initiallyDeferrable) { 4229 if (deferrability.equalsIgnoreCase("no")) 4230 return importedKeyNotDeferrable; 4231 return initiallyDeferrable.equalsIgnoreCase("yes") ? 4232 importedKeyInitiallyDeferred 4233 : importedKeyInitiallyImmediate; 4234 } 4235 4236 private int getUpdateDeleteRule(String OnUpdateDelete) { 4237 if (OnUpdateDelete.equalsIgnoreCase("no action")) 4238 return importedKeyNoAction; 4239 if (OnUpdateDelete.equalsIgnoreCase("cascade")) 4240 return importedKeyCascade; 4241 if (OnUpdateDelete.equalsIgnoreCase("set null")) 4242 return importedKeySetDefault; 4243 if (OnUpdateDelete.equalsIgnoreCase("restrict")) 4244 return importedKeyRestrict; 4245 return importedKeySetDefault; 4246 } 4247 4248 4251 4252 private ResultSet getTempResultSetForImportedKeys(String query) throws 4253 SQLException { 4254 return getTempResultSetForCrossReference(query); 4255 } 4256 4257 4260 4261 private ResultSet getTempResultSetForExportedKeys(String query) throws 4262 SQLException { 4263 return getTempResultSetForCrossReference(query); 4264 } 4265 4266 4282 private ResultSet getTempResultSetForPrimaryKeys(String query) throws 4283 SQLException { 4284 Statement statement = systemConnection.createStatement(); 4285 return statement.executeQuery(query); 4286 } 4287 4288 4314 private ResultSet getTempResultSetForVersionColumns(String query) throws 4315 SQLException { 4316 String [] columnNames = new String [] { 4317 "SCOPE", "COLUMN_NAME", "DATA_TYPE", "TYPE_NAME", 4318 "COLUMN_SIZE", "BUFFER_LENGTH", "DECIMAL_DIGITS", "PSEUDO_COLUMN"}; 4319 TempResultSet resultSet = null; 4320 ArrayList arr = new ArrayList(); 4321 4336 Object [][] objs = (Object [][]) arr.toArray(new Object [arr.size()][]); 4337 int rowCount = columnNames.length; 4338 Object [][] metaData = new Object [rowCount][20]; 4339 try { 4340 for (int i = 0; i < columnNames.length; i++) { 4341 metaData[i][0] = null; 4342 metaData[i][1] = null; 4343 metaData[i][2] = null; 4344 metaData[i][3] = columnNames[i]; 4345 metaData[i][4] = new Integer (getColumnTypeForVersionColumns(i + 1)); 4346 metaData[i][5] = columnNames[i]; 4347 metaData[i][6] = new Integer (Utilities.getPrecision( 4348 getColumnTypeForVersionColumns(i + 1))); 4349 metaData[i][7] = null; 4350 metaData[i][8] = new Integer (columnNames[i].length()); 4351 metaData[i][9] = getColumnTypeForVersionColumns(i + 1) == 4352 Types.SMALLINT ? "java.lang.String" : "short"; 4353 metaData[i][10] = Utilities.getCorrespondingJavaClassesOfSqlTypes( 4354 getColumnTypeForVersionColumns(i + 1)); 4355 metaData[i][11] = Utilities.getBooleanValue(false); 4356 metaData[i][12] = Utilities.getBooleanValue(false); 4357 metaData[i][13] = Utilities.getBooleanValue(false); 4358 metaData[i][14] = getColumnTypeForVersionColumns(i + 1) == 4359 Types.SMALLINT ? Utilities.getBooleanValue(true) : Utilities.getBooleanValue(false); 4360 metaData[i][15] = Utilities.getBooleanValue(false); 4361 metaData[i][16] = Utilities.getBooleanValue(true); 4362 metaData[i][17] = Utilities.getBooleanValue(true); 4363 metaData[i][18] = Utilities.getBooleanValue(true); 4364 metaData[i][19] = new Integer (ResultSetMetaData.columnNullableUnknown); 4365 } 4366 TempResultSetMetaData tempMetaData = new TempResultSetMetaData(metaData); 4367 resultSet = new TempResultSet(objs, columnNames); 4368 resultSet.setConnection(systemConnection); 4369 resultSet.setMetaData(tempMetaData); 4370 return resultSet; 4371 } 4372 catch (DException e) { 4373 throw e.getSqlException(systemConnection.getLocale()); 4374 } 4375 } 4376 4377 private int getColumnTypeForVersionColumns(int index) throws SQLException { 4378 switch (index) { 4379 case 1: 4380 return Types.SMALLINT; 4381 case 2: 4382 return Types.VARCHAR; 4383 case 3: 4384 return Types.SMALLINT; 4385 case 4: 4386 return Types.VARCHAR; 4387 case 5: 4388 return Types.INTEGER; 4389 case 6: 4390 return Types.INTEGER; 4391 case 7: 4392 return Types.SMALLINT; 4393 case 8: 4394 return Types.SMALLINT; 4395 default: 4396 DException dex = new DException("DSE504", null); 4397 throw dex.getSqlException(systemConnection.getLocale()); 4398 } 4399 } 4400 4401 private _RecordSetBuffer getRecordSetBuffer(String query) throws SQLException { 4402 try { 4403 Object obj = DaffodilDBStatement.getRequiredObjectOfexecute(systemConnection. 4404 getServerConnection().executeQuery(query, 0,IteratorConstants.UPDATABLE), 4405 ResultSet.CONCUR_READ_ONLY,0)[0]; 4406 if (! (obj instanceof _RecordSetBuffer)) { 4407 DException dex = new DException("DSE531", null); 4408 throw dex.getSqlException(systemConnection.getLocale()); 4409 } 4410 return (_RecordSetBuffer) obj; 4411 } 4412 catch (NullPointerException npe) { 4413 throw npe; 4414 } 4415 catch (DException e) { 4416 throw e.getSqlException(systemConnection.getLocale()); 4417 } 4418 } 4419 4420 public boolean locatorsUpdateCopy() throws SQLException { 4421 4422 throw new java.lang.UnsupportedOperationException ( 4423 "Method locatorsUpdateCopy() not yet implemented."); 4424 } 4425 4426 public boolean supportsStatementPooling() throws SQLException { 4427 4428 throw new java.lang.UnsupportedOperationException ( 4429 "Method supportsStatementPooling() not yet implemented."); 4430 } 4431} 4432 | Popular Tags |