1 21 22 package org.apache.derby.client.am; 23 24 import java.sql.SQLException ; 25 26 import org.apache.derby.jdbc.ClientDataSource; 27 import org.apache.derby.shared.common.reference.SQLState; 28 import org.apache.derby.shared.common.reference.JDBC30Translation; 29 30 45 public abstract class DatabaseMetaData implements java.sql.DatabaseMetaData { 46 48 private final static short SQL_BEST_ROWID = 1; 49 private final static short SQL_ROWVER = 2; 50 51 private final static short SQL_INDEX_UNIQUE = 0; 52 private final static short SQL_INDEX_ALL = 1; 53 54 56 protected Agent agent_; 57 protected Connection connection_; 58 59 61 private final static int numberOfMetaDataInfoMethods__ = 108; 62 private Object [] metaDataInfoCache_ = new Object [numberOfMetaDataInfoMethods__]; 63 private boolean metaDataInfoIsCached_ = false; 64 65 public ProductLevel productLevel_; 66 67 68 private final int serverJdbcMajorVersion; 69 70 private final int serverJdbcMinorVersion; 71 72 public boolean useServerXAState_ = true; 73 74 76 protected DatabaseMetaData(Agent agent, Connection connection, ProductLevel productLevel) { 77 agent_ = agent; 78 connection_ = connection; 79 productLevel_ = productLevel; 80 computeFeatureSet_(); 81 if (connection.isXAConnection()) { 82 connection.xaHostVersion_ = productLevel_.versionLevel_; 83 } 84 if (productLevel_.lessThan(10, 2, 0)) { 85 serverJdbcMajorVersion = 3; 86 serverJdbcMinorVersion = 0; 87 } else { 88 serverJdbcMajorVersion = 4; 89 serverJdbcMinorVersion = 0; 90 } 91 } 92 93 95 98 private final static int allProceduresAreCallable__ = 0; 99 100 public boolean allProceduresAreCallable() throws SQLException { 101 checkForClosedConnection(); 102 return getMetaDataInfoBoolean(allProceduresAreCallable__); 103 } 104 105 private final static int allTablesAreSelectable__ = 1; 106 107 public boolean allTablesAreSelectable() throws SQLException { 108 checkForClosedConnection(); 109 return getMetaDataInfoBoolean(allTablesAreSelectable__); 110 } 111 112 private final static int nullsAreSortedHigh__ = 2; 113 114 public boolean nullsAreSortedHigh() throws SQLException { 115 checkForClosedConnection(); 116 return getMetaDataInfoBoolean(nullsAreSortedHigh__); 117 } 118 119 private final static int nullsAreSortedLow__ = 3; 120 121 public boolean nullsAreSortedLow() throws SQLException { 122 checkForClosedConnection(); 123 return getMetaDataInfoBoolean(nullsAreSortedLow__); 124 } 125 126 private final static int nullsAreSortedAtStart__ = 4; 127 128 public boolean nullsAreSortedAtStart() throws SQLException { 129 checkForClosedConnection(); 130 return getMetaDataInfoBoolean(nullsAreSortedAtStart__); 131 } 132 133 private final static int nullsAreSortedAtEnd__ = 5; 134 135 public boolean nullsAreSortedAtEnd() throws SQLException { 136 checkForClosedConnection(); 137 return getMetaDataInfoBoolean(nullsAreSortedAtEnd__); 138 } 139 140 private final static int usesLocalFiles__ = 6; 141 142 public boolean usesLocalFiles() throws SQLException { 143 checkForClosedConnection(); 144 return getMetaDataInfoBoolean(usesLocalFiles__); 145 } 146 147 private final static int usesLocalFilePerTable__ = 7; 148 149 public boolean usesLocalFilePerTable() throws SQLException { 150 checkForClosedConnection(); 151 return getMetaDataInfoBoolean(usesLocalFilePerTable__); 152 } 153 154 private final static int storesUpperCaseIdentifiers__ = 8; 155 156 public boolean storesUpperCaseIdentifiers() throws SQLException { 157 checkForClosedConnection(); 158 return getMetaDataInfoBoolean(storesUpperCaseIdentifiers__); 159 } 160 161 162 private final static int storesLowerCaseIdentifiers__ = 9; 163 164 public boolean storesLowerCaseIdentifiers() throws SQLException { 165 checkForClosedConnection(); 166 return getMetaDataInfoBoolean(storesLowerCaseIdentifiers__); 167 } 168 169 private final static int storesMixedCaseIdentifiers__ = 10; 170 171 public boolean storesMixedCaseIdentifiers() throws SQLException { 172 checkForClosedConnection(); 173 return getMetaDataInfoBoolean(storesMixedCaseIdentifiers__); 174 } 175 176 private final static int storesUpperCaseQuotedIdentifiers__ = 11; 177 178 public boolean storesUpperCaseQuotedIdentifiers() throws SQLException { 179 checkForClosedConnection(); 180 return getMetaDataInfoBoolean(storesUpperCaseQuotedIdentifiers__); 181 } 182 183 private final static int storesLowerCaseQuotedIdentifiers__ = 12; 184 185 public boolean storesLowerCaseQuotedIdentifiers() throws SQLException { 186 checkForClosedConnection(); 187 return getMetaDataInfoBoolean(storesLowerCaseQuotedIdentifiers__); 188 } 189 190 private final static int storesMixedCaseQuotedIdentifiers__ = 13; 191 192 public boolean storesMixedCaseQuotedIdentifiers() throws SQLException { 193 checkForClosedConnection(); 194 return getMetaDataInfoBoolean(storesMixedCaseQuotedIdentifiers__); 195 } 196 197 private final static int getSQLKeywords__ = 14; 198 199 public String getSQLKeywords() throws SQLException { 200 checkForClosedConnection(); 201 return getMetaDataInfoString(getSQLKeywords__); 202 } 203 204 private final static int getNumericFunctions__ = 15; 205 206 public String getNumericFunctions() throws SQLException { 207 checkForClosedConnection(); 208 return getMetaDataInfoString(getNumericFunctions__); 209 } 210 211 private final static int getStringFunctions__ = 16; 212 213 public String getStringFunctions() throws SQLException { 214 checkForClosedConnection(); 215 return getMetaDataInfoString(getStringFunctions__); 216 } 217 218 private final static int getSystemFunctions__ = 17; 219 220 public String getSystemFunctions() throws SQLException { 221 checkForClosedConnection(); 222 return getMetaDataInfoString(getSystemFunctions__); 223 } 224 225 private final static int getTimeDateFunctions__ = 18; 226 227 public String getTimeDateFunctions() throws SQLException { 228 checkForClosedConnection(); 229 return getMetaDataInfoString(getTimeDateFunctions__); 230 } 231 232 private final static int getSearchStringEscape__ = 19; 233 234 public String getSearchStringEscape() throws SQLException { 235 checkForClosedConnection(); 236 return getMetaDataInfoString(getSearchStringEscape__); 237 } 238 239 private final static int getExtraNameCharacters__ = 20; 240 241 public String getExtraNameCharacters() throws SQLException { 242 checkForClosedConnection(); 243 return getMetaDataInfoString(getExtraNameCharacters__); 244 } 245 246 private final static int supportsAlterTableWithAddColumn__ = 21; 247 248 public boolean supportsAlterTableWithAddColumn() throws SQLException { 249 checkForClosedConnection(); 250 return getMetaDataInfoBoolean(supportsAlterTableWithAddColumn__); 251 } 252 253 private final static int supportsAlterTableWithDropColumn__ = 22; 254 255 public boolean supportsAlterTableWithDropColumn() throws SQLException { 256 checkForClosedConnection(); 257 return getMetaDataInfoBoolean(supportsAlterTableWithDropColumn__); 258 } 259 260 private final static int supportsConvert__ = 23; 261 262 public boolean supportsConvert() throws SQLException { 263 checkForClosedConnection(); 264 return getMetaDataInfoBoolean(supportsConvert__); 265 } 266 267 private final static int supportsConvertType__ = 24; 268 269 public boolean supportsConvert(int fromType, int toType) throws SQLException { 270 checkForClosedConnection(); 271 return getMetaDataInfoBoolean_supportsConvert(supportsConvertType__, fromType, toType); 272 } 273 274 private final static int supportsDifferentTableCorrelationNames__ = 25; 275 276 public boolean supportsDifferentTableCorrelationNames() throws SQLException { 277 checkForClosedConnection(); 278 return getMetaDataInfoBoolean(supportsDifferentTableCorrelationNames__); 279 } 280 281 private final static int supportsExpressionsInOrderBy__ = 26; 282 283 public boolean supportsExpressionsInOrderBy() throws SQLException { 284 checkForClosedConnection(); 285 return getMetaDataInfoBoolean(supportsExpressionsInOrderBy__); 286 } 287 288 private final static int supportsOrderByUnrelated__ = 27; 289 290 public boolean supportsOrderByUnrelated() throws SQLException { 291 checkForClosedConnection(); 292 return getMetaDataInfoBoolean(supportsOrderByUnrelated__); 293 } 294 295 private final static int supportsGroupBy__ = 28; 296 297 public boolean supportsGroupBy() throws SQLException { 298 checkForClosedConnection(); 299 return getMetaDataInfoBoolean(supportsGroupBy__); 300 } 301 302 private final static int supportsGroupByUnrelated__ = 29; 303 304 public boolean supportsGroupByUnrelated() throws SQLException { 305 checkForClosedConnection(); 306 return getMetaDataInfoBoolean(supportsGroupByUnrelated__); 307 } 308 309 private final static int supportsGroupByBeyondSelect__ = 30; 310 311 public boolean supportsGroupByBeyondSelect() throws SQLException { 312 checkForClosedConnection(); 313 return getMetaDataInfoBoolean(supportsGroupByBeyondSelect__); 314 } 315 316 private final static int supportsMultipleResultSets__ = 31; 317 318 public boolean supportsMultipleResultSets() throws SQLException { 319 checkForClosedConnection(); 320 return getMetaDataInfoBoolean(supportsMultipleResultSets__); 321 } 322 323 private final static int supportsMultipleTransactions__ = 32; 324 325 public boolean supportsMultipleTransactions() throws SQLException { 326 checkForClosedConnection(); 327 return getMetaDataInfoBoolean(supportsMultipleTransactions__); 328 } 329 330 private final static int supportsCoreSQLGrammar__ = 33; 331 332 public boolean supportsCoreSQLGrammar() throws SQLException { 333 checkForClosedConnection(); 334 return getMetaDataInfoBoolean(supportsCoreSQLGrammar__); 335 } 336 337 private final static int supportsExtendedSQLGrammar__ = 34; 338 339 public boolean supportsExtendedSQLGrammar() throws SQLException { 340 checkForClosedConnection(); 341 return getMetaDataInfoBoolean(supportsExtendedSQLGrammar__); 342 } 343 344 private final static int supportsANSI92IntermediateSQL__ = 35; 345 346 public boolean supportsANSI92IntermediateSQL() throws SQLException { 347 checkForClosedConnection(); 348 return getMetaDataInfoBoolean(supportsANSI92IntermediateSQL__); 349 } 350 351 private final static int supportsANSI92FullSQL__ = 36; 352 353 public boolean supportsANSI92FullSQL() throws SQLException { 354 checkForClosedConnection(); 355 return getMetaDataInfoBoolean(supportsANSI92FullSQL__); 356 } 357 358 private final static int supportsIntegrityEnhancementFacility__ = 37; 359 360 public boolean supportsIntegrityEnhancementFacility() throws SQLException { 361 checkForClosedConnection(); 362 return getMetaDataInfoBoolean(supportsIntegrityEnhancementFacility__); 363 } 364 365 private final static int supportsOuterJoins__ = 38; 366 367 public boolean supportsOuterJoins() throws SQLException { 368 checkForClosedConnection(); 369 return getMetaDataInfoBoolean(supportsOuterJoins__); 370 } 371 372 private final static int supportsFullOuterJoins__ = 39; 373 374 public boolean supportsFullOuterJoins() throws SQLException { 375 checkForClosedConnection(); 376 return getMetaDataInfoBoolean(supportsFullOuterJoins__); 377 } 378 379 private final static int supportsLimitedOuterJoins__ = 40; 380 381 public boolean supportsLimitedOuterJoins() throws SQLException { 382 checkForClosedConnection(); 383 return getMetaDataInfoBoolean(supportsLimitedOuterJoins__); 384 } 385 386 private final static int getSchemaTerm__ = 41; 387 388 public String getSchemaTerm() throws SQLException { 389 checkForClosedConnection(); 390 return getMetaDataInfoString(getSchemaTerm__); 391 } 392 393 private final static int getProcedureTerm__ = 42; 394 395 public String getProcedureTerm() throws SQLException { 396 checkForClosedConnection(); 397 return getMetaDataInfoString(getProcedureTerm__); 398 } 399 400 private final static int getCatalogTerm__ = 43; 401 402 public String getCatalogTerm() throws SQLException { 403 checkForClosedConnection(); 404 return getMetaDataInfoString(getCatalogTerm__); 405 } 406 407 private final static int isCatalogAtStart__ = 44; 408 409 public boolean isCatalogAtStart() throws SQLException { 410 checkForClosedConnection(); 411 return getMetaDataInfoBoolean(isCatalogAtStart__); 412 } 413 414 private final static int getCatalogSeparator__ = 45; 415 416 public String getCatalogSeparator() throws SQLException { 417 checkForClosedConnection(); 418 return getMetaDataInfoString(getCatalogSeparator__); 419 } 420 421 private final static int supportsSchemasInDataManipulation__ = 46; 422 423 public boolean supportsSchemasInDataManipulation() throws SQLException { 424 checkForClosedConnection(); 425 return getMetaDataInfoBoolean(supportsSchemasInDataManipulation__); 426 } 427 428 private final static int supportsSchemasInProcedureCalls__ = 47; 429 430 public boolean supportsSchemasInProcedureCalls() throws SQLException { 431 checkForClosedConnection(); 432 return getMetaDataInfoBoolean(supportsSchemasInProcedureCalls__); 433 } 434 435 private final static int supportsSchemasInTableDefinitions__ = 48; 436 437 public boolean supportsSchemasInTableDefinitions() throws SQLException { 438 checkForClosedConnection(); 439 return getMetaDataInfoBoolean(supportsSchemasInTableDefinitions__); 440 } 441 442 443 private final static int supportsSchemasInIndexDefinitions__ = 49; 444 445 public boolean supportsSchemasInIndexDefinitions() throws SQLException { 446 checkForClosedConnection(); 447 return getMetaDataInfoBoolean(supportsSchemasInIndexDefinitions__); 448 } 449 450 private final static int supportsSchemasInPrivilegeDefinitions__ = 50; 451 452 public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException { 453 checkForClosedConnection(); 454 return getMetaDataInfoBoolean(supportsSchemasInPrivilegeDefinitions__); 455 } 456 457 private final static int supportsCatalogsInDataManipulation__ = 51; 458 459 public boolean supportsCatalogsInDataManipulation() throws SQLException { 460 checkForClosedConnection(); 461 return getMetaDataInfoBoolean(supportsCatalogsInDataManipulation__); 462 } 463 464 private final static int supportsCatalogsInProcedureCalls__ = 52; 465 466 public boolean supportsCatalogsInProcedureCalls() throws SQLException { 467 checkForClosedConnection(); 468 return getMetaDataInfoBoolean(supportsCatalogsInProcedureCalls__); 469 } 470 471 private final static int supportsCatalogsInTableDefinitions__ = 53; 472 473 public boolean supportsCatalogsInTableDefinitions() throws SQLException { 474 checkForClosedConnection(); 475 return getMetaDataInfoBoolean(supportsCatalogsInTableDefinitions__); 476 } 477 478 private final static int supportsCatalogsInIndexDefinitions__ = 54; 479 480 public boolean supportsCatalogsInIndexDefinitions() throws SQLException { 481 checkForClosedConnection(); 482 return getMetaDataInfoBoolean(supportsCatalogsInIndexDefinitions__); 483 } 484 485 private final static int supportsCatalogsInPrivilegeDefinitions__ = 55; 486 487 public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException { 488 checkForClosedConnection(); 489 return getMetaDataInfoBoolean(supportsCatalogsInPrivilegeDefinitions__); 490 } 491 492 private final static int supportsPositionedDelete__ = 56; 493 494 public boolean supportsPositionedDelete() throws SQLException { 495 checkForClosedConnection(); 496 return getMetaDataInfoBoolean(supportsPositionedDelete__); 497 } 498 499 500 private final static int supportsPositionedUpdate__ = 57; 501 502 public boolean supportsPositionedUpdate() throws SQLException { 503 checkForClosedConnection(); 504 return getMetaDataInfoBoolean(supportsPositionedUpdate__); 505 } 506 507 private final static int supportsSelectForUpdate__ = 58; 508 509 public boolean supportsSelectForUpdate() throws SQLException { 510 checkForClosedConnection(); 511 return getMetaDataInfoBoolean(supportsSelectForUpdate__); 512 } 513 514 private final static int supportsStoredProcedures__ = 59; 515 516 public boolean supportsStoredProcedures() throws SQLException { 517 checkForClosedConnection(); 518 return getMetaDataInfoBoolean(supportsStoredProcedures__); 519 } 520 521 private final static int supportsSubqueriesInComparisons__ = 60; 522 523 public boolean supportsSubqueriesInComparisons() throws SQLException { 524 checkForClosedConnection(); 525 return getMetaDataInfoBoolean(supportsSubqueriesInComparisons__); 526 } 527 528 private final static int supportsUnion__ = 61; 529 530 public boolean supportsUnion() throws SQLException { 531 checkForClosedConnection(); 532 return getMetaDataInfoBoolean(supportsUnion__); 533 } 534 535 private final static int supportsUnionAll__ = 62; 536 537 public boolean supportsUnionAll() throws SQLException { 538 checkForClosedConnection(); 539 return getMetaDataInfoBoolean(supportsUnionAll__); 540 541 } 542 543 private final static int supportsOpenCursorsAcrossCommit__ = 63; 544 545 public boolean supportsOpenCursorsAcrossCommit() throws SQLException { 546 checkForClosedConnection(); 547 return getMetaDataInfoBoolean(supportsOpenCursorsAcrossCommit__); 548 } 549 550 private final static int supportsOpenCursorsAcrossRollback__ = 64; 551 552 public boolean supportsOpenCursorsAcrossRollback() throws SQLException { 553 checkForClosedConnection(); 554 return getMetaDataInfoBoolean(supportsOpenCursorsAcrossRollback__); 555 } 556 557 private final static int supportsOpenStatementsAcrossCommit__ = 65; 558 559 public boolean supportsOpenStatementsAcrossCommit() throws SQLException { 560 checkForClosedConnection(); 561 return getMetaDataInfoBoolean(supportsOpenStatementsAcrossCommit__); 562 } 563 564 565 private final static int supportsOpenStatementsAcrossRollback__ = 66; 566 567 public boolean supportsOpenStatementsAcrossRollback() throws SQLException { 568 checkForClosedConnection(); 569 return getMetaDataInfoBoolean(supportsOpenStatementsAcrossRollback__); 570 } 571 572 private final static int getMaxBinaryLiteralLength__ = 67; 578 579 public int getMaxBinaryLiteralLength() throws SQLException { 580 checkForClosedConnection(); 581 return getMetaDataInfoInt(getMaxBinaryLiteralLength__); 582 } 583 584 private final static int getMaxCharLiteralLength__ = 68; 585 586 public int getMaxCharLiteralLength() throws SQLException { 587 checkForClosedConnection(); 588 return getMetaDataInfoInt(getMaxCharLiteralLength__); 589 } 590 591 private final static int getMaxColumnNameLength__ = 69; 592 593 public int getMaxColumnNameLength() throws SQLException { 594 checkForClosedConnection(); 595 return getMetaDataInfoInt(getMaxColumnNameLength__); 596 } 597 598 private final static int getMaxColumnsInGroupBy__ = 70; 599 600 public int getMaxColumnsInGroupBy() throws SQLException { 601 checkForClosedConnection(); 602 return getMetaDataInfoInt(getMaxColumnsInGroupBy__); 603 } 604 605 private final static int getMaxColumnsInIndex__ = 71; 606 607 public int getMaxColumnsInIndex() throws SQLException { 608 checkForClosedConnection(); 609 return getMetaDataInfoInt(getMaxColumnsInIndex__); 610 } 611 612 private final static int getMaxColumnsInOrderBy__ = 72; 613 614 public int getMaxColumnsInOrderBy() throws SQLException { 615 checkForClosedConnection(); 616 return getMetaDataInfoInt(getMaxColumnsInOrderBy__); 617 } 618 619 private final static int getMaxColumnsInSelect__ = 73; 620 621 public int getMaxColumnsInSelect() throws SQLException { 622 checkForClosedConnection(); 623 return getMetaDataInfoInt(getMaxColumnsInSelect__); 624 } 625 626 private final static int getMaxColumnsInTable__ = 74; 627 628 public int getMaxColumnsInTable() throws SQLException { 629 checkForClosedConnection(); 630 return getMetaDataInfoInt(getMaxColumnsInTable__); 631 } 632 633 private final static int getMaxConnections__ = 75; 634 635 public int getMaxConnections() throws SQLException { 636 checkForClosedConnection(); 637 return getMetaDataInfoInt(getMaxConnections__); 638 } 639 640 private final static int getMaxCursorNameLength__ = 76; 641 642 public int getMaxCursorNameLength() throws SQLException { 643 checkForClosedConnection(); 644 return getMetaDataInfoInt(getMaxCursorNameLength__); 645 } 646 647 private final static int getMaxIndexLength__ = 77; 648 649 public int getMaxIndexLength() throws SQLException { 650 checkForClosedConnection(); 651 return getMetaDataInfoInt(getMaxIndexLength__); 652 } 653 654 private final static int getMaxSchemaNameLength__ = 78; 655 656 public int getMaxSchemaNameLength() throws SQLException { 657 checkForClosedConnection(); 658 return getMetaDataInfoInt(getMaxSchemaNameLength__); 659 } 660 661 private final static int getMaxProcedureNameLength__ = 79; 662 663 public int getMaxProcedureNameLength() throws SQLException { 664 checkForClosedConnection(); 665 return getMetaDataInfoInt(getMaxProcedureNameLength__); 666 } 667 668 private final static int getMaxCatalogNameLength__ = 80; 669 670 public int getMaxCatalogNameLength() throws SQLException { 671 checkForClosedConnection(); 672 return getMetaDataInfoInt(getMaxCatalogNameLength__); 673 } 674 675 private final static int getMaxRowSize__ = 81; 676 677 public int getMaxRowSize() throws SQLException { 678 checkForClosedConnection(); 679 return getMetaDataInfoInt(getMaxRowSize__); 680 } 681 682 private final static int doesMaxRowSizeIncludeBlobs__ = 82; 683 684 public boolean doesMaxRowSizeIncludeBlobs() throws SQLException { 685 checkForClosedConnection(); 686 return getMetaDataInfoBoolean(doesMaxRowSizeIncludeBlobs__); 687 } 688 689 private final static int getMaxStatementLength__ = 83; 690 691 public int getMaxStatementLength() throws SQLException { 692 checkForClosedConnection(); 693 return getMetaDataInfoInt(getMaxStatementLength__); 694 } 695 696 private final static int getMaxStatements__ = 84; 697 698 public int getMaxStatements() throws SQLException { 699 checkForClosedConnection(); 700 return getMetaDataInfoInt(getMaxStatements__); 701 } 702 703 private final static int getMaxTableNameLength__ = 85; 704 705 public int getMaxTableNameLength() throws SQLException { 706 checkForClosedConnection(); 707 return getMetaDataInfoInt(getMaxTableNameLength__); 708 } 709 710 private final static int getMaxTablesInSelect__ = 86; 711 712 public int getMaxTablesInSelect() throws SQLException { 713 checkForClosedConnection(); 714 return getMetaDataInfoInt(getMaxTablesInSelect__); 715 } 716 717 private final static int getMaxUserNameLength__ = 87; 718 719 public int getMaxUserNameLength() throws SQLException { 720 checkForClosedConnection(); 721 return getMetaDataInfoInt(getMaxUserNameLength__); 722 } 723 724 private final static int getDefaultTransactionIsolation__ = 88; 725 726 public int getDefaultTransactionIsolation() throws SQLException { 727 checkForClosedConnection(); 728 return getMetaDataInfoInt(getDefaultTransactionIsolation__); 729 } 730 731 private final static int supportsTransactions__ = 89; 732 733 public boolean supportsTransactions() throws SQLException { 734 checkForClosedConnection(); 735 return getMetaDataInfoBoolean(supportsTransactions__); 736 } 737 738 private final static int supportsTransactionIsolationLevel__ = 90; 741 742 public boolean supportsTransactionIsolationLevel(int level) throws SQLException { 743 checkForClosedConnection(); 744 return getMetaDataInfoBooleanWithType(supportsTransactionIsolationLevel__, level); 745 } 746 747 748 private final static int supportsDataDefinitionAndDataManipulationTransactions__ = 91; 749 750 public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException { 751 checkForClosedConnection(); 752 return getMetaDataInfoBoolean(supportsDataDefinitionAndDataManipulationTransactions__); 753 } 754 755 private final static int supportsDataManipulationTransactionsOnly__ = 92; 756 757 public boolean supportsDataManipulationTransactionsOnly() throws SQLException { 758 checkForClosedConnection(); 759 return getMetaDataInfoBoolean(supportsDataManipulationTransactionsOnly__); 760 } 761 762 private final static int dataDefinitionCausesTransactionCommit__ = 93; 763 764 public boolean dataDefinitionCausesTransactionCommit() throws SQLException { 765 checkForClosedConnection(); 766 return getMetaDataInfoBoolean(dataDefinitionCausesTransactionCommit__); 767 } 768 769 private final static int dataDefinitionIgnoredInTransactions__ = 94; 770 771 public boolean dataDefinitionIgnoredInTransactions() throws SQLException { 772 checkForClosedConnection(); 773 return getMetaDataInfoBoolean(dataDefinitionIgnoredInTransactions__); 774 } 775 776 private final static int supportsResultSetType__ = 95; 779 780 public boolean supportsResultSetType(int type) throws SQLException { 781 checkForClosedConnection(); 782 return getMetaDataInfoBooleanWithType(supportsResultSetType__, type); 783 } 784 785 private final static int supportsResultSetConcurrency__ = 96; 786 787 public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException { 788 checkForClosedConnection(); 789 return getMetaDataInfoInt_SupportsResultSetConcurrency(supportsResultSetConcurrency__, type, concurrency); 790 } 791 792 private final static int ownUpdatesAreVisible__ = 97; 795 796 public boolean ownUpdatesAreVisible(int type) throws SQLException { 797 checkForClosedConnection(); 798 return getMetaDataInfoBooleanWithType(ownUpdatesAreVisible__, type); 799 } 800 801 private final static int ownDeletesAreVisible__ = 98; 804 805 public boolean ownDeletesAreVisible(int type) throws SQLException { 806 checkForClosedConnection(); 807 return getMetaDataInfoBooleanWithType(ownDeletesAreVisible__, type); 808 } 809 810 private final static int ownInsertsAreVisible__ = 99; 813 814 public boolean ownInsertsAreVisible(int type) throws SQLException { 815 checkForClosedConnection(); 816 return getMetaDataInfoBooleanWithType(ownInsertsAreVisible__, type); 817 } 818 819 private final static int othersUpdatesAreVisible__ = 100; 822 823 public boolean othersUpdatesAreVisible(int type) throws SQLException { 824 checkForClosedConnection(); 825 return getMetaDataInfoBooleanWithType(othersUpdatesAreVisible__, type); 826 } 827 828 private final static int othersDeletesAreVisible__ = 101; 831 832 public boolean othersDeletesAreVisible(int type) throws SQLException { 833 checkForClosedConnection(); 834 return getMetaDataInfoBooleanWithType(othersDeletesAreVisible__, type); 835 } 836 837 private final static int othersInsertsAreVisible__ = 102; 840 841 public boolean othersInsertsAreVisible(int type) throws SQLException { 842 checkForClosedConnection(); 843 return getMetaDataInfoBooleanWithType(othersInsertsAreVisible__, type); 844 } 845 846 private final static int updatesAreDetected__ = 103; 849 850 public boolean updatesAreDetected(int type) throws SQLException { 851 checkForClosedConnection(); 852 return getMetaDataInfoBooleanWithType(updatesAreDetected__, type); 853 } 854 855 private final static int deletesAreDetected__ = 104; 858 859 public boolean deletesAreDetected(int type) throws SQLException { 860 checkForClosedConnection(); 861 return getMetaDataInfoBooleanWithType(deletesAreDetected__, type); 862 } 863 864 private final static int insertsAreDetected__ = 105; 867 868 public boolean insertsAreDetected(int type) throws SQLException { 869 checkForClosedConnection(); 870 return getMetaDataInfoBooleanWithType(insertsAreDetected__, type); 871 } 872 873 private final static int supportsBatchUpdates__ = 106; 874 875 public boolean supportsBatchUpdates() throws SQLException { 876 checkForClosedConnection(); 877 return getMetaDataInfoBoolean(supportsBatchUpdates__); 878 } 879 880 public boolean supportsSavepoints() throws SQLException { 881 checkForClosedConnection(); 882 if (productLevel_.greaterThanOrEqualTo(5, 2, 0)) { 883 return true; 884 } 885 886 return false; 887 } 888 889 abstract public String getURL_() throws SqlException; 891 892 public String getURL() throws SQLException { 893 try 894 { 895 checkForClosedConnection(); 896 return getURL_(); 897 } 898 catch ( SqlException se ) 899 { 900 throw se.getSQLException(); 901 } 902 } 903 904 public String getUserName() throws SQLException { 905 checkForClosedConnection(); 906 return connection_.user_; 907 } 908 909 public boolean isReadOnly() throws SQLException { 910 return false; 911 } 912 913 public String getDatabaseProductName() throws SQLException { 914 checkForClosedConnection(); 915 return productLevel_.databaseProductName_; 916 } 917 918 public String getDatabaseProductVersion() throws SQLException { 919 checkForClosedConnection(); 920 return productLevel_.databaseProductVersion_; 921 } 922 923 public String getDriverName() throws SQLException { 924 checkForClosedConnection(); 925 return Configuration.dncDriverName; 926 } 927 928 public String getDriverVersion() throws SQLException { 929 checkForClosedConnection(); 930 return Version.getDriverVersion(); 931 } 932 933 public int getDriverMajorVersion() { 935 return Version.getMajorVersion(); 936 } 937 938 public int getDriverMinorVersion() { 940 return Version.getMinorVersion(); 941 } 942 943 public boolean supportsMixedCaseIdentifiers() throws SQLException { 946 checkForClosedConnection(); 947 return false; 948 } 949 950 public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { 951 checkForClosedConnection(); 952 return true; 953 } 954 955 public String getIdentifierQuoteString() throws SQLException { 956 checkForClosedConnection(); 957 return "\""; 958 } 959 960 public boolean supportsColumnAliasing() throws SQLException { 961 checkForClosedConnection(); 962 return true; 963 } 964 965 public boolean nullPlusNonNullIsNull() throws SQLException { 966 checkForClosedConnection(); 967 return true; 968 } 969 970 public boolean supportsTableCorrelationNames() throws SQLException { 971 checkForClosedConnection(); 972 return true; 973 } 974 975 public boolean supportsLikeEscapeClause() throws SQLException { 976 checkForClosedConnection(); 977 return true; 978 } 979 980 public boolean supportsNonNullableColumns() throws SQLException { 981 checkForClosedConnection(); 982 return true; 983 } 984 985 public boolean supportsMinimumSQLGrammar() throws SQLException { 986 checkForClosedConnection(); 987 return true; 988 } 989 990 public boolean supportsANSI92EntryLevelSQL() throws SQLException { 991 checkForClosedConnection(); 992 return true; 993 } 994 995 public boolean supportsSubqueriesInExists() throws SQLException { 996 checkForClosedConnection(); 997 return true; 998 } 999 1000 public boolean supportsSubqueriesInIns() throws SQLException { 1001 checkForClosedConnection(); 1002 return true; 1003 } 1004 1005 public boolean supportsSubqueriesInQuantifieds() throws SQLException { 1006 checkForClosedConnection(); 1007 return true; 1008 } 1009 1010 public boolean supportsCorrelatedSubqueries() throws SQLException { 1011 checkForClosedConnection(); 1012 return true; 1013 } 1014 1015 1016 1018 public java.sql.ResultSet getProcedures(String catalog, 1026 String schemaPattern, 1027 String procedureNamePattern) throws SQLException { 1028 try 1029 { 1030 synchronized (connection_) { 1031 if (agent_.loggingEnabled()) { 1032 agent_.logWriter_.traceEntry(this, "getProcedures", catalog, schemaPattern, procedureNamePattern); 1033 } 1034 return getProceduresX(catalog, schemaPattern, procedureNamePattern); 1035 } 1036 } 1037 catch ( SqlException se ) 1038 { 1039 throw se.getSQLException(); 1040 } 1041 } 1042 1043 1044 private ResultSet getProceduresX(String catalog, 1045 String schemaPattern, 1046 String procedureNamePattern) throws SqlException { 1047 checkForClosedConnectionX(); 1048 1049 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLPROCEDURES(?,?,?,?)"); 1050 1051 cs.setStringX(1, catalog); 1052 cs.setStringX(2, schemaPattern); 1053 cs.setStringX(3, procedureNamePattern); 1054 cs.setStringX(4, getOptions()); 1055 return executeCatalogQuery(cs); 1056 } 1057 1058 1059 public java.sql.ResultSet getProcedureColumns(String catalog, 1068 String schemaPattern, 1069 String procedureNamePattern, 1070 String columnNamePattern) throws SQLException { 1071 try 1072 { 1073 synchronized (connection_) { 1074 if (agent_.loggingEnabled()) { 1075 agent_.logWriter_.traceEntry(this, "getProcedureColumns", catalog, schemaPattern, procedureNamePattern, columnNamePattern); 1076 } 1077 return getProcedureColumnsX(catalog, schemaPattern, procedureNamePattern, columnNamePattern); 1078 } 1079 } 1080 catch ( SqlException se ) 1081 { 1082 throw se.getSQLException(); 1083 } 1084 1085 } 1086 1087 private ResultSet getProcedureColumnsX(String catalog, 1088 String schemaPattern, 1089 String procedureNamePattern, 1090 String columnNamePattern) throws SqlException { 1091 checkForClosedConnectionX(); 1092 ; 1093 1094 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLPROCEDURECOLS(?,?,?,?,?)"); 1095 1096 cs.setStringX(1, catalog); 1097 cs.setStringX(2, schemaPattern); 1098 cs.setStringX(3, procedureNamePattern); 1099 cs.setStringX(4, columnNamePattern); 1100 cs.setStringX(5, getOptions()); 1101 return executeCatalogQuery(cs); 1102 } 1103 1104 1132 1133 public java.sql.ResultSet getFunctions(String catalog, 1134 String schemaPattern, 1135 String functionNamePattern) 1136 throws SQLException { 1137 try { 1138 synchronized (connection_) { 1139 if (agent_.loggingEnabled()) { 1140 agent_.logWriter_.traceEntry(this, "getFunctions", 1141 catalog, schemaPattern, 1142 functionNamePattern); 1143 } 1144 return getFunctionsX(catalog, schemaPattern, 1145 functionNamePattern); 1146 } 1147 } 1148 catch (SqlException se) { 1149 throw se.getSQLException(); 1150 } 1151 } 1152 1153 1163 private ResultSet getFunctionsX(String catalog, 1164 String schemaPattern, 1165 String functionNamePattern) 1166 throws SqlException { 1167 checkForClosedConnectionX(); 1168 checkServerJdbcVersionX("getFunctions(String,String,String)", 4, 0); 1169 1170 PreparedStatement cs = 1171 prepareMetaDataQuery("SYSIBM.SQLFUNCTIONS(?,?,?,?)"); 1172 1173 cs.setStringX(1, catalog); 1174 cs.setStringX(2, schemaPattern); 1175 cs.setStringX(3, functionNamePattern); 1176 cs.setStringX(4, getOptions()); 1177 return executeCatalogQuery(cs); 1178 } 1179 1180 1208 public java.sql.ResultSet 1209 getFunctionColumns(String catalog, 1210 String schemaPattern, 1211 String functionNamePattern, 1212 String parameterNamePattern) 1213 throws SQLException { 1214 try 1215 { 1216 synchronized (connection_) { 1217 if (agent_.loggingEnabled()) { 1218 agent_.logWriter_. 1219 traceEntry(this, 1220 "getFunctionColumns", 1221 catalog, schemaPattern, 1222 functionNamePattern, parameterNamePattern); 1223 } 1224 return getFunctionColumnsX(catalog, schemaPattern, 1225 functionNamePattern, 1226 parameterNamePattern); 1227 } 1228 } 1229 catch ( SqlException se ) 1230 { 1231 throw se.getSQLException(); 1232 } 1233 } 1234 1235 1248 private ResultSet getFunctionColumnsX(String catalog, 1249 String schemaPattern, 1250 String functionNamePattern, 1251 String parameterNamePattern) 1252 throws SqlException { 1253 checkForClosedConnectionX(); 1254 checkServerJdbcVersionX("getFunctionColumns"+ 1255 "(String,String,String,String)", 4, 0); 1256 1257 PreparedStatement cs = 1258 prepareMetaDataQuery("SYSIBM.SQLFUNCTIONPARAMS(?,?,?,?,?)"); 1259 1260 cs.setStringX(1, catalog); 1261 cs.setStringX(2, schemaPattern); 1262 cs.setStringX(3, functionNamePattern); 1263 cs.setStringX(4, parameterNamePattern); 1264 cs.setStringX(5, getOptions()); 1265 return executeCatalogQuery(cs); 1266 } 1267 1268 public java.sql.ResultSet getTables(String catalog, 1277 String schemaPattern, 1278 String tableNamePattern, 1279 String types[]) throws SQLException { 1280 try 1281 { 1282 synchronized (connection_) { 1283 if (agent_.loggingEnabled()) { 1284 agent_.logWriter_.traceEntry(this, "getTables", catalog, schemaPattern, tableNamePattern, types); 1285 } 1286 return getTablesX(catalog, schemaPattern, tableNamePattern, types); 1287 } 1288 } 1289 catch ( SqlException se ) 1290 { 1291 throw se.getSQLException(); 1292 } 1293 } 1294 1295 private ResultSet getTablesX(String catalog, 1296 String schemaPattern, 1297 String tableNamePattern, 1298 String types[]) throws SqlException { 1299 try { 1300 checkForClosedConnection(); 1301 } catch ( SQLException se ) { 1302 throw new SqlException(se); 1303 } 1304 1305 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLTABLES(?,?,?,?,?)"); 1306 1307 if (catalog == null) { 1308 cs.setNullX(1, java.sql.Types.VARCHAR); 1309 } else { 1310 cs.setStringX(1, catalog); 1311 } 1312 1313 if (schemaPattern == null) { 1314 cs.setNullX(2, java.sql.Types.VARCHAR); 1315 } else { 1316 cs.setStringX(2, schemaPattern); 1317 } 1318 1319 if (tableNamePattern == null) { 1320 cs.setNullX(3, java.sql.Types.VARCHAR); 1321 } else { 1322 cs.setStringX(3, tableNamePattern); 1323 } 1324 1325 String tableTypes = new String (); 1326 int i = 0; 1327 if (types == null) { 1328 cs.setNullX(4, java.sql.Types.VARCHAR); 1329 } else if (types.length == 1 && (types[0].trim()).equals("%")) { 1330 cs.setStringX(4, types[0]); 1331 } else { 1332 while (i < types.length) { 1333 if (i > 0) { 1334 tableTypes = tableTypes.concat(","); 1335 } 1336 tableTypes = tableTypes.concat("'" + types[i] + "'"); 1337 i++; 1338 } 1339 cs.setStringX(4, tableTypes); 1340 } 1341 cs.setStringX(5, getOptions()); 1342 return executeCatalogQuery(cs); 1343 } 1344 1345 public java.sql.ResultSet getSchemas() throws SQLException { 1354 try 1355 { 1356 synchronized (connection_) { 1357 if (agent_.loggingEnabled()) { 1358 agent_.logWriter_.traceEntry(this, "getSchemas"); 1359 } 1360 return getSchemasX(); 1361 } 1362 } 1363 catch ( SqlException se ) 1364 { 1365 throw se.getSQLException(); 1366 } 1367 } 1368 1369 private ResultSet getSchemasX() throws SqlException { 1370 try { 1371 checkForClosedConnection(); 1372 } catch ( SQLException se ) { 1373 throw new SqlException(se); 1374 } 1375 1376 ; 1377 1378 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')"); 1379 return (ResultSet) cs.executeQueryX(); 1380 } 1381 1382 1383 public java.sql.ResultSet getCatalogs() throws SQLException { 1385 try 1386 { 1387 synchronized (connection_) { 1388 if (agent_.loggingEnabled()) { 1389 agent_.logWriter_.traceEntry(this, "getCatalogs"); 1390 } 1391 return getCatalogsX(); 1392 } 1393 } 1394 catch ( SqlException se ) 1395 { 1396 throw se.getSQLException(); 1397 } 1398 } 1399 1400 private ResultSet getCatalogsX() throws SqlException { 1401 checkForClosedConnectionX(); 1402 1403 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLTABLES('', '', '', '', 'GETCATALOGS=1')"); 1404 return (ResultSet) cs.executeQueryX(); 1405 } 1406 1407 public java.sql.ResultSet getTableTypes() throws SQLException { 1415 try 1416 { 1417 synchronized (connection_) { 1418 if (agent_.loggingEnabled()) { 1419 agent_.logWriter_.traceEntry(this, "getTableTypes"); 1420 } 1421 return getTableTypesX(); 1422 } 1423 } 1424 catch ( SqlException se ) 1425 { 1426 throw se.getSQLException(); 1427 } 1428 } 1429 1430 private ResultSet getTableTypesX() throws SqlException { 1431 checkForClosedConnectionX(); 1432 ; 1433 1434 PreparedStatement cs = null; 1435 cs = prepareMetaDataQuery("SYSIBM.SQLTABLES(?,?,?,?,?)"); 1436 1437 cs.setStringX(1, ""); 1438 cs.setStringX(2, ""); 1439 cs.setStringX(3, ""); 1440 cs.setStringX(4, "%"); 1441 int cursorHold; 1442 if (connection_.holdability() == JDBC30Translation.HOLD_CURSORS_OVER_COMMIT) { 1443 cursorHold = 1; 1444 } else { 1445 cursorHold = 0; 1446 } 1447 cs.setStringX(5, "DATATYPE='JDBC';GETTABLETYPES=1; CURSORHOLD=" + cursorHold); 1448 return executeCatalogQuery(cs); 1449 } 1450 1451 1452 public java.sql.ResultSet getColumns(String catalog, 1461 String schemaPattern, 1462 String tableNamePattern, 1463 String columnNamePattern) throws SQLException { 1464 try 1465 { 1466 synchronized (connection_) { 1467 if (agent_.loggingEnabled()) { 1468 agent_.logWriter_.traceEntry(this, "getColumns", catalog, schemaPattern, tableNamePattern, columnNamePattern); 1469 } 1470 checkForClosedConnection(); 1471 return getColumnsX(catalog, schemaPattern, tableNamePattern, columnNamePattern); 1472 } 1473 } 1474 catch ( SqlException se ) 1475 { 1476 throw se.getSQLException(); 1477 } 1478 } 1479 1480 private ResultSet getColumnsX(String catalog, 1481 String schemaPattern, 1482 String tableNamePattern, 1483 String columnNamePattern) throws SqlException { 1484 checkForClosedConnectionX(); 1485 1486 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLCOLUMNS(?,?,?,?,?)"); 1487 1488 cs.setStringX(1, catalog); 1489 cs.setStringX(2, schemaPattern); 1490 cs.setStringX(3, tableNamePattern); 1491 cs.setStringX(4, columnNamePattern); cs.setStringX(5, getOptions()); 1493 return executeCatalogQuery(cs); 1494 } 1495 1496 1497 public java.sql.ResultSet getColumnPrivileges(String catalog, 1506 String schema, 1507 String table, 1508 String columnNamePattern) throws SQLException { 1509 try 1510 { 1511 synchronized (connection_) { 1512 if (agent_.loggingEnabled()) { 1513 agent_.logWriter_.traceEntry(this, "getColumnPrivileges", catalog, schema, table, columnNamePattern); 1514 } 1515 return getColumnPrivilegesX(catalog, schema, table, columnNamePattern); 1516 } 1517 } 1518 catch ( SqlException se ) 1519 { 1520 throw se.getSQLException(); 1521 } 1522 } 1523 1524 private ResultSet getColumnPrivilegesX(String catalog, 1525 String schema, 1526 String table, 1527 String columnNamePattern) throws SqlException { 1528 checkForClosedConnectionX(); 1529 if (table == null) { 1531 throw new SqlException(agent_.logWriter_, 1532 new ClientMessageId(SQLState.TABLE_NAME_CANNOT_BE_NULL)); 1533 1534 } 1535 1536 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLCOLPRIVILEGES(?,?,?,?,?)"); 1537 1538 cs.setStringX(1, catalog); 1539 cs.setStringX(2, schema); 1540 cs.setStringX(3, table); 1541 cs.setStringX(4, columnNamePattern); 1542 cs.setStringX(5, getOptions()); 1543 return executeCatalogQuery(cs); 1544 } 1545 1546 1547 public java.sql.ResultSet getTablePrivileges(String catalog, 1555 String schemaPattern, 1556 String tableNamePattern) throws SQLException { 1557 try 1558 { 1559 synchronized (connection_) { 1560 if (agent_.loggingEnabled()) { 1561 agent_.logWriter_.traceEntry(this, "getTablePrivileges", catalog, schemaPattern, tableNamePattern); 1562 } 1563 return getTablePrivilegesX(catalog, schemaPattern, tableNamePattern); 1564 } 1565 } 1566 catch ( SqlException se ) 1567 { 1568 throw se.getSQLException(); 1569 } 1570 } 1571 1572 private ResultSet getTablePrivilegesX(String catalog, 1573 String schemaPattern, 1574 String tableNamePattern) throws SqlException { 1575 checkForClosedConnectionX(); 1576 ; 1577 1578 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLTABLEPRIVILEGES(?,?,?,?)"); 1579 1580 cs.setStringX(1, catalog); 1581 cs.setStringX(2, schemaPattern); 1582 cs.setStringX(3, tableNamePattern); 1583 cs.setStringX(4, getOptions()); 1584 return executeCatalogQuery(cs); 1585 } 1586 1587 1588 public java.sql.ResultSet getBestRowIdentifier(String catalog, 1598 String schema, 1599 String table, 1600 int scope, 1601 boolean nullable) throws SQLException { 1602 try 1603 { 1604 synchronized (connection_) { 1605 if (agent_.loggingEnabled()) { 1606 agent_.logWriter_.traceEntry(this, "getBestRowIdentifier", catalog, schema, table, scope, nullable); 1607 } 1608 return getBestRowIdentifierX(catalog, schema, table, scope, nullable); 1609 } 1610 } 1611 catch ( SqlException se ) 1612 { 1613 throw se.getSQLException(); 1614 } 1615 } 1616 1617 private ResultSet getBestRowIdentifierX(String catalog, 1618 String schema, 1619 String table, 1620 int scope, 1621 boolean nullable) throws SqlException { 1622 checkForClosedConnectionX(); 1623 ; 1624 1625 if (table == null) { 1629 throw new SqlException(agent_.logWriter_, 1630 new ClientMessageId(SQLState.TABLE_NAME_CANNOT_BE_NULL)); 1631 1632 } 1633 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLSPECIALCOLUMNS(?,?,?,?,?,?,?)"); 1634 1635 cs.setIntX(1, SQL_BEST_ROWID); 1636 cs.setStringX(2, catalog); 1637 cs.setStringX(3, schema); 1638 cs.setStringX(4, table); 1639 cs.setIntX(5, scope); 1640 if (nullable) { 1641 cs.setShortX(6, (short) 1); 1642 } else { 1643 cs.setShortX(6, (short) 0); 1644 } 1645 cs.setStringX(7, getOptions()); 1646 return executeCatalogQuery(cs); 1647 } 1648 1649 1650 public java.sql.ResultSet getVersionColumns(String catalog, 1651 String schema, 1652 String table) throws SQLException { 1653 try 1654 { 1655 synchronized (connection_) { 1656 if (agent_.loggingEnabled()) { 1657 agent_.logWriter_.traceEntry(this, "getVersionColumns", catalog, schema, table); 1658 } 1659 return getVersionColumnsX(catalog, schema, table); 1660 } 1661 } 1662 catch ( SqlException se ) 1663 { 1664 throw se.getSQLException(); 1665 } 1666 } 1667 1668 private ResultSet getVersionColumnsX(String catalog, 1669 String schema, 1670 String table) throws SqlException { 1671 checkForClosedConnectionX(); 1672 1673 if (table == null) { 1675 throw new SqlException(agent_.logWriter_, 1676 new ClientMessageId(SQLState.TABLE_NAME_CANNOT_BE_NULL)); 1677 1678 } 1679 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLSPECIALCOLUMNS(?,?,?,?,?,?,?)"); 1680 1681 cs.setIntX(1, SQL_ROWVER); 1682 cs.setStringX(2, catalog); 1683 cs.setStringX(3, schema); 1684 cs.setStringX(4, table); 1685 cs.setIntX(5, 0); 1686 cs.setShortX(6, (short) 0); 1687 cs.setStringX(7, getOptions()); 1688 1689 return executeCatalogQuery(cs); 1690 } 1691 1692 public java.sql.ResultSet getPrimaryKeys(String catalog, 1700 String schema, 1701 String table) throws SQLException { 1702 try 1703 { 1704 synchronized (connection_) { 1705 if (agent_.loggingEnabled()) { 1706 agent_.logWriter_.traceEntry(this, "getPrimaryKeys", catalog, schema, table); 1707 } 1708 return getPrimaryKeysX(catalog, schema, table); 1709 } 1710 } 1711 catch ( SqlException se ) 1712 { 1713 throw se.getSQLException(); 1714 } 1715 } 1716 1717 private ResultSet getPrimaryKeysX(String catalog, 1718 String schema, 1719 String table) throws SqlException { 1720 checkForClosedConnectionX(); 1721 ; 1722 1723 if (table == null) { 1725 throw new SqlException(agent_.logWriter_, 1726 new ClientMessageId(SQLState.TABLE_NAME_CANNOT_BE_NULL)); 1727 1728 } 1729 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLPRIMARYKEYS(?,?,?,?)"); 1730 1731 cs.setStringX(1, catalog); 1732 cs.setStringX(2, schema); 1733 cs.setStringX(3, table); 1734 cs.setStringX(4, getOptions()); 1735 return executeCatalogQuery(cs); 1736 } 1737 1738 1739 public java.sql.ResultSet getImportedKeys(String catalog, 1750 String schema, 1751 String table) throws SQLException { 1752 try 1753 { 1754 synchronized (connection_) { 1755 if (agent_.loggingEnabled()) { 1756 agent_.logWriter_.traceEntry(this, "getImportedKeys", catalog, schema, table); 1757 } 1758 return getImportedKeysX(catalog, schema, table); 1759 } 1760 } 1761 catch ( SqlException se ) 1762 { 1763 throw se.getSQLException(); 1764 } 1765 } 1766 1767 private ResultSet getImportedKeysX(String catalog, 1768 String schema, 1769 String table) throws SqlException { 1770 checkForClosedConnectionX(); 1771 1772 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLFOREIGNKEYS(?,?,?,?,?,?,?)"); 1773 1774 cs.setStringX(1, ""); 1775 cs.setStringX(2, null); 1776 cs.setStringX(3, ""); 1777 cs.setStringX(4, catalog); 1778 cs.setStringX(5, schema); 1779 cs.setStringX(6, table); 1780 if (connection_.holdability() == JDBC30Translation.HOLD_CURSORS_OVER_COMMIT) { 1783 cs.setStringX(7, "DATATYPE='JDBC';IMPORTEDKEY=1; CURSORHOLD=1"); 1784 } else { 1785 cs.setStringX(7, "DATATYPE='JDBC';IMPORTEDKEY=1; CURSORHOLD=0"); 1786 } 1787 return executeCatalogQuery(cs); 1788 } 1789 1790 public java.sql.ResultSet getExportedKeys(String catalog, 1801 String schema, 1802 String table) throws SQLException { 1803 try 1804 { 1805 synchronized (connection_) { 1806 if (agent_.loggingEnabled()) { 1807 agent_.logWriter_.traceEntry(this, "getExportedKeys", catalog, schema, table); 1808 } 1809 return getExportedKeysX(catalog, schema, table); 1810 } 1811 } 1812 catch ( SqlException se ) 1813 { 1814 throw se.getSQLException(); 1815 } 1816 } 1817 1818 private ResultSet getExportedKeysX(String catalog, 1819 String schema, 1820 String table) throws SqlException { 1821 checkForClosedConnectionX(); 1822 ; 1823 1824 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLFOREIGNKEYS(?,?,?,?,?,?,?)"); 1825 1826 cs.setStringX(1, catalog); 1827 cs.setStringX(2, schema); 1828 cs.setStringX(3, table); 1829 cs.setStringX(4, ""); 1830 cs.setStringX(5, null); 1831 cs.setStringX(6, ""); 1832 if (connection_.holdability() == JDBC30Translation.HOLD_CURSORS_OVER_COMMIT) { 1835 cs.setStringX(7, "DATATYPE='JDBC';EXPORTEDKEY=1; CURSORHOLD=1"); 1836 } else { 1837 cs.setStringX(7, "DATATYPE='JDBC';EXPORTEDKEY=1; CURSORHOLD=0"); 1838 } 1839 return executeCatalogQuery(cs); 1840 } 1841 1842 public java.sql.ResultSet getCrossReference(String primaryCatalog, 1853 String primarySchema, 1854 String primaryTable, 1855 String foreignCatalog, 1856 String foreignSchema, 1857 String foreignTable) throws SQLException { 1858 try 1859 { 1860 synchronized (connection_) { 1861 if (agent_.loggingEnabled()) { 1862 agent_.logWriter_.traceEntry(this, "getCrossReference", primaryCatalog, primarySchema, primaryTable, foreignCatalog, foreignSchema, foreignTable); 1863 } 1864 return getCrossReferenceX(primaryCatalog, primarySchema, primaryTable, 1865 foreignCatalog, foreignSchema, foreignTable); 1866 } 1867 } 1868 catch ( SqlException se ) 1869 { 1870 throw se.getSQLException(); 1871 } 1872 } 1873 1874 1875 private ResultSet getCrossReferenceX(String primaryCatalog, 1876 String primarySchema, 1877 String primaryTable, 1878 String foreignCatalog, 1879 String foreignSchema, 1880 String foreignTable) throws SqlException { 1881 checkForClosedConnectionX(); 1882 ; 1883 1884 if (primaryTable == null) { 1886 throw new SqlException(agent_.logWriter_, 1887 new ClientMessageId(SQLState.PRIMARY_TABLE_NAME_IS_NULL)); 1888 1889 } 1890 1891 if (foreignTable == null) { 1892 throw new SqlException(agent_.logWriter_, 1893 new ClientMessageId(SQLState.FOREIGN_TABLE_NAME_IS_NULL)); 1894 1895 } 1896 1897 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLFOREIGNKEYS(?,?,?,?,?,?,?)"); 1898 1899 cs.setStringX(1, primaryCatalog); 1900 cs.setStringX(2, primarySchema); 1901 cs.setStringX(3, primaryTable); 1902 cs.setStringX(4, foreignCatalog); 1903 cs.setStringX(5, foreignSchema); 1904 cs.setStringX(6, foreignTable); 1905 cs.setStringX(7, getOptions()); 1906 return executeCatalogQuery(cs); 1907 } 1908 1909 public java.sql.ResultSet getTypeInfo() throws SQLException { 1915 try 1916 { 1917 synchronized (connection_) { 1918 if (agent_.loggingEnabled()) { 1919 agent_.logWriter_.traceEntry(this, "getTypeInfo"); 1920 } 1921 return getTypeInfoX(); 1922 } 1923 } 1924 catch ( SqlException se ) 1925 { 1926 throw se.getSQLException(); 1927 } 1928 } 1929 1930 private ResultSet getTypeInfoX() throws SqlException { 1931 checkForClosedConnectionX(); 1932 ; 1933 1934 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLGETTYPEINFO(?,?)"); 1936 1937 cs.setShortX(1, (short) 0); 1938 cs.setStringX(2, getOptions()); 1939 return executeCatalogQuery(cs); 1940 } 1941 1942 1943 public java.sql.ResultSet getIndexInfo(String catalog, 1953 String schema, 1954 String table, 1955 boolean unique, 1956 boolean approximate) throws SQLException { 1957 try 1958 { 1959 synchronized (connection_) { 1960 if (agent_.loggingEnabled()) { 1961 agent_.logWriter_.traceEntry(this, "getIndexInfo", catalog, schema, table, unique, approximate); 1962 } 1963 return getIndexInfoX(catalog, schema, table, unique, approximate); 1964 } 1965 } 1966 catch ( SqlException se ) 1967 { 1968 throw se.getSQLException(); 1969 } 1970 } 1971 1972 private ResultSet getIndexInfoX(String catalog, 1973 String schema, 1974 String table, 1975 boolean unique, 1976 boolean approximate) throws SqlException { 1977 checkForClosedConnectionX(); 1978 1979 if (table == null) { 1981 throw new SqlException(agent_.logWriter_, 1982 new ClientMessageId(SQLState.TABLE_NAME_CANNOT_BE_NULL)); 1983 } 1984 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLSTATISTICS(?,?,?,?,?,?)"); 1985 1986 cs.setStringX(1, catalog); 1987 cs.setStringX(2, schema); 1988 cs.setStringX(3, table); 1989 1990 if (unique) { 1991 cs.setShortX(4, SQL_INDEX_UNIQUE); 1992 } else { 1993 cs.setShortX(4, SQL_INDEX_ALL); 1994 } 1995 1996 if (approximate) { 1997 cs.setShortX(5, (short) 1); 1998 } else { 1999 cs.setShortX(5, (short) 0); 2000 } 2001 2002 cs.setStringX(6, getOptions()); 2003 return executeCatalogQuery(cs); 2004 } 2005 2006 2007 2009 public java.sql.ResultSet getUDTs(String catalog, 2010 String schemaPattern, 2011 String typeNamePattern, 2012 int[] types) throws SQLException { 2013 try 2014 { 2015 synchronized (connection_) { 2016 if (agent_.loggingEnabled()) { 2017 agent_.logWriter_.traceEntry(this, "getUDTs", catalog, schemaPattern, typeNamePattern, types); 2018 } 2019 return getUDTsX(catalog, schemaPattern, typeNamePattern, types); 2020 } 2021 } 2022 catch ( SqlException se ) 2023 { 2024 throw se.getSQLException(); 2025 } 2026 } 2027 2028 private ResultSet getUDTsX(String catalog, 2029 String schemaPattern, 2030 String typeNamePattern, 2031 int[] types) throws SqlException { 2032 checkForClosedConnectionX(); 2033 ; 2034 2035 PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLUDTS(?,?,?,?,?)"); 2036 2037 cs.setStringX(1, catalog); 2038 cs.setStringX(2, schemaPattern); 2039 cs.setStringX(3, typeNamePattern); 2040 int i = 0; 2041 String udtTypes = new String (); 2042 while (types != null && i < types.length) { 2043 if (i > 0) { 2044 udtTypes = udtTypes.concat(","); 2045 } 2046 udtTypes = udtTypes.concat(String.valueOf(types[i])); 2047 i++; 2048 } 2049 cs.setStringX(4, udtTypes); 2050 cs.setStringX(5, getOptions()); 2051 return executeCatalogQuery(cs); 2052 } 2053 2054 2055 private String getOptions() { 2057 int cursorHold; 2058 if (connection_.holdability() == JDBC30Translation.HOLD_CURSORS_OVER_COMMIT) { 2059 cursorHold = 1; 2060 } else { 2061 cursorHold = 0; 2062 } 2063 return "DATATYPE='JDBC';DYNAMIC=0;REPORTPUBLICPRIVILEGES=1;CURSORHOLD=" + cursorHold; 2064 2065 } 2066 2067 private ResultSet executeCatalogQuery(PreparedStatement cs) 2069 throws SqlException { 2070 try { 2071 return cs.executeQueryX(); 2072 } catch (SqlException e) { 2073 if (e.getErrorCode() == -440) { 2074 SqlException newException = new SqlException(agent_.logWriter_, 2075 new ClientMessageId(SQLState.STORED_PROC_NOT_INSTALLED)); 2076 newException.setNextException(e); 2077 throw newException; 2078 } else if (e.getErrorCode() == -444) { 2079 SqlException newException = new SqlException(agent_.logWriter_, 2080 new ClientMessageId(SQLState.STORED_PROC_LOAD_MODULE_NOT_FOUND)); 2081 newException.setNextException(e); 2082 throw newException; 2083 } else { 2084 throw e; 2085 } 2086 } 2087 } 2088 2089 public java.sql.Connection getConnection() throws SQLException { 2090 checkForClosedConnection(); 2091 return connection_; 2092 } 2093 2094 2096 public boolean supportsNamedParameters() throws SQLException { 2097 checkForClosedConnection(); 2098 return false; 2099 } 2100 2101 public boolean supportsMultipleOpenResults() throws SQLException { 2102 checkForClosedConnection(); 2103 return true; 2104 } 2105 2106 public boolean supportsGetGeneratedKeys() throws SQLException { 2107 checkForClosedConnection(); 2108 return false; 2109 } 2110 2111 public java.sql.ResultSet getSuperTypes(String catalog, 2112 String schemaPattern, 2113 String typeNamePattern) throws SQLException { 2114 try 2115 { 2116 synchronized (connection_) { 2117 if (agent_.loggingEnabled()) { 2118 agent_.logWriter_.traceEntry(this, "getSuperTypes", catalog, schemaPattern, typeNamePattern); 2119 } 2120 return getSuperTypesX(); 2121 } 2122 } 2123 catch ( SqlException se ) 2124 { 2125 throw se.getSQLException(); 2126 } 2127 } 2128 2129 private ResultSet getSuperTypesX() throws SqlException { 2130 checkForClosedConnectionX(); 2131 String sql = "SELECT CAST(NULL AS VARCHAR(128)) AS TYPE_CAT," + 2132 "CAST(NULL AS VARCHAR(128)) AS TYPE_SCHEM," + 2133 "VARCHAR('', 128) AS TYPE_NAME," + 2134 "CAST(NULL AS VARCHAR(128)) AS SUPERTYPE_CAT," + 2135 "CAST(NULL AS VARCHAR(128)) AS SUPERTYPE_SCHEM," + 2136 "VARCHAR('', 128) AS SUPERTYPE_NAME " + 2137 "FROM SYSIBM.SYSDUMMY1 WHERE 1=0 WITH UR "; 2138 PreparedStatement ps = connection_.prepareDynamicCatalogQuery(sql); 2139 return ps.executeQueryX(); 2140 } 2141 2142 public java.sql.ResultSet getSuperTables(String catalog, 2143 String schemaPattern, 2144 String tableNamePattern) throws SQLException { 2145 try 2146 { 2147 synchronized (connection_) { 2148 if (agent_.loggingEnabled()) { 2149 agent_.logWriter_.traceEntry(this, "getSuperTables", catalog, schemaPattern, tableNamePattern); 2150 } 2151 return getSuperTablesX(); 2152 } 2153 } 2154 catch ( SqlException se ) 2155 { 2156 throw se.getSQLException(); 2157 } 2158 } 2159 2160 private ResultSet getSuperTablesX() throws SqlException { 2161 checkForClosedConnectionX(); 2162 java.lang.String sql = "SELECT CAST(NULL AS VARCHAR(128)) AS TABLE_CAT," + 2163 "CAST(NULL AS VARCHAR(128)) AS TABLE_SCHEM," + 2164 "VARCHAR('', 128) AS TABLE_NAME," + 2165 "VARCHAR('', 128) AS SUPERTABLE_NAME FROM SYSIBM.SYSDUMMY1 " + 2166 "WHERE 1=0 WITH UR"; 2167 PreparedStatement ps = connection_.prepareDynamicCatalogQuery(sql); 2168 return ps.executeQueryX(); 2169 } 2170 2171 2172 public java.sql.ResultSet getAttributes(String catalog, 2173 String schemaPattern, 2174 String typeNamePattern, 2175 String attributeNamePattern) throws SQLException { 2176 try 2177 { 2178 synchronized (connection_) { 2179 if (agent_.loggingEnabled()) { 2180 agent_.logWriter_.traceEntry(this, "getAttributes", catalog, schemaPattern, typeNamePattern, attributeNamePattern); 2181 } 2182 return getAttributesX(); 2183 } 2184 } 2185 catch ( SqlException se ) 2186 { 2187 throw se.getSQLException(); 2188 } 2189 } 2190 2191 private ResultSet getAttributesX() throws SqlException { 2192 checkForClosedConnectionX(); 2193 java.lang.String sql = "SELECT CAST(NULL AS VARCHAR(128)) AS TYPE_CAT," + 2194 "CAST(NULL AS VARCHAR(128)) AS TYPE_SCHEM," + 2195 "VARCHAR('', 128) AS TYPE_NAME," + 2196 "VARCHAR('',128) AS ATTR_NAME," + 2197 "0 AS DATA_TYPE," + 2198 "VARCHAR('',129) AS ATTR_TYPE_NAME," + 2199 "0 AS ATTR_SIZE," + 2200 "0 AS DECIMAL_DIGITS," + 2201 "0 AS NUM_PREC_RADIX," + 2202 "2 AS NULLABLE," + 2203 "CAST(NULL AS VARCHAR(254)) AS REMARKS," + 2204 "CAST(NULL AS VARCHAR(128)) AS ATTR_DEF," + 2205 "0 AS SQL_DATA_TYPE," + 2206 "0 AS SQL_DATETIME_SUB," + 2207 "0 AS CHAR_OCTET_LENGTH," + 2208 "0 AS ORDINAL_POSITION," + 2209 "VARCHAR('',128) AS IS_NULLABLE," + 2210 "CAST(NULL AS VARCHAR(128)) AS SCOPE_CATALOG," + 2211 "CAST(NULL AS VARCHAR(128)) AS SCOPE_SCHEMA," + 2212 "CAST(NULL AS VARCHAR(128)) AS SCOPE_TABLE," + 2213 "CAST(NULL AS SMALLINT) AS SOURCE_DATA_TYPE " + 2214 "FROM SYSIBM.SYSDUMMY1 WHERE 1=0 WITH UR"; 2215 PreparedStatement ps = connection_.prepareDynamicCatalogQuery(sql); 2216 return ps.executeQueryX(); 2217 } 2218 2219 public boolean supportsResultSetHoldability(int holdability) throws SQLException { 2220 checkForClosedConnection(); 2221 return true; 2222 } 2223 2224 public int getResultSetHoldability() throws SQLException { 2225 checkForClosedConnection(); 2226 return java.sql.ResultSet.HOLD_CURSORS_OVER_COMMIT; 2227 } 2228 2229 public int getDatabaseMajorVersion() throws SQLException { 2230 checkForClosedConnection(); 2231 return productLevel_.versionLevel_; 2232 } 2233 2234 public int getDatabaseMinorVersion() throws SQLException { 2235 checkForClosedConnection(); 2236 return productLevel_.releaseLevel_; 2237 } 2238 2239 public int getJDBCMajorVersion() throws SQLException { 2240 checkForClosedConnection(); 2241 return 3; 2242 } 2243 2244 public int getJDBCMinorVersion() throws SQLException { 2245 checkForClosedConnection(); 2246 return 0; 2247 } 2248 2249 public int getSQLStateType() throws SQLException { 2250 checkForClosedConnection(); 2251 return sqlStateSQL99; 2252 } 2253 2254 public boolean locatorsUpdateCopy() throws SQLException { 2255 checkForClosedConnection(); 2256 return false; 2257 } 2258 2259 public boolean supportsStatementPooling() throws SQLException { 2260 checkForClosedConnection(); 2261 return false; 2262 } 2263 2264 2266 abstract protected void computeFeatureSet_(); 2268 2269 2271 2272 private boolean getMetaDataInfoBoolean(int infoCallIndex) throws SQLException { 2273 try 2274 { 2275 if (metaDataInfoIsCached_) { 2276 return ((Integer ) metaDataInfoCache_[infoCallIndex]).intValue() != 0; 2277 } 2278 metaDataInfoCall(); 2279 return ((Integer ) metaDataInfoCache_[infoCallIndex]).intValue() != 0; 2280 } 2281 catch ( SqlException se ) 2282 { 2283 throw se.getSQLException(); 2284 } 2285 } 2286 2287 private int getMetaDataInfoInt(int infoCallIndex) throws SQLException { 2288 try 2289 { 2290 if (metaDataInfoIsCached_) { 2291 return ((Integer ) metaDataInfoCache_[infoCallIndex]).intValue(); 2292 } 2293 metaDataInfoCall(); 2294 return ((Integer ) metaDataInfoCache_[infoCallIndex]).intValue(); 2295 } 2296 catch ( SqlException se ) 2297 { 2298 throw se.getSQLException(); 2299 } 2300 2301 } 2302 2303 private String getMetaDataInfoString(int infoCallIndex) throws SQLException { 2304 try 2305 { 2306 if (metaDataInfoIsCached_) { 2307 return (String ) metaDataInfoCache_[infoCallIndex]; 2308 } 2309 metaDataInfoCall(); 2310 return (String ) metaDataInfoCache_[infoCallIndex]; 2311 } 2312 catch ( SqlException se ) 2313 { 2314 throw se.getSQLException(); 2315 } 2316 } 2317 2318 2319 private boolean getMetaDataInfoBooleanWithType(int infoCallIndex, int type) 2320 throws SQLException { 2321 2322 boolean clientValue = 2323 getMetaDataInfoBooleanWithTypeClient(infoCallIndex, type); 2324 2325 2340 2347 return clientValue; 2348 } 2349 2350 2351 private boolean getMetaDataInfoBooleanWithTypeClient(int infoCallIndex, 2367 int type) 2368 throws SQLException { 2369 2370 switch (infoCallIndex) { 2371 case updatesAreDetected__: 2372 case deletesAreDetected__: 2373 case ownUpdatesAreVisible__: 2374 case ownDeletesAreVisible__: 2375 2376 if (productLevel_.greaterThanOrEqualTo(10,2,0) && 2377 type == ResultSet.TYPE_SCROLL_INSENSITIVE) { 2378 return true; 2379 } else { 2380 return getMetaDataInfoBooleanWithTypeServer(infoCallIndex, 2381 type); 2382 } 2383 case insertsAreDetected__: 2384 case ownInsertsAreVisible__: 2385 if (productLevel_.greaterThanOrEqualTo(10,2,0) && 2386 type == ResultSet.TYPE_SCROLL_INSENSITIVE) { 2387 return false; 2388 } else { 2389 return getMetaDataInfoBooleanWithTypeServer(infoCallIndex, 2390 type); 2391 } 2392 default: 2393 return getMetaDataInfoBooleanWithTypeServer(infoCallIndex, 2394 type); 2395 } 2396 } 2397 2398 2399 private boolean getMetaDataInfoBooleanWithTypeServer(int infoCallIndex, 2400 int type) 2401 throws SQLException { 2402 2403 try 2407 { 2408 String returnedFromSP = null; 2409 if (metaDataInfoIsCached_) { 2410 returnedFromSP = (String ) metaDataInfoCache_[infoCallIndex]; 2411 } else { 2412 metaDataInfoCall(); 2413 returnedFromSP = (String ) metaDataInfoCache_[infoCallIndex]; 2414 } 2415 java.util.StringTokenizer st = new java.util.StringTokenizer (returnedFromSP, ","); 2416 while (st.hasMoreTokens()) { 2417 if ((new Integer (st.nextToken())).intValue() == type) { 2418 return true; 2419 } 2420 } 2421 return false; 2422 } 2423 catch ( SqlException se ) 2424 { 2425 throw se.getSQLException(); 2426 } 2427 } 2428 2429 private boolean getMetaDataInfoInt_SupportsResultSetConcurrency(int infoCallIndex, int type, int concurrency) throws SQLException { 2430 try 2445 { 2446 String returnedFromSP = null; 2447 if (metaDataInfoIsCached_) { 2448 returnedFromSP = (String ) metaDataInfoCache_[infoCallIndex]; 2449 } else { 2450 metaDataInfoCall(); 2451 returnedFromSP = (String ) metaDataInfoCache_[infoCallIndex]; 2452 } 2453 java.util.StringTokenizer st = new java.util.StringTokenizer (returnedFromSP, ";"); 2454 while (st.hasMoreTokens()) { 2455 java.util.StringTokenizer stForConc = 2456 new java.util.StringTokenizer (st.nextToken(), ","); 2457 if ((new Integer (stForConc.nextToken())).intValue() == type) { 2458 while (stForConc.hasMoreTokens()) { 2459 if ((new Integer (stForConc.nextToken())).intValue() == concurrency) { 2460 return true; 2461 } 2462 } 2463 return false; 2464 } 2465 } 2466 return false; 2467 } 2468 catch ( SqlException se ) 2469 { 2470 throw se.getSQLException(); 2471 } 2472 } 2473 2474 private boolean getMetaDataInfoBoolean_supportsConvert(int infoCallIndex, int fromType, int toType) throws SQLException { 2475 try 2481 { 2482 String returnedFromSP = null; 2483 if (metaDataInfoIsCached_) { 2484 returnedFromSP = (String ) metaDataInfoCache_[infoCallIndex]; 2485 } else { 2486 metaDataInfoCall(); 2487 returnedFromSP = (String ) metaDataInfoCache_[infoCallIndex]; 2488 } 2489 java.util.StringTokenizer st = new java.util.StringTokenizer (returnedFromSP, ";"); 2490 while (st.hasMoreTokens()) { 2491 java.util.StringTokenizer stForType = new java.util.StringTokenizer (st.nextToken(), ","); 2492 if ((new Integer (stForType.nextToken())).intValue() == fromType) { 2493 while (st.hasMoreTokens()) { 2494 if ((new Integer (st.nextToken())).intValue() == toType) { 2495 return true; 2496 } 2497 } 2498 return false; 2499 } 2500 } 2501 return false; 2502 } 2503 catch ( SqlException se ) 2504 { 2505 throw se.getSQLException(); 2506 } 2507 } 2508 2509 private void metaDataInfoCall() throws SqlException { 2513 synchronized (connection_) { 2514 ResultSet rs; 2515 2516 PreparedStatement ps = prepareMetaDataQuery("SYSIBM.MetaData()"); 2520 rs = (ResultSet) ps.executeQueryX(); 2521 rs.nextX(); 2522 int ColumnCount; 2523 try { 2524 ColumnCount = ((ColumnMetaData) rs.getMetaDataX()).getColumnCount(); 2525 } catch ( SQLException se ) { 2526 throw new SqlException(se); 2527 } 2528 for (int infoCallIndex = 0; 2529 (infoCallIndex < ColumnCount && infoCallIndex < metaDataInfoCache_.length); 2530 infoCallIndex++) { 2531 metaDataInfoCache_[infoCallIndex] = rs.getObjectX(infoCallIndex + 1); 2532 } 2533 metaDataInfoIsCached_ = true; 2534 rs.closeX(); 2535 } 2536 } 2537 2538 2540 2547 public final boolean supportsStoredFunctionsUsingCallSyntax() 2548 throws SQLException 2549 { 2550 checkForClosedConnection(); 2551 return true; 2552 } 2553 2554 2563 public final boolean autoCommitFailureClosesAllResultSets() 2564 throws SQLException 2565 { 2566 checkForClosedConnection(); 2567 return false; 2568 } 2569 2570 2578 public final boolean providesQueryObjectGenerator() throws SQLException { 2579 checkForClosedConnection(); 2580 return false; 2581 } 2582 2583 2603 public ResultSet getSchemas(String catalog, String schemaPattern) 2604 throws SQLException 2605 { 2606 try { 2607 synchronized (connection_) { 2608 if (agent_.loggingEnabled()) { 2609 agent_.logWriter_.traceEntry(this, "getSchemas"); 2610 } 2611 return getSchemasX(catalog, schemaPattern); 2612 } 2613 } catch (SqlException se) { 2614 throw se.getSQLException(); 2615 } 2616 } 2617 2618 2627 private ResultSet getSchemasX(String catalog, String schemaPattern) 2628 throws SqlException 2629 { 2630 checkForClosedConnectionX(); 2631 2632 checkServerJdbcVersionX("getSchemas(String, String)", 4, 0); 2638 2639 String call = "SYSIBM.SQLTABLES(?, ?, '', '', 'GETSCHEMAS=2')"; 2640 PreparedStatement cs = prepareMetaDataQuery(call); 2641 if (catalog == null) { 2642 cs.setNullX(1, java.sql.Types.VARCHAR); 2643 } else { 2644 cs.setStringX(1, catalog); 2645 } 2646 if (schemaPattern == null) { 2647 cs.setNullX(2, java.sql.Types.VARCHAR); 2648 } else { 2649 cs.setStringX(2, schemaPattern); 2650 } 2651 return cs.executeQueryX(); 2652 } 2653 2654 2673 public ResultSet getClientInfoProperties() throws SQLException { 2674 try { 2675 synchronized (connection_) { 2676 if (agent_.loggingEnabled()) { 2677 agent_.logWriter_.traceEntry(this, 2678 "getClientInfoProperties"); 2679 } 2680 return getClientInfoPropertiesX(); 2681 } 2682 } catch (SqlException se) { 2683 throw se.getSQLException(); 2684 } 2685 } 2686 2687 2696 private ResultSet getClientInfoPropertiesX() throws SqlException { 2697 checkForClosedConnectionX(); 2698 final String sql = 2699 "SELECT CAST(NULL AS VARCHAR(128)) AS NAME, " + 2700 "CAST(NULL AS INT) AS MAX_LEN, " + 2701 "CAST(NULL AS VARCHAR(128)) AS DEFAULT_VALUE, " + 2702 "CAST(NULL AS VARCHAR(128)) AS DESCRIPTION " + 2703 "FROM SYSIBM.SYSDUMMY1 WHERE 1=0 WITH UR"; 2704 PreparedStatement ps = connection_.prepareDynamicCatalogQuery(sql); 2705 return ps.executeQueryX(); 2706 } 2707 2708 2710 2711 private PreparedStatement prepareMetaDataQuery(String cmd) throws SqlException { 2712 PreparedStatement ps; 2713 2714 ps = (org.apache.derby.client.am.PreparedStatement) 2715 connection_.prepareStatementX("CALL " + cmd, 2716 java.sql.ResultSet.TYPE_FORWARD_ONLY, 2717 java.sql.ResultSet.CONCUR_READ_ONLY, 2718 connection_.holdability(), 2719 java.sql.Statement.NO_GENERATED_KEYS, 2720 null); 2721 return ps; 2722 } 2723 2724 2729 protected void checkForClosedConnection() throws SQLException 2730 { 2731 try { 2732 checkForClosedConnectionX(); 2733 } catch ( SqlException se ) { 2734 throw se.getSQLException(); 2735 } 2736 } 2737 2738 private void checkForClosedConnectionX() throws SqlException { 2739 if (connection_.isClosedX()) { 2740 agent_.checkForDeferredExceptions(); 2741 throw new SqlException(agent_.logWriter_, 2742 new ClientMessageId(SQLState.NO_CURRENT_CONNECTION)); 2743 2744 } else { 2745 agent_.checkForDeferredExceptions(); 2746 } 2747 } 2748 2749 2761 protected void checkServerJdbcVersionX(String method, int major, int minor) 2762 throws SqlException 2763 { 2764 if (serverJdbcMajorVersion < major || 2765 (serverJdbcMajorVersion == major && 2766 serverJdbcMinorVersion < minor)) { 2767 throw new SqlException(agent_.logWriter_, 2768 new ClientMessageId(SQLState.JDBC_METHOD_NOT_SUPPORTED_BY_SERVER), method); 2769 } 2770 } 2771} 2772 | Popular Tags |