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