1 23 24 package org.continuent.sequoia.controller.backend; 25 26 import java.lang.reflect.InvocationTargetException ; 27 import java.lang.reflect.Method ; 28 import java.sql.Connection ; 29 import java.sql.DatabaseMetaData ; 30 import java.sql.ResultSet ; 31 import java.sql.SQLException ; 32 33 import org.continuent.sequoia.common.i18n.Translate; 34 import org.continuent.sequoia.common.log.Trace; 35 import org.continuent.sequoia.common.sql.metadata.MetadataContainer; 36 import org.continuent.sequoia.common.sql.metadata.MetadataDescription; 37 import org.continuent.sequoia.controller.connection.AbstractConnectionManager; 38 import org.continuent.sequoia.controller.connection.PooledConnection; 39 import org.continuent.sequoia.controller.sql.schema.DatabaseSchema; 40 import org.continuent.sequoia.controller.sql.schema.DynamicDatabaseSchema; 41 42 55 public final class DatabaseBackendMetaData 56 { 57 58 private AbstractConnectionManager connectionManager; 59 60 61 private Trace logger; 62 63 64 private DatabaseSchema databaseSchema; 65 66 67 private DynamicDatabaseSchema dynamicDatabaseSchema; 68 69 70 private String vdbName; 71 72 73 private MetadataContainer metadataContainer = null; 74 75 88 public DatabaseBackendMetaData(AbstractConnectionManager connectionManager, 89 Trace logger, DynamicDatabaseSchema dynamicDatabaseSchema, String vdbName) 90 { 91 this.connectionManager = connectionManager; 92 this.dynamicDatabaseSchema = dynamicDatabaseSchema; 93 this.logger = logger; 94 this.vdbName = vdbName; 95 } 96 97 106 private void insertMetadataInContainer(DatabaseMetaData metaData, 107 String methodName, Class [] parametersType, Object [] arguments) 108 { 109 Class metadataClass = metaData.getClass(); 110 try 111 { 112 Method method = metadataClass.getMethod(methodName, parametersType); 113 Object result = method.invoke(metaData, arguments); 114 updateContainerInformation(methodName, parametersType, arguments, result); 115 } 116 catch (SecurityException e) 117 { 118 if (logger.isDebugEnabled()) 119 logger.debug("Problem calling " + methodName, e); 120 else 121 logger.warn("Unable to get information for " + methodName); 122 } 123 catch (IllegalArgumentException e) 124 { 125 if (logger.isDebugEnabled()) 126 logger.debug("Problem calling " + methodName, e); 127 else 128 logger.warn("Unable to get information for " + methodName); 129 } 130 catch (NoSuchMethodException e) 131 { 132 if (logger.isDebugEnabled()) 133 logger.debug("Metadata " + methodName 134 + " does not exists. Probably not supported by your JDK."); 135 } 136 catch (IllegalAccessException e) 137 { 138 if (logger.isDebugEnabled()) 139 logger.debug("Problem calling " + methodName, e); 140 else 141 logger.warn("Unable to get information for " + methodName); 142 } 143 catch (InvocationTargetException e) 144 { 145 if (logger.isDebugEnabled()) 146 logger.debug("Problem calling " + methodName, e); 147 else 148 logger.warn("Unable to get information for " + methodName); 149 } 150 catch (AbstractMethodError e) 151 { 152 if (logger.isDebugEnabled()) 156 logger.debug("Metadata " + methodName 157 + " does not exists. Probably not supported by your jdbc-driver."); 158 } 159 } 160 161 169 private void updateContainerInformation(String methodName, 170 Class [] parametersType, Object [] arguments, Object result) 171 { 172 String key = MetadataContainer.getContainerKey(methodName, parametersType, 173 arguments); 174 metadataContainer.put(key, result); 175 if (logger.isDebugEnabled()) 176 logger.debug("Updating metadata " + key + "=" + result); 177 } 178 179 187 public MetadataContainer retrieveDatabaseMetadata() throws SQLException 188 { 189 if (metadataContainer != null) 190 return metadataContainer; 191 192 boolean wasInitialized = connectionManager.isInitialized(); 194 195 DatabaseMetaData metaData; 196 PooledConnection pooledConnection = null; 197 try 198 { 199 if (!wasInitialized) 200 connectionManager.initializeConnections(); 201 202 pooledConnection = connectionManager.retrieveConnectionInAutoCommit(null); 203 if (pooledConnection == null) 204 { 205 String msg = Translate.get("backend.meta.connection.failed"); 206 logger.error(msg); 207 throw new SQLException (msg); 208 } 209 Connection connection = pooledConnection.getConnection(); 210 if (connection == null) 211 { 212 String msg = Translate.get("backend.meta.connection.failed"); 213 logger.error(msg); 214 throw new SQLException (msg); 215 } 216 217 metaData = connection.getMetaData(); 218 metadataContainer = new MetadataContainer(connection.getMetaData() 219 .getURL()); 220 221 224 insertMetadataInContainer(metaData, 228 MetadataDescription.ALL_PROCEDURES_ARE_CALLABLE, null, null); 229 insertMetadataInContainer(metaData, 230 MetadataDescription.ALL_TABLES_ARE_SELECTABLE, null, null); 231 insertMetadataInContainer(metaData, 232 MetadataDescription.DATA_DEFINITION_CAUSES_TRANSACTION_COMMIT, null, 233 null); 234 insertMetadataInContainer(metaData, 235 MetadataDescription.DATA_DEFINITION_IGNORED_IN_TRANSACTIONS, null, 236 null); 237 insertMetadataInContainer(metaData, 238 MetadataDescription.DELETES_ARE_DETECTED, new Class []{Integer.TYPE}, 239 new Object []{new Integer (ResultSet.TYPE_FORWARD_ONLY)}); 240 insertMetadataInContainer(metaData, 241 MetadataDescription.DELETES_ARE_DETECTED, new Class []{Integer.TYPE}, 242 new Object []{new Integer (ResultSet.TYPE_SCROLL_INSENSITIVE)}); 243 insertMetadataInContainer(metaData, 244 MetadataDescription.DELETES_ARE_DETECTED, new Class []{Integer.TYPE}, 245 new Object []{new Integer (ResultSet.TYPE_SCROLL_SENSITIVE)}); 246 insertMetadataInContainer(metaData, 247 MetadataDescription.DOES_MAX_ROW_SIZE_INCLUDE_BLOBS, null, null); 248 insertMetadataInContainer(metaData, 249 MetadataDescription.GET_DEFAULT_TRANSACTION_ISOLATION, null, null); 250 insertMetadataInContainer(metaData, 251 MetadataDescription.GET_DATABASE_MAJOR_VERSION, null, null); 252 insertMetadataInContainer(metaData, 253 MetadataDescription.GET_DATABASE_MINOR_VERSION, null, null); 254 insertMetadataInContainer(metaData, 255 MetadataDescription.GET_DRIVER_MAJOR_VERSION, null, null); 256 insertMetadataInContainer(metaData, 257 MetadataDescription.GET_DRIVER_MINOR_VERSION, null, null); 258 insertMetadataInContainer(metaData, 259 MetadataDescription.GET_JDBC_MAJOR_VERSION, null, null); 260 insertMetadataInContainer(metaData, 261 MetadataDescription.GET_JDBC_MINOR_VERSION, null, null); 262 insertMetadataInContainer(metaData, 263 MetadataDescription.GET_MAX_BINARY_LITERAL_LENGTH, null, null); 264 insertMetadataInContainer(metaData, 265 MetadataDescription.GET_RESULTSET_HOLDABILITY, null, null); 266 insertMetadataInContainer(metaData, 267 MetadataDescription.GET_SQL_STATE_TYPE, null, null); 268 insertMetadataInContainer(metaData, 269 MetadataDescription.GET_MAX_CATALOG_NAME_LENGTH, null, null); 270 insertMetadataInContainer(metaData, 271 MetadataDescription.GET_MAX_CHAR_LITERAL_LENGTH, null, null); 272 insertMetadataInContainer(metaData, 273 MetadataDescription.GET_MAX_COLUMN_NAME_LENGTH, null, null); 274 insertMetadataInContainer(metaData, 275 MetadataDescription.GET_MAX_COLUMNS_IN_GROUP_BY, null, null); 276 insertMetadataInContainer(metaData, 277 MetadataDescription.GET_MAX_COLUMNS_IN_INDEX, null, null); 278 insertMetadataInContainer(metaData, 279 MetadataDescription.GET_MAX_COLUMNS_IN_ORDER_BY, null, null); 280 insertMetadataInContainer(metaData, 281 MetadataDescription.GET_MAX_COLUMNS_IN_SELECT, null, null); 282 insertMetadataInContainer(metaData, 283 MetadataDescription.GET_MAX_COLUMNS_IN_TABLE, null, null); 284 insertMetadataInContainer(metaData, 285 MetadataDescription.GET_MAX_CONNECTIONS, null, null); 286 insertMetadataInContainer(metaData, 287 MetadataDescription.GET_MAX_CURSOR_NAME_LENGTH, null, null); 288 insertMetadataInContainer(metaData, 289 MetadataDescription.GET_MAX_INDEX_LENGTH, null, null); 290 insertMetadataInContainer(metaData, 291 MetadataDescription.GET_MAX_PROCEDURE_NAME_LENGTH, null, null); 292 insertMetadataInContainer(metaData, MetadataDescription.GET_MAX_ROW_SIZE, 293 null, null); 294 insertMetadataInContainer(metaData, 295 MetadataDescription.GET_MAX_SCHEMA_NAME_LENGTH, null, null); 296 insertMetadataInContainer(metaData, 297 MetadataDescription.GET_MAX_STATEMENT_LENGTH, null, null); 298 insertMetadataInContainer(metaData, 299 MetadataDescription.GET_MAX_STATEMENTS, null, null); 300 insertMetadataInContainer(metaData, 301 MetadataDescription.GET_MAX_TABLE_NAME_LENGTH, null, null); 302 insertMetadataInContainer(metaData, 303 MetadataDescription.GET_MAX_TABLES_IN_SELECT, null, null); 304 insertMetadataInContainer(metaData, 305 MetadataDescription.GET_MAX_USER_NAME_LENGTH, null, null); 306 insertMetadataInContainer(metaData, 308 MetadataDescription.GET_CATALOG_SEPARATOR, null, null); 309 insertMetadataInContainer(metaData, MetadataDescription.GET_CATALOG_TERM, 310 null, null); 311 insertMetadataInContainer(metaData, 312 MetadataDescription.GET_DATABASE_PRODUCT_NAME, null, null); 313 insertMetadataInContainer(metaData, MetadataDescription.GET_DRIVER_NAME, 314 null, null); 315 insertMetadataInContainer(metaData, 316 MetadataDescription.GET_DRIVER_VERSION, null, null); 317 insertMetadataInContainer(metaData, 318 MetadataDescription.GET_EXTRA_NAME_CHARACTERS, null, null); 319 insertMetadataInContainer(metaData, 320 MetadataDescription.GET_IDENTIFIER_QUOTE_STRING, null, null); 321 insertMetadataInContainer(metaData, 322 MetadataDescription.GET_NUMERIC_FUNCTIONS, null, null); 323 insertMetadataInContainer(metaData, 324 MetadataDescription.GET_PROCEDURE_TERM, null, null); 325 insertMetadataInContainer(metaData, MetadataDescription.GET_SCHEMA_TERM, 326 null, null); 327 insertMetadataInContainer(metaData, 328 MetadataDescription.GET_SEARCH_STRING_ESCAPE, null, null); 329 insertMetadataInContainer(metaData, MetadataDescription.GET_SQL_KEYWORDS, 330 null, null); 331 insertMetadataInContainer(metaData, 332 MetadataDescription.GET_STRING_FUNCTIONS, null, null); 333 insertMetadataInContainer(metaData, 334 MetadataDescription.GET_SYSTEM_FUNCTIONS, null, null); 335 insertMetadataInContainer(metaData, 336 MetadataDescription.GET_TIME_DATE_FUNCTIONS, null, null); 337 insertMetadataInContainer(metaData, 338 MetadataDescription.INSERTS_ARE_DETECTED, new Class []{Integer.TYPE}, 339 new Object []{new Integer (ResultSet.TYPE_FORWARD_ONLY)}); 340 insertMetadataInContainer(metaData, 341 MetadataDescription.INSERTS_ARE_DETECTED, new Class []{Integer.TYPE}, 342 new Object []{new Integer (ResultSet.TYPE_SCROLL_INSENSITIVE)}); 343 insertMetadataInContainer(metaData, 344 MetadataDescription.INSERTS_ARE_DETECTED, new Class []{Integer.TYPE}, 345 new Object []{new Integer (ResultSet.TYPE_SCROLL_SENSITIVE)}); 346 insertMetadataInContainer(metaData, 347 MetadataDescription.LOCATORS_UPDATE_COPY, null, null); 348 insertMetadataInContainer(metaData, 349 MetadataDescription.NULL_PLUS_NON_NULL_IS_NULL, null, null); 350 insertMetadataInContainer(metaData, 351 MetadataDescription.NULLS_ARE_SORTED_AT_END, null, null); 352 insertMetadataInContainer(metaData, 353 MetadataDescription.NULLS_ARE_SORTED_AT_START, null, null); 354 insertMetadataInContainer(metaData, 355 MetadataDescription.NULLS_ARE_SORTED_HIGH, null, null); 356 insertMetadataInContainer(metaData, 357 MetadataDescription.NULLS_ARE_SORTED_LOW, null, null); 358 insertMetadataInContainer(metaData, 359 MetadataDescription.OTHERS_DELETES_ARE_VISIBLE, 360 new Class []{Integer.TYPE}, new Object []{new Integer ( 361 ResultSet.TYPE_FORWARD_ONLY)}); 362 insertMetadataInContainer(metaData, 363 MetadataDescription.OTHERS_DELETES_ARE_VISIBLE, 364 new Class []{Integer.TYPE}, new Object []{new Integer ( 365 ResultSet.TYPE_SCROLL_INSENSITIVE)}); 366 insertMetadataInContainer(metaData, 367 MetadataDescription.OTHERS_DELETES_ARE_VISIBLE, 368 new Class []{Integer.TYPE}, new Object []{new Integer ( 369 ResultSet.TYPE_SCROLL_SENSITIVE)}); 370 insertMetadataInContainer(metaData, 371 MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE, 372 new Class []{Integer.TYPE}, new Object []{new Integer ( 373 ResultSet.TYPE_FORWARD_ONLY)}); 374 insertMetadataInContainer(metaData, 375 MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE, 376 new Class []{Integer.TYPE}, new Object []{new Integer ( 377 ResultSet.TYPE_SCROLL_INSENSITIVE)}); 378 insertMetadataInContainer(metaData, 379 MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE, 380 new Class []{Integer.TYPE}, new Object []{new Integer ( 381 ResultSet.TYPE_SCROLL_SENSITIVE)}); 382 insertMetadataInContainer(metaData, 383 MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE, 384 new Class []{Integer.TYPE}, new Object []{new Integer ( 385 ResultSet.TYPE_FORWARD_ONLY)}); 386 insertMetadataInContainer(metaData, 387 MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE, 388 new Class []{Integer.TYPE}, new Object []{new Integer ( 389 ResultSet.TYPE_SCROLL_INSENSITIVE)}); 390 insertMetadataInContainer(metaData, 391 MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE, 392 new Class []{Integer.TYPE}, new Object []{new Integer ( 393 ResultSet.TYPE_SCROLL_SENSITIVE)}); 394 insertMetadataInContainer(metaData, 395 MetadataDescription.OWN_DELETES_ARE_VISIBLE, 396 new Class []{Integer.TYPE}, new Object []{new Integer ( 397 ResultSet.TYPE_FORWARD_ONLY)}); 398 insertMetadataInContainer(metaData, 399 MetadataDescription.OWN_DELETES_ARE_VISIBLE, 400 new Class []{Integer.TYPE}, new Object []{new Integer ( 401 ResultSet.TYPE_SCROLL_INSENSITIVE)}); 402 insertMetadataInContainer(metaData, 403 MetadataDescription.OWN_DELETES_ARE_VISIBLE, 404 new Class []{Integer.TYPE}, new Object []{new Integer ( 405 ResultSet.TYPE_SCROLL_SENSITIVE)}); 406 insertMetadataInContainer(metaData, 407 MetadataDescription.OWN_INSERTS_ARE_VISIBLE, 408 new Class []{Integer.TYPE}, new Object []{new Integer ( 409 ResultSet.TYPE_FORWARD_ONLY)}); 410 insertMetadataInContainer(metaData, 411 MetadataDescription.OWN_INSERTS_ARE_VISIBLE, 412 new Class []{Integer.TYPE}, new Object []{new Integer ( 413 ResultSet.TYPE_SCROLL_INSENSITIVE)}); 414 insertMetadataInContainer(metaData, 415 MetadataDescription.OWN_INSERTS_ARE_VISIBLE, 416 new Class []{Integer.TYPE}, new Object []{new Integer ( 417 ResultSet.TYPE_SCROLL_SENSITIVE)}); 418 insertMetadataInContainer(metaData, 419 MetadataDescription.OWN_UPDATES_ARE_VISIBLE, 420 new Class []{Integer.TYPE}, new Object []{new Integer ( 421 ResultSet.TYPE_FORWARD_ONLY)}); 422 insertMetadataInContainer(metaData, 423 MetadataDescription.OWN_UPDATES_ARE_VISIBLE, 424 new Class []{Integer.TYPE}, new Object []{new Integer ( 425 ResultSet.TYPE_SCROLL_INSENSITIVE)}); 426 insertMetadataInContainer(metaData, 427 MetadataDescription.OWN_UPDATES_ARE_VISIBLE, 428 new Class []{Integer.TYPE}, new Object []{new Integer ( 429 ResultSet.TYPE_SCROLL_SENSITIVE)}); 430 insertMetadataInContainer(metaData, 431 MetadataDescription.STORES_LOWER_CASE_IDENTIFIERS, null, null); 432 insertMetadataInContainer(metaData, 433 MetadataDescription.STORES_LOWER_CASE_QUOTED_IDENTIFIERS, null, null); 434 insertMetadataInContainer(metaData, 435 MetadataDescription.STORES_MIXED_CASE_IDENTIFIERS, null, null); 436 insertMetadataInContainer(metaData, 437 MetadataDescription.STORES_MIXED_CASE_QUOTED_IDENTIFIERS, null, null); 438 insertMetadataInContainer(metaData, 439 MetadataDescription.STORES_UPPER_CASE_IDENTIFIERS, null, null); 440 insertMetadataInContainer(metaData, 441 MetadataDescription.STORES_UPPER_CASE_QUOTED_IDENTIFIERS, null, null); 442 insertMetadataInContainer(metaData, 443 MetadataDescription.SUPPORTS_ALTER_TABLE_WITH_ADD_COLUMN, null, null); 444 insertMetadataInContainer(metaData, 445 MetadataDescription.SUPPORTS_ALTER_TABLE_WITH_DROP_COLUMN, null, null); 446 insertMetadataInContainer(metaData, 447 MetadataDescription.SUPPORTS_ANSI92_ENTRY_LEVEL_SQL, null, null); 448 insertMetadataInContainer(metaData, 449 MetadataDescription.SUPPORTS_ANSI92_FULL_SQL, null, null); 450 insertMetadataInContainer(metaData, 451 MetadataDescription.SUPPORTS_ANSI92_INTERMEDIATE_SQL, null, null); 452 insertMetadataInContainer(metaData, 453 MetadataDescription.SUPPORTS_BATCH_UPDATES, null, null); 454 insertMetadataInContainer(metaData, 455 MetadataDescription.SUPPORTS_CATALOGS_IN_DATA_MANIPULATION, null, 456 null); 457 insertMetadataInContainer(metaData, 458 MetadataDescription.SUPPORTS_CATALOGS_IN_INDEX_DEFINITIONS, null, 459 null); 460 insertMetadataInContainer(metaData, 461 MetadataDescription.SUPPORTS_CATALOGS_IN_PRIVILEGE_DEFINITIONS, null, 462 null); 463 insertMetadataInContainer(metaData, 464 MetadataDescription.SUPPORTS_CATALOGS_IN_PROCEDURE_CALLS, null, null); 465 insertMetadataInContainer(metaData, 466 MetadataDescription.SUPPORTS_CATALOGS_IN_TABLE_DEFINITIONS, null, 467 null); 468 insertMetadataInContainer(metaData, 469 MetadataDescription.SUPPORTS_COLUMN_ALIASING, null, null); 470 insertMetadataInContainer(metaData, MetadataDescription.SUPPORTS_CONVERT, 471 null, null); 472 insertMetadataInContainer(metaData, 473 MetadataDescription.SUPPORTS_CORE_SQL_GRAMMAR, null, null); 474 insertMetadataInContainer(metaData, 475 MetadataDescription.SUPPORTS_CORRELATED_SUBQUERIES, null, null); 476 insertMetadataInContainer( 477 metaData, 478 MetadataDescription.SUPPORTS_DATA_DEFINITION_AND_DATA_MANIPULATION_TRANSACTIONS, 479 null, null); 480 insertMetadataInContainer(metaData, 481 MetadataDescription.SUPPORTS_DATA_MANIPULATION_TRANSACTIONS_ONLY, 482 null, null); 483 insertMetadataInContainer(metaData, 484 MetadataDescription.SUPPORTS_DIFFERENT_TABLE_CORRELATION_NAMES, null, 485 null); 486 insertMetadataInContainer(metaData, 487 MetadataDescription.SUPPORTS_EXPRESSIONS_IN_ORDER_BY, null, null); 488 insertMetadataInContainer(metaData, 489 MetadataDescription.SUPPORTS_EXTENDED_SQL_GRAMMAR, null, null); 490 insertMetadataInContainer(metaData, 491 MetadataDescription.SUPPORTS_FULL_OUTER_JOINS, null, null); 492 insertMetadataInContainer(metaData, 493 MetadataDescription.SUPPORTS_GET_GENERATED_KEYS, null, null); 494 insertMetadataInContainer(metaData, 495 MetadataDescription.SUPPORTS_GROUP_BY, null, null); 496 insertMetadataInContainer(metaData, 497 MetadataDescription.SUPPORTS_GROUP_BY_BEYOND_SELECT, null, null); 498 insertMetadataInContainer(metaData, 499 MetadataDescription.SUPPORTS_GROUP_BY_UNRELATED, null, null); 500 insertMetadataInContainer(metaData, 501 MetadataDescription.SUPPORTS_INTEGRITY_ENHANCEMENT_FACILITY, null, 502 null); 503 insertMetadataInContainer(metaData, 504 MetadataDescription.SUPPORTS_LIKE_ESCAPE_CLAUSE, null, null); 505 insertMetadataInContainer(metaData, 506 MetadataDescription.SUPPORTS_LIMITED_OUTER_JOINS, null, null); 507 insertMetadataInContainer(metaData, 508 MetadataDescription.SUPPORTS_MINIMUM_SQL_GRAMMAR, null, null); 509 insertMetadataInContainer(metaData, 510 MetadataDescription.SUPPORTS_MIXED_CASE_IDENTIFIERS, null, null); 511 insertMetadataInContainer(metaData, 512 MetadataDescription.SUPPORTS_MIXED_CASE_QUOTED_IDENTIFIERS, null, 513 null); 514 insertMetadataInContainer(metaData, 515 MetadataDescription.SUPPORTS_MULTIPLE_OPEN_RESULTS, null, null); 516 insertMetadataInContainer(metaData, 517 MetadataDescription.SUPPORTS_MULTIPLE_RESULTSETS, null, null); 518 insertMetadataInContainer(metaData, 519 MetadataDescription.SUPPORTS_MULTIPLE_TRANSACTIONS, null, null); 520 insertMetadataInContainer(metaData, 521 MetadataDescription.SUPPORTS_NAMED_PARAMETERS, null, null); 522 insertMetadataInContainer(metaData, 523 MetadataDescription.SUPPORTS_NON_NULLABLE_COLUMNS, null, null); 524 insertMetadataInContainer(metaData, 525 MetadataDescription.SUPPORTS_OPEN_CURSORS_ACROSS_COMMIT, null, null); 526 insertMetadataInContainer(metaData, 527 MetadataDescription.SUPPORTS_OPEN_CURSORS_ACROSS_ROLLBACK, null, null); 528 insertMetadataInContainer(metaData, 529 MetadataDescription.SUPPORTS_OPEN_STATEMENTS_ACROSS_COMMIT, null, 530 null); 531 insertMetadataInContainer(metaData, 532 MetadataDescription.SUPPORTS_OPEN_STATEMENTS_ACROSS_ROLLBACK, null, 533 null); 534 insertMetadataInContainer(metaData, 535 MetadataDescription.SUPPORTS_ORDER_BY_UNRELATED, null, null); 536 insertMetadataInContainer(metaData, 537 MetadataDescription.SUPPORTS_OUTER_JOINS, null, null); 538 insertMetadataInContainer(metaData, 539 MetadataDescription.SUPPORTS_POSITIONED_DELETE, null, null); 540 insertMetadataInContainer(metaData, 541 MetadataDescription.SUPPORTS_POSITIONED_UPDATE, null, null); 542 insertMetadataInContainer(metaData, 543 MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class []{ 544 Integer.TYPE, Integer.TYPE}, new Object []{ 545 new Integer (ResultSet.TYPE_FORWARD_ONLY), 546 new Integer (ResultSet.CONCUR_READ_ONLY)}); 547 insertMetadataInContainer(metaData, 548 MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class []{ 549 Integer.TYPE, Integer.TYPE}, new Object []{ 550 new Integer (ResultSet.TYPE_FORWARD_ONLY), 551 new Integer (ResultSet.CONCUR_UPDATABLE)}); 552 insertMetadataInContainer(metaData, 553 MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class []{ 554 Integer.TYPE, Integer.TYPE}, new Object []{ 555 new Integer (ResultSet.TYPE_SCROLL_INSENSITIVE), 556 new Integer (ResultSet.CONCUR_READ_ONLY)}); 557 insertMetadataInContainer(metaData, 558 MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class []{ 559 Integer.TYPE, Integer.TYPE}, new Object []{ 560 new Integer (ResultSet.TYPE_SCROLL_INSENSITIVE), 561 new Integer (ResultSet.CONCUR_UPDATABLE)}); 562 insertMetadataInContainer(metaData, 563 MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class []{ 564 Integer.TYPE, Integer.TYPE}, new Object []{ 565 new Integer (ResultSet.TYPE_SCROLL_SENSITIVE), 566 new Integer (ResultSet.CONCUR_READ_ONLY)}); 567 insertMetadataInContainer(metaData, 568 MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class []{ 569 Integer.TYPE, Integer.TYPE}, new Object []{ 570 new Integer (ResultSet.TYPE_SCROLL_SENSITIVE), 571 new Integer (ResultSet.CONCUR_UPDATABLE)}); 572 insertMetadataInContainer(metaData, 573 MetadataDescription.SUPPORTS_RESULT_SET_HOLDABILITY, 574 new Class []{Integer.TYPE}, new Object []{new Integer ( 575 ResultSet.HOLD_CURSORS_OVER_COMMIT)}); 576 insertMetadataInContainer(metaData, 577 MetadataDescription.SUPPORTS_RESULT_SET_HOLDABILITY, 578 new Class []{Integer.TYPE}, new Object []{new Integer ( 579 ResultSet.CLOSE_CURSORS_AT_COMMIT)}); 580 insertMetadataInContainer(metaData, 581 MetadataDescription.SUPPORTS_RESULT_SET_TYPE, 582 new Class []{Integer.TYPE}, new Object []{new Integer ( 583 ResultSet.TYPE_FORWARD_ONLY)}); 584 insertMetadataInContainer(metaData, 585 MetadataDescription.SUPPORTS_RESULT_SET_TYPE, 586 new Class []{Integer.TYPE}, new Object []{new Integer ( 587 ResultSet.TYPE_SCROLL_INSENSITIVE)}); 588 insertMetadataInContainer(metaData, 589 MetadataDescription.SUPPORTS_RESULT_SET_TYPE, 590 new Class []{Integer.TYPE}, new Object []{new Integer ( 591 ResultSet.TYPE_SCROLL_SENSITIVE)}); 592 insertMetadataInContainer(metaData, 593 MetadataDescription.SUPPORTS_SAVEPOINTS, null, null); 594 insertMetadataInContainer(metaData, 595 MetadataDescription.SUPPORTS_SCHEMAS_IN_DATA_MANIPULATION, null, null); 596 insertMetadataInContainer(metaData, 597 MetadataDescription.SUPPORTS_SCHEMAS_IN_INDEX_DEFINITIONS, null, null); 598 insertMetadataInContainer(metaData, 599 MetadataDescription.SUPPORTS_SCHEMAS_IN_PRIVILEGE_DEFINITIONS, null, 600 null); 601 insertMetadataInContainer(metaData, 602 MetadataDescription.SUPPORTS_SCHEMAS_IN_PROCEDURE_CALLS, null, null); 603 insertMetadataInContainer(metaData, 604 MetadataDescription.SUPPORTS_SCHEMAS_IN_TABLE_DEFINITIONS, null, null); 605 insertMetadataInContainer(metaData, 606 MetadataDescription.SUPPORTS_SELECT_FOR_UPDATE, null, null); 607 insertMetadataInContainer(metaData, 608 MetadataDescription.SUPPORTS_STATEMENT_POOLING, null, null); 609 insertMetadataInContainer(metaData, 610 MetadataDescription.SUPPORTS_STORED_PROCEDURES, null, null); 611 insertMetadataInContainer(metaData, 612 MetadataDescription.SUPPORTS_SUB_QUERIES_IN_COMPARISONS, null, null); 613 insertMetadataInContainer(metaData, 614 MetadataDescription.SUPPORTS_SUB_QUERIES_IN_EXISTS, null, null); 615 insertMetadataInContainer(metaData, 616 MetadataDescription.SUPPORTS_SUB_QUERIES_IN_INS, null, null); 617 insertMetadataInContainer(metaData, 618 MetadataDescription.SUPPORTS_SUB_QUERIES_IN_QUANTIFIEDS, null, null); 619 insertMetadataInContainer(metaData, 620 MetadataDescription.SUPPORTS_TABLE_CORRELATION_NAMES, null, null); 621 insertMetadataInContainer(metaData, 622 MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL, 623 new Class []{Integer.TYPE}, new Object []{new Integer ( 624 Connection.TRANSACTION_NONE)}); 625 insertMetadataInContainer(metaData, 626 MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL, 627 new Class []{Integer.TYPE}, new Object []{new Integer ( 628 Connection.TRANSACTION_READ_COMMITTED)}); 629 insertMetadataInContainer(metaData, 630 MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL, 631 new Class []{Integer.TYPE}, new Object []{new Integer ( 632 Connection.TRANSACTION_READ_UNCOMMITTED)}); 633 insertMetadataInContainer(metaData, 634 MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL, 635 new Class []{Integer.TYPE}, new Object []{new Integer ( 636 Connection.TRANSACTION_REPEATABLE_READ)}); 637 insertMetadataInContainer(metaData, 638 MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL, 639 new Class []{Integer.TYPE}, new Object []{new Integer ( 640 Connection.TRANSACTION_SERIALIZABLE)}); 641 insertMetadataInContainer(metaData, 642 MetadataDescription.SUPPORTS_TRANSACTIONS, null, null); 643 insertMetadataInContainer(metaData, MetadataDescription.SUPPORTS_UNION, 644 null, null); 645 insertMetadataInContainer(metaData, 646 MetadataDescription.SUPPORTS_UNION_ALL, null, null); 647 insertMetadataInContainer(metaData, 648 MetadataDescription.UPDATES_ARE_DETECTED, new Class []{Integer.TYPE}, 649 new Object []{new Integer (ResultSet.TYPE_FORWARD_ONLY)}); 650 insertMetadataInContainer(metaData, 651 MetadataDescription.UPDATES_ARE_DETECTED, new Class []{Integer.TYPE}, 652 new Object []{new Integer (ResultSet.TYPE_SCROLL_INSENSITIVE)}); 653 insertMetadataInContainer(metaData, 654 MetadataDescription.UPDATES_ARE_DETECTED, new Class []{Integer.TYPE}, 655 new Object []{new Integer (ResultSet.TYPE_SCROLL_SENSITIVE)}); 656 insertMetadataInContainer(metaData, 657 MetadataDescription.USES_LOCAL_FILE_PER_TABLE, null, null); 658 insertMetadataInContainer(metaData, MetadataDescription.USES_LOCAL_FILES, 659 null, null); 660 insertMetadataInContainer(metaData, 661 MetadataDescription.IS_CATALOG_AT_START, null, null); 662 663 overrideSequoiaSpecificFeatures(); 664 } 665 catch (Exception e) 666 { 667 if (e instanceof RuntimeException ) 668 logger.error(Translate.get("backend.meta.runtime.error"), e); 669 throw new SQLException (Translate.get("backend.meta.failed.get.info", e)); 670 } 671 672 finally 673 { 674 if (pooledConnection != null) 676 connectionManager.releaseConnectionInAutoCommit(null, pooledConnection); 677 678 if (!wasInitialized) 679 connectionManager.finalizeConnections(); 680 } 681 return metadataContainer; 682 } 683 684 688 private void overrideSequoiaSpecificFeatures() 689 { 690 updateContainerInformation(MetadataDescription.DELETES_ARE_DETECTED, 693 new Class []{Integer.TYPE}, new Object []{new Integer ( 694 ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE); 695 updateContainerInformation(MetadataDescription.DELETES_ARE_DETECTED, 696 new Class []{Integer.TYPE}, new Object []{new Integer ( 697 ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE); 698 updateContainerInformation(MetadataDescription.INSERTS_ARE_DETECTED, 699 new Class []{Integer.TYPE}, new Object []{new Integer ( 700 ResultSet.TYPE_FORWARD_ONLY)}, Boolean.FALSE); 701 updateContainerInformation(MetadataDescription.INSERTS_ARE_DETECTED, 702 new Class []{Integer.TYPE}, new Object []{new Integer ( 703 ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE); 704 updateContainerInformation(MetadataDescription.INSERTS_ARE_DETECTED, 705 new Class []{Integer.TYPE}, new Object []{new Integer ( 706 ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE); 707 708 updateContainerInformation(MetadataDescription.LOCATORS_UPDATE_COPY, null, 711 null, Boolean.TRUE); 712 713 updateContainerInformation(MetadataDescription.OTHERS_DELETES_ARE_VISIBLE, 716 new Class []{Integer.TYPE}, new Object []{new Integer ( 717 ResultSet.TYPE_FORWARD_ONLY)}, Boolean.FALSE); 718 updateContainerInformation(MetadataDescription.OTHERS_DELETES_ARE_VISIBLE, 719 new Class []{Integer.TYPE}, new Object []{new Integer ( 720 ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE); 721 updateContainerInformation(MetadataDescription.OTHERS_DELETES_ARE_VISIBLE, 722 new Class []{Integer.TYPE}, new Object []{new Integer ( 723 ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE); 724 updateContainerInformation(MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE, 725 new Class []{Integer.TYPE}, new Object []{new Integer ( 726 ResultSet.TYPE_FORWARD_ONLY)}, Boolean.FALSE); 727 updateContainerInformation(MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE, 728 new Class []{Integer.TYPE}, new Object []{new Integer ( 729 ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE); 730 updateContainerInformation(MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE, 731 new Class []{Integer.TYPE}, new Object []{new Integer ( 732 ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE); 733 updateContainerInformation(MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE, 734 new Class []{Integer.TYPE}, new Object []{new Integer ( 735 ResultSet.TYPE_FORWARD_ONLY)}, Boolean.FALSE); 736 updateContainerInformation(MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE, 737 new Class []{Integer.TYPE}, new Object []{new Integer ( 738 ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE); 739 updateContainerInformation(MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE, 740 new Class []{Integer.TYPE}, new Object []{new Integer ( 741 ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE); 742 743 updateContainerInformation(MetadataDescription.OWN_DELETES_ARE_VISIBLE, 746 new Class []{Integer.TYPE}, new Object []{new Integer ( 747 ResultSet.TYPE_FORWARD_ONLY)}, Boolean.TRUE); 748 updateContainerInformation(MetadataDescription.OWN_DELETES_ARE_VISIBLE, 749 new Class []{Integer.TYPE}, new Object []{new Integer ( 750 ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.TRUE); 751 updateContainerInformation(MetadataDescription.OWN_DELETES_ARE_VISIBLE, 752 new Class []{Integer.TYPE}, new Object []{new Integer ( 753 ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.TRUE); 754 updateContainerInformation(MetadataDescription.OWN_INSERTS_ARE_VISIBLE, 755 new Class []{Integer.TYPE}, new Object []{new Integer ( 756 ResultSet.TYPE_FORWARD_ONLY)}, Boolean.TRUE); 757 updateContainerInformation(MetadataDescription.OWN_INSERTS_ARE_VISIBLE, 758 new Class []{Integer.TYPE}, new Object []{new Integer ( 759 ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.TRUE); 760 updateContainerInformation(MetadataDescription.OWN_INSERTS_ARE_VISIBLE, 761 new Class []{Integer.TYPE}, new Object []{new Integer ( 762 ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.TRUE); 763 updateContainerInformation(MetadataDescription.OWN_UPDATES_ARE_VISIBLE, 764 new Class []{Integer.TYPE}, new Object []{new Integer ( 765 ResultSet.TYPE_FORWARD_ONLY)}, Boolean.TRUE); 766 updateContainerInformation(MetadataDescription.OWN_UPDATES_ARE_VISIBLE, 767 new Class []{Integer.TYPE}, new Object []{new Integer ( 768 ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.TRUE); 769 updateContainerInformation(MetadataDescription.OWN_UPDATES_ARE_VISIBLE, 770 new Class []{Integer.TYPE}, new Object []{new Integer ( 771 ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.TRUE); 772 773 updateContainerInformation(MetadataDescription.SUPPORTS_BATCH_UPDATES, 775 null, null, Boolean.TRUE); 776 777 updateContainerInformation( 780 MetadataDescription.SUPPORTS_MULTIPLE_OPEN_RESULTS, null, null, 781 Boolean.FALSE); 782 783 updateContainerInformation( 786 MetadataDescription.SUPPORTS_MULTIPLE_RESULTSETS, null, null, 787 Boolean.FALSE); 788 789 updateContainerInformation( 793 MetadataDescription.SUPPORTS_OPEN_CURSORS_ACROSS_COMMIT, null, null, 794 Boolean.TRUE); 795 updateContainerInformation( 796 MetadataDescription.SUPPORTS_OPEN_CURSORS_ACROSS_ROLLBACK, null, null, 797 Boolean.TRUE); 798 updateContainerInformation( 799 MetadataDescription.SUPPORTS_OPEN_STATEMENTS_ACROSS_COMMIT, null, null, 800 Boolean.TRUE); 801 updateContainerInformation( 802 MetadataDescription.SUPPORTS_OPEN_STATEMENTS_ACROSS_ROLLBACK, null, 803 null, Boolean.TRUE); 804 805 updateContainerInformation( 807 MetadataDescription.SUPPORTS_RESULT_SET_HOLDABILITY, 808 new Class []{Integer.TYPE}, new Object []{new Integer ( 809 ResultSet.HOLD_CURSORS_OVER_COMMIT)}, Boolean.TRUE); 810 updateContainerInformation( 811 MetadataDescription.SUPPORTS_RESULT_SET_HOLDABILITY, 812 new Class []{Integer.TYPE}, new Object []{new Integer ( 813 ResultSet.CLOSE_CURSORS_AT_COMMIT)}, Boolean.FALSE); 814 815 updateContainerInformation( 818 MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class []{ 819 Integer.TYPE, Integer.TYPE}, new Object []{ 820 new Integer (ResultSet.TYPE_FORWARD_ONLY), 821 new Integer (ResultSet.CONCUR_READ_ONLY)}, Boolean.TRUE); 822 updateContainerInformation( 823 MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class []{ 824 Integer.TYPE, Integer.TYPE}, new Object []{ 825 new Integer (ResultSet.TYPE_FORWARD_ONLY), 826 new Integer (ResultSet.CONCUR_UPDATABLE)}, Boolean.TRUE); 827 updateContainerInformation( 828 MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class []{ 829 Integer.TYPE, Integer.TYPE}, new Object []{ 830 new Integer (ResultSet.TYPE_SCROLL_INSENSITIVE), 831 new Integer (ResultSet.CONCUR_READ_ONLY)}, Boolean.TRUE); 832 updateContainerInformation( 833 MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class []{ 834 Integer.TYPE, Integer.TYPE}, new Object []{ 835 new Integer (ResultSet.TYPE_SCROLL_INSENSITIVE), 836 new Integer (ResultSet.CONCUR_UPDATABLE)}, Boolean.TRUE); 837 updateContainerInformation( 838 MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class []{ 839 Integer.TYPE, Integer.TYPE}, new Object []{ 840 new Integer (ResultSet.TYPE_SCROLL_SENSITIVE), 841 new Integer (ResultSet.CONCUR_READ_ONLY)}, Boolean.FALSE); 842 updateContainerInformation( 843 MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class []{ 844 Integer.TYPE, Integer.TYPE}, new Object []{ 845 new Integer (ResultSet.TYPE_SCROLL_SENSITIVE), 846 new Integer (ResultSet.CONCUR_UPDATABLE)}, Boolean.FALSE); 847 848 updateContainerInformation(MetadataDescription.SUPPORTS_RESULT_SET_TYPE, 850 new Class []{Integer.TYPE}, new Object []{new Integer ( 851 ResultSet.TYPE_FORWARD_ONLY)}, Boolean.TRUE); 852 updateContainerInformation(MetadataDescription.SUPPORTS_RESULT_SET_TYPE, 853 new Class []{Integer.TYPE}, new Object []{new Integer ( 854 ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.TRUE); 855 updateContainerInformation(MetadataDescription.SUPPORTS_RESULT_SET_TYPE, 856 new Class []{Integer.TYPE}, new Object []{new Integer ( 857 ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE); 858 859 updateContainerInformation(MetadataDescription.SUPPORTS_SAVEPOINTS, null, 861 null, Boolean.FALSE); 862 863 updateContainerInformation(MetadataDescription.UPDATES_ARE_DETECTED, 865 new Class []{Integer.TYPE}, new Object []{new Integer ( 866 ResultSet.TYPE_FORWARD_ONLY)}, Boolean.FALSE); 867 updateContainerInformation(MetadataDescription.UPDATES_ARE_DETECTED, 868 new Class []{Integer.TYPE}, new Object []{new Integer ( 869 ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE); 870 updateContainerInformation(MetadataDescription.UPDATES_ARE_DETECTED, 871 new Class []{Integer.TYPE}, new Object []{new Integer ( 872 ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE); 873 } 874 875 881 public void createDatabaseSchemaDynamically() throws SQLException 882 { 883 PooledConnection pooledConnection = null; 884 boolean wasInitialized = connectionManager.isInitialized(); 885 886 Connection connection; 887 try 888 { 889 if (!wasInitialized) 890 connectionManager.initializeConnections(); 891 892 pooledConnection = connectionManager.retrieveConnectionInAutoCommit(null); 893 if (pooledConnection == null) 894 { 895 String msg = Translate.get("backend.meta.connection.failed"); 896 logger.error(msg); 897 throw new SQLException (msg); 898 } 899 connection = pooledConnection.getConnection(); 900 if (connection == null) 901 { 902 String msg = Translate.get("backend.meta.connection.failed"); 903 logger.error(msg); 904 throw new SQLException (msg); 905 } 906 907 databaseSchema = new DatabaseSQLMetaData(logger, connection, 908 dynamicDatabaseSchema).createDatabaseSchema(vdbName); 909 } 910 catch (Exception e) 911 { 912 if (e instanceof RuntimeException ) 913 logger.error(Translate.get("backend.meta.runtime.error"), e); 914 throw new SQLException (Translate.get("backend.meta.failed.get.info", e)); 915 } 916 finally 917 { 918 if (pooledConnection != null) 919 connectionManager.releaseConnectionInAutoCommit(null, pooledConnection); 920 921 if (!wasInitialized) 922 connectionManager.finalizeConnections(); 923 924 } 925 } 926 927 939 public DatabaseSchema getDatabaseSchema() throws SQLException 940 { 941 if (databaseSchema == null) 942 createDatabaseSchemaDynamically(); 943 return databaseSchema; 944 } 945 } 946 | Popular Tags |