0001: /**
0002: * Sequoia: Database clustering technology.
0003: * Copyright (C) 2002-2004 French National Institute For Research In Computer
0004: * Science And Control (INRIA).
0005: * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
0006: * Contact: sequoia@continuent.org
0007: *
0008: * Licensed under the Apache License, Version 2.0 (the "License");
0009: * you may not use this file except in compliance with the License.
0010: * You may obtain a copy of the License at
0011: *
0012: * http://www.apache.org/licenses/LICENSE-2.0
0013: *
0014: * Unless required by applicable law or agreed to in writing, software
0015: * distributed under the License is distributed on an "AS IS" BASIS,
0016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0017: * See the License for the specific language governing permissions and
0018: * limitations under the License.
0019: *
0020: * Initial developer(s): Julie Marguerite.
0021: * Contributor(s): Emmanuel Cecchet, Nicolas Modrzyk, Mathieu Peltier, Jean-Bernard van Zuylen.
0022: */package org.continuent.sequoia.controller.backend;
0023:
0024: import java.lang.reflect.InvocationTargetException;
0025: import java.lang.reflect.Method;
0026: import java.sql.Connection;
0027: import java.sql.DatabaseMetaData;
0028: import java.sql.ResultSet;
0029: import java.sql.SQLException;
0030:
0031: import org.continuent.sequoia.common.i18n.Translate;
0032: import org.continuent.sequoia.common.log.Trace;
0033: import org.continuent.sequoia.common.sql.metadata.MetadataContainer;
0034: import org.continuent.sequoia.common.sql.metadata.MetadataDescription;
0035: import org.continuent.sequoia.common.sql.schema.DatabaseSchema;
0036: import org.continuent.sequoia.controller.connection.AbstractConnectionManager;
0037: import org.continuent.sequoia.controller.connection.PooledConnection;
0038:
0039: /**
0040: * A <code>DatabaseBackendMetaData</code> is used to retrieve the database
0041: * schema of a real database backend that will have to be bound to a virtual
0042: * Sequoia database.
0043: *
0044: * @author <a href="mailto:Julie.Marguerite@inria.fr">Julie Marguerite </a>
0045: * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
0046: * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
0047: * @author <a href="mailto:Mathieu.Peltier@inrialpes.fr">Mathieu Peltier </a>
0048: * @author <a href="mailto:jbvanzuylen@transwide.com">Jean-Bernard van Zuylen
0049: * </a>
0050: * @version 1.0
0051: */
0052: public final class DatabaseBackendMetaData {
0053: /** Connection manager to get a connection from. */
0054: private AbstractConnectionManager connectionManager;
0055:
0056: /** Logger instance. */
0057: private Trace logger;
0058:
0059: /** Schema of the database backend. */
0060: private DatabaseSchema databaseSchema;
0061:
0062: /** The precision of the dynamically generated schema */
0063: private int dynamicPrecision;
0064:
0065: /** Should the system tables be gathered or not */
0066: private boolean gatherSystemTables = false;
0067:
0068: /** Virtual database name that can be used as a table name prefix in the schema */
0069: private String vdbName;
0070:
0071: /** The name of the schema used to gather meta data */
0072: private String schemaName = null;
0073:
0074: /** Container for static metadata */
0075: private MetadataContainer metadataContainer = null;
0076:
0077: /**
0078: * Creates a new <code>DatabaseBackendMetaData</code> instance. This class
0079: * takes care of initializing the connection manager if needed but the driver
0080: * must have been previously loaded else the connection manager's
0081: * initialization will fail.
0082: *
0083: * @param connectionManager the connection manager to gather the schema from
0084: * @param logger the logger (usually the backend logger) to use
0085: * @param dynamicPrecision the precision with which we gather a schema
0086: * directly from the backend
0087: * @param gatherSystemTables true if system tables must be gathered
0088: * @param vdbName the virtual database name this schema represents
0089: * @param schemaName schema name to use to retrieve information
0090: */
0091: public DatabaseBackendMetaData(
0092: AbstractConnectionManager connectionManager, Trace logger,
0093: int dynamicPrecision, boolean gatherSystemTables,
0094: String vdbName, String schemaName) {
0095: this .connectionManager = connectionManager;
0096: this .dynamicPrecision = dynamicPrecision;
0097: this .logger = logger;
0098: this .gatherSystemTables = gatherSystemTables;
0099: this .vdbName = vdbName;
0100: this .schemaName = schemaName;
0101: }
0102:
0103: /**
0104: * This method invokes by reflection the appropriate metadata method and fills
0105: * the container with the result.
0106: *
0107: * @param metaData metadata to invoke
0108: * @param methodName method to invoke
0109: * @param parametersType parameters type of method to invoke
0110: * @param arguments arguments to invoke the method
0111: */
0112: private void insertMetadataInContainer(DatabaseMetaData metaData,
0113: String methodName, Class[] parametersType,
0114: Object[] arguments) {
0115: Class metadataClass = metaData.getClass();
0116: try {
0117: Method method = metadataClass.getMethod(methodName,
0118: parametersType);
0119: Object result = method.invoke(metaData, arguments);
0120: updateContainerInformation(methodName, parametersType,
0121: arguments, result);
0122: } catch (SecurityException e) {
0123: if (logger.isDebugEnabled())
0124: logger.debug("Problem calling " + methodName, e);
0125: else
0126: logger.warn("Unable to get information for "
0127: + methodName);
0128: } catch (IllegalArgumentException e) {
0129: if (logger.isDebugEnabled())
0130: logger.debug("Problem calling " + methodName, e);
0131: else
0132: logger.warn("Unable to get information for "
0133: + methodName);
0134: } catch (NoSuchMethodException e) {
0135: if (logger.isDebugEnabled())
0136: logger
0137: .debug("Metadata "
0138: + methodName
0139: + " does not exists. Probably not supported by your JDK.");
0140: } catch (IllegalAccessException e) {
0141: if (logger.isDebugEnabled())
0142: logger.debug("Problem calling " + methodName, e);
0143: else
0144: logger.warn("Unable to get information for "
0145: + methodName);
0146: } catch (InvocationTargetException e) {
0147: if (logger.isDebugEnabled())
0148: logger.debug("Problem calling " + methodName, e);
0149: else
0150: logger.warn("Unable to get information for "
0151: + methodName);
0152: } catch (AbstractMethodError e) {
0153: // user Wolfgang Koppenberger reported problems with code compiled with
0154: // java 1.3, it throws AbstractMethodError instead of
0155: // NoSuchMethodException
0156: if (logger.isDebugEnabled())
0157: logger
0158: .debug("Metadata "
0159: + methodName
0160: + " does not exists. Probably not supported by your jdbc-driver.");
0161: }
0162: }
0163:
0164: /**
0165: * Update the metadata container information for the given method.
0166: *
0167: * @param methodName method invoked to generate the key in the container
0168: * @param parametersType parameters type of invoked method
0169: * @param arguments arguments used to invoke the method
0170: * @param result result of the method call
0171: */
0172: private void updateContainerInformation(String methodName,
0173: Class[] parametersType, Object[] arguments, Object result) {
0174: String key = MetadataContainer.getContainerKey(methodName,
0175: parametersType, arguments);
0176: metadataContainer.put(key, result);
0177: if (logger.isDebugEnabled())
0178: logger.debug("Updating metadata " + key + "=" + result);
0179: }
0180:
0181: /**
0182: * Retrieve metadata from a connection on this backend and build the
0183: * ("getDataXXX(Y,Z,...)", value) hash table. Note that some values are
0184: * overriden with Sequoia specific features (add-ons or limitations).
0185: *
0186: * @return a metadata container including all metadata values
0187: * @throws SQLException if an error occurs
0188: */
0189: public MetadataContainer retrieveDatabaseMetadata()
0190: throws SQLException {
0191: if (metadataContainer != null)
0192: return metadataContainer;
0193:
0194: // Retrieve metadata
0195: boolean wasInitialized = connectionManager.isInitialized();
0196:
0197: DatabaseMetaData metaData;
0198: PooledConnection pooledConnection = null;
0199: try {
0200: if (!wasInitialized)
0201: connectionManager.initializeConnections();
0202:
0203: pooledConnection = connectionManager
0204: .retrieveConnectionInAutoCommit(null);
0205: if (pooledConnection == null) {
0206: String msg = Translate
0207: .get("backend.meta.connection.failed");
0208: logger.error(msg);
0209: throw new SQLException(msg);
0210: }
0211: Connection connection = pooledConnection.getConnection();
0212: if (connection == null) {
0213: String msg = Translate
0214: .get("backend.meta.connection.failed");
0215: logger.error(msg);
0216: throw new SQLException(msg);
0217: }
0218:
0219: metaData = connection.getMetaData();
0220: metadataContainer = new MetadataContainer(connection
0221: .getMetaData().getURL());
0222:
0223: // TODO: Move this to a separate command
0224: // Boolean.valueOf(metaData.supportsConvert(int,int)
0225:
0226: // Metadata in alphabetical order.
0227: // These calls do not seem to throw anything, but require a valid
0228: // connection (which is closed in the finally block).
0229: insertMetadataInContainer(metaData,
0230: MetadataDescription.ALL_PROCEDURES_ARE_CALLABLE,
0231: null, null);
0232: insertMetadataInContainer(metaData,
0233: MetadataDescription.ALL_TABLES_ARE_SELECTABLE,
0234: null, null);
0235: insertMetadataInContainer(
0236: metaData,
0237: MetadataDescription.DATA_DEFINITION_CAUSES_TRANSACTION_COMMIT,
0238: null, null);
0239: insertMetadataInContainer(
0240: metaData,
0241: MetadataDescription.DATA_DEFINITION_IGNORED_IN_TRANSACTIONS,
0242: null, null);
0243: insertMetadataInContainer(metaData,
0244: MetadataDescription.DELETES_ARE_DETECTED,
0245: new Class[] { Integer.TYPE },
0246: new Object[] { new Integer(
0247: ResultSet.TYPE_FORWARD_ONLY) });
0248: insertMetadataInContainer(metaData,
0249: MetadataDescription.DELETES_ARE_DETECTED,
0250: new Class[] { Integer.TYPE },
0251: new Object[] { new Integer(
0252: ResultSet.TYPE_SCROLL_INSENSITIVE) });
0253: insertMetadataInContainer(metaData,
0254: MetadataDescription.DELETES_ARE_DETECTED,
0255: new Class[] { Integer.TYPE },
0256: new Object[] { new Integer(
0257: ResultSet.TYPE_SCROLL_SENSITIVE) });
0258: insertMetadataInContainer(
0259: metaData,
0260: MetadataDescription.DOES_MAX_ROW_SIZE_INCLUDE_BLOBS,
0261: null, null);
0262: insertMetadataInContainer(
0263: metaData,
0264: MetadataDescription.GET_DEFAULT_TRANSACTION_ISOLATION,
0265: null, null);
0266: insertMetadataInContainer(metaData,
0267: MetadataDescription.GET_DATABASE_MAJOR_VERSION,
0268: null, null);
0269: insertMetadataInContainer(metaData,
0270: MetadataDescription.GET_DATABASE_MINOR_VERSION,
0271: null, null);
0272: insertMetadataInContainer(metaData,
0273: MetadataDescription.GET_DRIVER_MAJOR_VERSION, null,
0274: null);
0275: insertMetadataInContainer(metaData,
0276: MetadataDescription.GET_DRIVER_MINOR_VERSION, null,
0277: null);
0278: insertMetadataInContainer(metaData,
0279: MetadataDescription.GET_JDBC_MAJOR_VERSION, null,
0280: null);
0281: insertMetadataInContainer(metaData,
0282: MetadataDescription.GET_JDBC_MINOR_VERSION, null,
0283: null);
0284: insertMetadataInContainer(metaData,
0285: MetadataDescription.GET_MAX_BINARY_LITERAL_LENGTH,
0286: null, null);
0287: insertMetadataInContainer(metaData,
0288: MetadataDescription.GET_RESULTSET_HOLDABILITY,
0289: null, null);
0290: insertMetadataInContainer(metaData,
0291: MetadataDescription.GET_SQL_STATE_TYPE, null, null);
0292: insertMetadataInContainer(metaData,
0293: MetadataDescription.GET_MAX_CATALOG_NAME_LENGTH,
0294: null, null);
0295: insertMetadataInContainer(metaData,
0296: MetadataDescription.GET_MAX_CHAR_LITERAL_LENGTH,
0297: null, null);
0298: insertMetadataInContainer(metaData,
0299: MetadataDescription.GET_MAX_COLUMN_NAME_LENGTH,
0300: null, null);
0301: insertMetadataInContainer(metaData,
0302: MetadataDescription.GET_MAX_COLUMNS_IN_GROUP_BY,
0303: null, null);
0304: insertMetadataInContainer(metaData,
0305: MetadataDescription.GET_MAX_COLUMNS_IN_INDEX, null,
0306: null);
0307: insertMetadataInContainer(metaData,
0308: MetadataDescription.GET_MAX_COLUMNS_IN_ORDER_BY,
0309: null, null);
0310: insertMetadataInContainer(metaData,
0311: MetadataDescription.GET_MAX_COLUMNS_IN_SELECT,
0312: null, null);
0313: insertMetadataInContainer(metaData,
0314: MetadataDescription.GET_MAX_COLUMNS_IN_TABLE, null,
0315: null);
0316: insertMetadataInContainer(metaData,
0317: MetadataDescription.GET_MAX_CONNECTIONS, null, null);
0318: insertMetadataInContainer(metaData,
0319: MetadataDescription.GET_MAX_CURSOR_NAME_LENGTH,
0320: null, null);
0321: insertMetadataInContainer(metaData,
0322: MetadataDescription.GET_MAX_INDEX_LENGTH, null,
0323: null);
0324: insertMetadataInContainer(metaData,
0325: MetadataDescription.GET_MAX_PROCEDURE_NAME_LENGTH,
0326: null, null);
0327: insertMetadataInContainer(metaData,
0328: MetadataDescription.GET_MAX_ROW_SIZE, null, null);
0329: insertMetadataInContainer(metaData,
0330: MetadataDescription.GET_MAX_SCHEMA_NAME_LENGTH,
0331: null, null);
0332: insertMetadataInContainer(metaData,
0333: MetadataDescription.GET_MAX_STATEMENT_LENGTH, null,
0334: null);
0335: insertMetadataInContainer(metaData,
0336: MetadataDescription.GET_MAX_STATEMENTS, null, null);
0337: insertMetadataInContainer(metaData,
0338: MetadataDescription.GET_MAX_TABLE_NAME_LENGTH,
0339: null, null);
0340: insertMetadataInContainer(metaData,
0341: MetadataDescription.GET_MAX_TABLES_IN_SELECT, null,
0342: null);
0343: insertMetadataInContainer(metaData,
0344: MetadataDescription.GET_MAX_USER_NAME_LENGTH, null,
0345: null);
0346: // strings
0347: insertMetadataInContainer(metaData,
0348: MetadataDescription.GET_CATALOG_SEPARATOR, null,
0349: null);
0350: insertMetadataInContainer(metaData,
0351: MetadataDescription.GET_CATALOG_TERM, null, null);
0352: insertMetadataInContainer(metaData,
0353: MetadataDescription.GET_DATABASE_PRODUCT_NAME,
0354: null, null);
0355: insertMetadataInContainer(metaData,
0356: MetadataDescription.GET_DRIVER_NAME, null, null);
0357: insertMetadataInContainer(metaData,
0358: MetadataDescription.GET_DRIVER_VERSION, null, null);
0359: insertMetadataInContainer(metaData,
0360: MetadataDescription.GET_EXTRA_NAME_CHARACTERS,
0361: null, null);
0362: insertMetadataInContainer(metaData,
0363: MetadataDescription.GET_IDENTIFIER_QUOTE_STRING,
0364: null, null);
0365: insertMetadataInContainer(metaData,
0366: MetadataDescription.GET_NUMERIC_FUNCTIONS, null,
0367: null);
0368: insertMetadataInContainer(metaData,
0369: MetadataDescription.GET_PROCEDURE_TERM, null, null);
0370: insertMetadataInContainer(metaData,
0371: MetadataDescription.GET_SCHEMA_TERM, null, null);
0372: insertMetadataInContainer(metaData,
0373: MetadataDescription.GET_SEARCH_STRING_ESCAPE, null,
0374: null);
0375: insertMetadataInContainer(metaData,
0376: MetadataDescription.GET_SQL_KEYWORDS, null, null);
0377: insertMetadataInContainer(metaData,
0378: MetadataDescription.GET_STRING_FUNCTIONS, null,
0379: null);
0380: insertMetadataInContainer(metaData,
0381: MetadataDescription.GET_SYSTEM_FUNCTIONS, null,
0382: null);
0383: insertMetadataInContainer(metaData,
0384: MetadataDescription.GET_TIME_DATE_FUNCTIONS, null,
0385: null);
0386: insertMetadataInContainer(metaData,
0387: MetadataDescription.INSERTS_ARE_DETECTED,
0388: new Class[] { Integer.TYPE },
0389: new Object[] { new Integer(
0390: ResultSet.TYPE_FORWARD_ONLY) });
0391: insertMetadataInContainer(metaData,
0392: MetadataDescription.INSERTS_ARE_DETECTED,
0393: new Class[] { Integer.TYPE },
0394: new Object[] { new Integer(
0395: ResultSet.TYPE_SCROLL_INSENSITIVE) });
0396: insertMetadataInContainer(metaData,
0397: MetadataDescription.INSERTS_ARE_DETECTED,
0398: new Class[] { Integer.TYPE },
0399: new Object[] { new Integer(
0400: ResultSet.TYPE_SCROLL_SENSITIVE) });
0401: insertMetadataInContainer(metaData,
0402: MetadataDescription.LOCATORS_UPDATE_COPY, null,
0403: null);
0404: insertMetadataInContainer(metaData,
0405: MetadataDescription.NULL_PLUS_NON_NULL_IS_NULL,
0406: null, null);
0407: insertMetadataInContainer(metaData,
0408: MetadataDescription.NULLS_ARE_SORTED_AT_END, null,
0409: null);
0410: insertMetadataInContainer(metaData,
0411: MetadataDescription.NULLS_ARE_SORTED_AT_START,
0412: null, null);
0413: insertMetadataInContainer(metaData,
0414: MetadataDescription.NULLS_ARE_SORTED_HIGH, null,
0415: null);
0416: insertMetadataInContainer(metaData,
0417: MetadataDescription.NULLS_ARE_SORTED_LOW, null,
0418: null);
0419: insertMetadataInContainer(metaData,
0420: MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
0421: new Class[] { Integer.TYPE },
0422: new Object[] { new Integer(
0423: ResultSet.TYPE_FORWARD_ONLY) });
0424: insertMetadataInContainer(metaData,
0425: MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
0426: new Class[] { Integer.TYPE },
0427: new Object[] { new Integer(
0428: ResultSet.TYPE_SCROLL_INSENSITIVE) });
0429: insertMetadataInContainer(metaData,
0430: MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
0431: new Class[] { Integer.TYPE },
0432: new Object[] { new Integer(
0433: ResultSet.TYPE_SCROLL_SENSITIVE) });
0434: insertMetadataInContainer(metaData,
0435: MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
0436: new Class[] { Integer.TYPE },
0437: new Object[] { new Integer(
0438: ResultSet.TYPE_FORWARD_ONLY) });
0439: insertMetadataInContainer(metaData,
0440: MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
0441: new Class[] { Integer.TYPE },
0442: new Object[] { new Integer(
0443: ResultSet.TYPE_SCROLL_INSENSITIVE) });
0444: insertMetadataInContainer(metaData,
0445: MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
0446: new Class[] { Integer.TYPE },
0447: new Object[] { new Integer(
0448: ResultSet.TYPE_SCROLL_SENSITIVE) });
0449: insertMetadataInContainer(metaData,
0450: MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
0451: new Class[] { Integer.TYPE },
0452: new Object[] { new Integer(
0453: ResultSet.TYPE_FORWARD_ONLY) });
0454: insertMetadataInContainer(metaData,
0455: MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
0456: new Class[] { Integer.TYPE },
0457: new Object[] { new Integer(
0458: ResultSet.TYPE_SCROLL_INSENSITIVE) });
0459: insertMetadataInContainer(metaData,
0460: MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
0461: new Class[] { Integer.TYPE },
0462: new Object[] { new Integer(
0463: ResultSet.TYPE_SCROLL_SENSITIVE) });
0464: insertMetadataInContainer(metaData,
0465: MetadataDescription.OWN_DELETES_ARE_VISIBLE,
0466: new Class[] { Integer.TYPE },
0467: new Object[] { new Integer(
0468: ResultSet.TYPE_FORWARD_ONLY) });
0469: insertMetadataInContainer(metaData,
0470: MetadataDescription.OWN_DELETES_ARE_VISIBLE,
0471: new Class[] { Integer.TYPE },
0472: new Object[] { new Integer(
0473: ResultSet.TYPE_SCROLL_INSENSITIVE) });
0474: insertMetadataInContainer(metaData,
0475: MetadataDescription.OWN_DELETES_ARE_VISIBLE,
0476: new Class[] { Integer.TYPE },
0477: new Object[] { new Integer(
0478: ResultSet.TYPE_SCROLL_SENSITIVE) });
0479: insertMetadataInContainer(metaData,
0480: MetadataDescription.OWN_INSERTS_ARE_VISIBLE,
0481: new Class[] { Integer.TYPE },
0482: new Object[] { new Integer(
0483: ResultSet.TYPE_FORWARD_ONLY) });
0484: insertMetadataInContainer(metaData,
0485: MetadataDescription.OWN_INSERTS_ARE_VISIBLE,
0486: new Class[] { Integer.TYPE },
0487: new Object[] { new Integer(
0488: ResultSet.TYPE_SCROLL_INSENSITIVE) });
0489: insertMetadataInContainer(metaData,
0490: MetadataDescription.OWN_INSERTS_ARE_VISIBLE,
0491: new Class[] { Integer.TYPE },
0492: new Object[] { new Integer(
0493: ResultSet.TYPE_SCROLL_SENSITIVE) });
0494: insertMetadataInContainer(metaData,
0495: MetadataDescription.OWN_UPDATES_ARE_VISIBLE,
0496: new Class[] { Integer.TYPE },
0497: new Object[] { new Integer(
0498: ResultSet.TYPE_FORWARD_ONLY) });
0499: insertMetadataInContainer(metaData,
0500: MetadataDescription.OWN_UPDATES_ARE_VISIBLE,
0501: new Class[] { Integer.TYPE },
0502: new Object[] { new Integer(
0503: ResultSet.TYPE_SCROLL_INSENSITIVE) });
0504: insertMetadataInContainer(metaData,
0505: MetadataDescription.OWN_UPDATES_ARE_VISIBLE,
0506: new Class[] { Integer.TYPE },
0507: new Object[] { new Integer(
0508: ResultSet.TYPE_SCROLL_SENSITIVE) });
0509: insertMetadataInContainer(metaData,
0510: MetadataDescription.STORES_LOWER_CASE_IDENTIFIERS,
0511: null, null);
0512: insertMetadataInContainer(
0513: metaData,
0514: MetadataDescription.STORES_LOWER_CASE_QUOTED_IDENTIFIERS,
0515: null, null);
0516: insertMetadataInContainer(metaData,
0517: MetadataDescription.STORES_MIXED_CASE_IDENTIFIERS,
0518: null, null);
0519: insertMetadataInContainer(
0520: metaData,
0521: MetadataDescription.STORES_MIXED_CASE_QUOTED_IDENTIFIERS,
0522: null, null);
0523: insertMetadataInContainer(metaData,
0524: MetadataDescription.STORES_UPPER_CASE_IDENTIFIERS,
0525: null, null);
0526: insertMetadataInContainer(
0527: metaData,
0528: MetadataDescription.STORES_UPPER_CASE_QUOTED_IDENTIFIERS,
0529: null, null);
0530: insertMetadataInContainer(
0531: metaData,
0532: MetadataDescription.SUPPORTS_ALTER_TABLE_WITH_ADD_COLUMN,
0533: null, null);
0534: insertMetadataInContainer(
0535: metaData,
0536: MetadataDescription.SUPPORTS_ALTER_TABLE_WITH_DROP_COLUMN,
0537: null, null);
0538: insertMetadataInContainer(
0539: metaData,
0540: MetadataDescription.SUPPORTS_ANSI92_ENTRY_LEVEL_SQL,
0541: null, null);
0542: insertMetadataInContainer(metaData,
0543: MetadataDescription.SUPPORTS_ANSI92_FULL_SQL, null,
0544: null);
0545: insertMetadataInContainer(
0546: metaData,
0547: MetadataDescription.SUPPORTS_ANSI92_INTERMEDIATE_SQL,
0548: null, null);
0549: insertMetadataInContainer(metaData,
0550: MetadataDescription.SUPPORTS_BATCH_UPDATES, null,
0551: null);
0552: insertMetadataInContainer(
0553: metaData,
0554: MetadataDescription.SUPPORTS_CATALOGS_IN_DATA_MANIPULATION,
0555: null, null);
0556: insertMetadataInContainer(
0557: metaData,
0558: MetadataDescription.SUPPORTS_CATALOGS_IN_INDEX_DEFINITIONS,
0559: null, null);
0560: insertMetadataInContainer(
0561: metaData,
0562: MetadataDescription.SUPPORTS_CATALOGS_IN_PRIVILEGE_DEFINITIONS,
0563: null, null);
0564: insertMetadataInContainer(
0565: metaData,
0566: MetadataDescription.SUPPORTS_CATALOGS_IN_PROCEDURE_CALLS,
0567: null, null);
0568: insertMetadataInContainer(
0569: metaData,
0570: MetadataDescription.SUPPORTS_CATALOGS_IN_TABLE_DEFINITIONS,
0571: null, null);
0572: insertMetadataInContainer(metaData,
0573: MetadataDescription.SUPPORTS_COLUMN_ALIASING, null,
0574: null);
0575: insertMetadataInContainer(metaData,
0576: MetadataDescription.SUPPORTS_CONVERT, null, null);
0577: insertMetadataInContainer(metaData,
0578: MetadataDescription.SUPPORTS_CORE_SQL_GRAMMAR,
0579: null, null);
0580: insertMetadataInContainer(metaData,
0581: MetadataDescription.SUPPORTS_CORRELATED_SUBQUERIES,
0582: null, null);
0583: insertMetadataInContainer(
0584: metaData,
0585: MetadataDescription.SUPPORTS_DATA_DEFINITION_AND_DATA_MANIPULATION_TRANSACTIONS,
0586: null, null);
0587: insertMetadataInContainer(
0588: metaData,
0589: MetadataDescription.SUPPORTS_DATA_MANIPULATION_TRANSACTIONS_ONLY,
0590: null, null);
0591: insertMetadataInContainer(
0592: metaData,
0593: MetadataDescription.SUPPORTS_DIFFERENT_TABLE_CORRELATION_NAMES,
0594: null, null);
0595: insertMetadataInContainer(
0596: metaData,
0597: MetadataDescription.SUPPORTS_EXPRESSIONS_IN_ORDER_BY,
0598: null, null);
0599: insertMetadataInContainer(metaData,
0600: MetadataDescription.SUPPORTS_EXTENDED_SQL_GRAMMAR,
0601: null, null);
0602: insertMetadataInContainer(metaData,
0603: MetadataDescription.SUPPORTS_FULL_OUTER_JOINS,
0604: null, null);
0605: insertMetadataInContainer(metaData,
0606: MetadataDescription.SUPPORTS_GET_GENERATED_KEYS,
0607: null, null);
0608: insertMetadataInContainer(metaData,
0609: MetadataDescription.SUPPORTS_GROUP_BY, null, null);
0610: insertMetadataInContainer(
0611: metaData,
0612: MetadataDescription.SUPPORTS_GROUP_BY_BEYOND_SELECT,
0613: null, null);
0614: insertMetadataInContainer(metaData,
0615: MetadataDescription.SUPPORTS_GROUP_BY_UNRELATED,
0616: null, null);
0617: insertMetadataInContainer(
0618: metaData,
0619: MetadataDescription.SUPPORTS_INTEGRITY_ENHANCEMENT_FACILITY,
0620: null, null);
0621: insertMetadataInContainer(metaData,
0622: MetadataDescription.SUPPORTS_LIKE_ESCAPE_CLAUSE,
0623: null, null);
0624: insertMetadataInContainer(metaData,
0625: MetadataDescription.SUPPORTS_LIMITED_OUTER_JOINS,
0626: null, null);
0627: insertMetadataInContainer(metaData,
0628: MetadataDescription.SUPPORTS_MINIMUM_SQL_GRAMMAR,
0629: null, null);
0630: insertMetadataInContainer(
0631: metaData,
0632: MetadataDescription.SUPPORTS_MIXED_CASE_IDENTIFIERS,
0633: null, null);
0634: insertMetadataInContainer(
0635: metaData,
0636: MetadataDescription.SUPPORTS_MIXED_CASE_QUOTED_IDENTIFIERS,
0637: null, null);
0638: insertMetadataInContainer(metaData,
0639: MetadataDescription.SUPPORTS_MULTIPLE_OPEN_RESULTS,
0640: null, null);
0641: insertMetadataInContainer(metaData,
0642: MetadataDescription.SUPPORTS_MULTIPLE_RESULTSETS,
0643: null, null);
0644: insertMetadataInContainer(metaData,
0645: MetadataDescription.SUPPORTS_MULTIPLE_TRANSACTIONS,
0646: null, null);
0647: insertMetadataInContainer(metaData,
0648: MetadataDescription.SUPPORTS_NAMED_PARAMETERS,
0649: null, null);
0650: insertMetadataInContainer(metaData,
0651: MetadataDescription.SUPPORTS_NON_NULLABLE_COLUMNS,
0652: null, null);
0653: insertMetadataInContainer(
0654: metaData,
0655: MetadataDescription.SUPPORTS_OPEN_CURSORS_ACROSS_COMMIT,
0656: null, null);
0657: insertMetadataInContainer(
0658: metaData,
0659: MetadataDescription.SUPPORTS_OPEN_CURSORS_ACROSS_ROLLBACK,
0660: null, null);
0661: insertMetadataInContainer(
0662: metaData,
0663: MetadataDescription.SUPPORTS_OPEN_STATEMENTS_ACROSS_COMMIT,
0664: null, null);
0665: insertMetadataInContainer(
0666: metaData,
0667: MetadataDescription.SUPPORTS_OPEN_STATEMENTS_ACROSS_ROLLBACK,
0668: null, null);
0669: insertMetadataInContainer(metaData,
0670: MetadataDescription.SUPPORTS_ORDER_BY_UNRELATED,
0671: null, null);
0672: insertMetadataInContainer(metaData,
0673: MetadataDescription.SUPPORTS_OUTER_JOINS, null,
0674: null);
0675: insertMetadataInContainer(metaData,
0676: MetadataDescription.SUPPORTS_POSITIONED_DELETE,
0677: null, null);
0678: insertMetadataInContainer(metaData,
0679: MetadataDescription.SUPPORTS_POSITIONED_UPDATE,
0680: null, null);
0681: insertMetadataInContainer(
0682: metaData,
0683: MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
0684: new Class[] { Integer.TYPE, Integer.TYPE },
0685: new Object[] {
0686: new Integer(ResultSet.TYPE_FORWARD_ONLY),
0687: new Integer(ResultSet.CONCUR_READ_ONLY) });
0688: insertMetadataInContainer(
0689: metaData,
0690: MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
0691: new Class[] { Integer.TYPE, Integer.TYPE },
0692: new Object[] {
0693: new Integer(ResultSet.TYPE_FORWARD_ONLY),
0694: new Integer(ResultSet.CONCUR_UPDATABLE) });
0695: insertMetadataInContainer(
0696: metaData,
0697: MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
0698: new Class[] { Integer.TYPE, Integer.TYPE },
0699: new Object[] {
0700: new Integer(
0701: ResultSet.TYPE_SCROLL_INSENSITIVE),
0702: new Integer(ResultSet.CONCUR_READ_ONLY) });
0703: insertMetadataInContainer(
0704: metaData,
0705: MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
0706: new Class[] { Integer.TYPE, Integer.TYPE },
0707: new Object[] {
0708: new Integer(
0709: ResultSet.TYPE_SCROLL_INSENSITIVE),
0710: new Integer(ResultSet.CONCUR_UPDATABLE) });
0711: insertMetadataInContainer(
0712: metaData,
0713: MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
0714: new Class[] { Integer.TYPE, Integer.TYPE },
0715: new Object[] {
0716: new Integer(ResultSet.TYPE_SCROLL_SENSITIVE),
0717: new Integer(ResultSet.CONCUR_READ_ONLY) });
0718: insertMetadataInContainer(
0719: metaData,
0720: MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
0721: new Class[] { Integer.TYPE, Integer.TYPE },
0722: new Object[] {
0723: new Integer(ResultSet.TYPE_SCROLL_SENSITIVE),
0724: new Integer(ResultSet.CONCUR_UPDATABLE) });
0725: insertMetadataInContainer(
0726: metaData,
0727: MetadataDescription.SUPPORTS_RESULT_SET_HOLDABILITY,
0728: new Class[] { Integer.TYPE },
0729: new Object[] { new Integer(
0730: ResultSet.HOLD_CURSORS_OVER_COMMIT) });
0731: insertMetadataInContainer(
0732: metaData,
0733: MetadataDescription.SUPPORTS_RESULT_SET_HOLDABILITY,
0734: new Class[] { Integer.TYPE },
0735: new Object[] { new Integer(
0736: ResultSet.CLOSE_CURSORS_AT_COMMIT) });
0737: insertMetadataInContainer(metaData,
0738: MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
0739: new Class[] { Integer.TYPE },
0740: new Object[] { new Integer(
0741: ResultSet.TYPE_FORWARD_ONLY) });
0742: insertMetadataInContainer(metaData,
0743: MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
0744: new Class[] { Integer.TYPE },
0745: new Object[] { new Integer(
0746: ResultSet.TYPE_SCROLL_INSENSITIVE) });
0747: insertMetadataInContainer(metaData,
0748: MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
0749: new Class[] { Integer.TYPE },
0750: new Object[] { new Integer(
0751: ResultSet.TYPE_SCROLL_SENSITIVE) });
0752: insertMetadataInContainer(metaData,
0753: MetadataDescription.SUPPORTS_SAVEPOINTS, null, null);
0754: insertMetadataInContainer(
0755: metaData,
0756: MetadataDescription.SUPPORTS_SCHEMAS_IN_DATA_MANIPULATION,
0757: null, null);
0758: insertMetadataInContainer(
0759: metaData,
0760: MetadataDescription.SUPPORTS_SCHEMAS_IN_INDEX_DEFINITIONS,
0761: null, null);
0762: insertMetadataInContainer(
0763: metaData,
0764: MetadataDescription.SUPPORTS_SCHEMAS_IN_PRIVILEGE_DEFINITIONS,
0765: null, null);
0766: insertMetadataInContainer(
0767: metaData,
0768: MetadataDescription.SUPPORTS_SCHEMAS_IN_PROCEDURE_CALLS,
0769: null, null);
0770: insertMetadataInContainer(
0771: metaData,
0772: MetadataDescription.SUPPORTS_SCHEMAS_IN_TABLE_DEFINITIONS,
0773: null, null);
0774: insertMetadataInContainer(metaData,
0775: MetadataDescription.SUPPORTS_SELECT_FOR_UPDATE,
0776: null, null);
0777: insertMetadataInContainer(metaData,
0778: MetadataDescription.SUPPORTS_STATEMENT_POOLING,
0779: null, null);
0780: insertMetadataInContainer(metaData,
0781: MetadataDescription.SUPPORTS_STORED_PROCEDURES,
0782: null, null);
0783: insertMetadataInContainer(
0784: metaData,
0785: MetadataDescription.SUPPORTS_SUB_QUERIES_IN_COMPARISONS,
0786: null, null);
0787: insertMetadataInContainer(metaData,
0788: MetadataDescription.SUPPORTS_SUB_QUERIES_IN_EXISTS,
0789: null, null);
0790: insertMetadataInContainer(metaData,
0791: MetadataDescription.SUPPORTS_SUB_QUERIES_IN_INS,
0792: null, null);
0793: insertMetadataInContainer(
0794: metaData,
0795: MetadataDescription.SUPPORTS_SUB_QUERIES_IN_QUANTIFIEDS,
0796: null, null);
0797: insertMetadataInContainer(
0798: metaData,
0799: MetadataDescription.SUPPORTS_TABLE_CORRELATION_NAMES,
0800: null, null);
0801: insertMetadataInContainer(
0802: metaData,
0803: MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL,
0804: new Class[] { Integer.TYPE },
0805: new Object[] { new Integer(
0806: Connection.TRANSACTION_NONE) });
0807: insertMetadataInContainer(
0808: metaData,
0809: MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL,
0810: new Class[] { Integer.TYPE },
0811: new Object[] { new Integer(
0812: Connection.TRANSACTION_READ_COMMITTED) });
0813: insertMetadataInContainer(
0814: metaData,
0815: MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL,
0816: new Class[] { Integer.TYPE },
0817: new Object[] { new Integer(
0818: Connection.TRANSACTION_READ_UNCOMMITTED) });
0819: insertMetadataInContainer(
0820: metaData,
0821: MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL,
0822: new Class[] { Integer.TYPE },
0823: new Object[] { new Integer(
0824: Connection.TRANSACTION_REPEATABLE_READ) });
0825: insertMetadataInContainer(
0826: metaData,
0827: MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL,
0828: new Class[] { Integer.TYPE },
0829: new Object[] { new Integer(
0830: Connection.TRANSACTION_SERIALIZABLE) });
0831: insertMetadataInContainer(metaData,
0832: MetadataDescription.SUPPORTS_TRANSACTIONS, null,
0833: null);
0834: insertMetadataInContainer(metaData,
0835: MetadataDescription.SUPPORTS_UNION, null, null);
0836: insertMetadataInContainer(metaData,
0837: MetadataDescription.SUPPORTS_UNION_ALL, null, null);
0838: insertMetadataInContainer(metaData,
0839: MetadataDescription.UPDATES_ARE_DETECTED,
0840: new Class[] { Integer.TYPE },
0841: new Object[] { new Integer(
0842: ResultSet.TYPE_FORWARD_ONLY) });
0843: insertMetadataInContainer(metaData,
0844: MetadataDescription.UPDATES_ARE_DETECTED,
0845: new Class[] { Integer.TYPE },
0846: new Object[] { new Integer(
0847: ResultSet.TYPE_SCROLL_INSENSITIVE) });
0848: insertMetadataInContainer(metaData,
0849: MetadataDescription.UPDATES_ARE_DETECTED,
0850: new Class[] { Integer.TYPE },
0851: new Object[] { new Integer(
0852: ResultSet.TYPE_SCROLL_SENSITIVE) });
0853: insertMetadataInContainer(metaData,
0854: MetadataDescription.USES_LOCAL_FILE_PER_TABLE,
0855: null, null);
0856: insertMetadataInContainer(metaData,
0857: MetadataDescription.USES_LOCAL_FILES, null, null);
0858: insertMetadataInContainer(metaData,
0859: MetadataDescription.IS_CATALOG_AT_START, null, null);
0860:
0861: overrideSequoiaSpecificFeatures();
0862: } catch (Exception e) {
0863: if (e instanceof RuntimeException)
0864: logger.error(Translate
0865: .get("backend.meta.runtime.error"), e);
0866: throw new SQLException(Translate.get(
0867: "backend.meta.failed.get.info", e));
0868: }
0869:
0870: finally {
0871: // IGOR's fix: do that after we are finished with all DB accesses
0872: if (pooledConnection != null)
0873: connectionManager.releaseConnectionInAutoCommit(null,
0874: pooledConnection);
0875:
0876: if (!wasInitialized)
0877: connectionManager.finalizeConnections();
0878: }
0879: return metadataContainer;
0880: }
0881:
0882: /**
0883: * This method overrides metdata container information with Sequoia specific
0884: * limitations.
0885: */
0886: private void overrideSequoiaSpecificFeatures() {
0887: // Sequoia ResultSets are disconnected therefore they cannot detect deletes,
0888: // inserts or udpates.
0889: updateContainerInformation(
0890: MetadataDescription.DELETES_ARE_DETECTED,
0891: new Class[] { Integer.TYPE },
0892: new Object[] { new Integer(
0893: ResultSet.TYPE_SCROLL_INSENSITIVE) },
0894: Boolean.FALSE);
0895: updateContainerInformation(
0896: MetadataDescription.DELETES_ARE_DETECTED,
0897: new Class[] { Integer.TYPE },
0898: new Object[] { new Integer(
0899: ResultSet.TYPE_SCROLL_SENSITIVE) },
0900: Boolean.FALSE);
0901: updateContainerInformation(
0902: MetadataDescription.INSERTS_ARE_DETECTED,
0903: new Class[] { Integer.TYPE },
0904: new Object[] { new Integer(ResultSet.TYPE_FORWARD_ONLY) },
0905: Boolean.FALSE);
0906: updateContainerInformation(
0907: MetadataDescription.INSERTS_ARE_DETECTED,
0908: new Class[] { Integer.TYPE },
0909: new Object[] { new Integer(
0910: ResultSet.TYPE_SCROLL_INSENSITIVE) },
0911: Boolean.FALSE);
0912: updateContainerInformation(
0913: MetadataDescription.INSERTS_ARE_DETECTED,
0914: new Class[] { Integer.TYPE },
0915: new Object[] { new Integer(
0916: ResultSet.TYPE_SCROLL_SENSITIVE) },
0917: Boolean.FALSE);
0918:
0919: // we don't implement Blob references (= LOCATORs), the driver
0920: // delivers only copies that the application has to put back by itself.
0921: updateContainerInformation(
0922: MetadataDescription.LOCATORS_UPDATE_COPY, null, null,
0923: Boolean.TRUE);
0924:
0925: // Sequoia ResultSets are disconnected therefore they cannot detect deletes,
0926: // inserts or udpates.
0927: updateContainerInformation(
0928: MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
0929: new Class[] { Integer.TYPE },
0930: new Object[] { new Integer(ResultSet.TYPE_FORWARD_ONLY) },
0931: Boolean.FALSE);
0932: updateContainerInformation(
0933: MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
0934: new Class[] { Integer.TYPE },
0935: new Object[] { new Integer(
0936: ResultSet.TYPE_SCROLL_INSENSITIVE) },
0937: Boolean.FALSE);
0938: updateContainerInformation(
0939: MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
0940: new Class[] { Integer.TYPE },
0941: new Object[] { new Integer(
0942: ResultSet.TYPE_SCROLL_SENSITIVE) },
0943: Boolean.FALSE);
0944: updateContainerInformation(
0945: MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
0946: new Class[] { Integer.TYPE },
0947: new Object[] { new Integer(ResultSet.TYPE_FORWARD_ONLY) },
0948: Boolean.FALSE);
0949: updateContainerInformation(
0950: MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
0951: new Class[] { Integer.TYPE },
0952: new Object[] { new Integer(
0953: ResultSet.TYPE_SCROLL_INSENSITIVE) },
0954: Boolean.FALSE);
0955: updateContainerInformation(
0956: MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
0957: new Class[] { Integer.TYPE },
0958: new Object[] { new Integer(
0959: ResultSet.TYPE_SCROLL_SENSITIVE) },
0960: Boolean.FALSE);
0961: updateContainerInformation(
0962: MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
0963: new Class[] { Integer.TYPE },
0964: new Object[] { new Integer(ResultSet.TYPE_FORWARD_ONLY) },
0965: Boolean.FALSE);
0966: updateContainerInformation(
0967: MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
0968: new Class[] { Integer.TYPE },
0969: new Object[] { new Integer(
0970: ResultSet.TYPE_SCROLL_INSENSITIVE) },
0971: Boolean.FALSE);
0972: updateContainerInformation(
0973: MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
0974: new Class[] { Integer.TYPE },
0975: new Object[] { new Integer(
0976: ResultSet.TYPE_SCROLL_SENSITIVE) },
0977: Boolean.FALSE);
0978:
0979: // Sequoia ResultSets are updated when making changes to the database using
0980: // updatable ResultSets
0981: updateContainerInformation(
0982: MetadataDescription.OWN_DELETES_ARE_VISIBLE,
0983: new Class[] { Integer.TYPE },
0984: new Object[] { new Integer(ResultSet.TYPE_FORWARD_ONLY) },
0985: Boolean.TRUE);
0986: updateContainerInformation(
0987: MetadataDescription.OWN_DELETES_ARE_VISIBLE,
0988: new Class[] { Integer.TYPE },
0989: new Object[] { new Integer(
0990: ResultSet.TYPE_SCROLL_INSENSITIVE) },
0991: Boolean.TRUE);
0992: updateContainerInformation(
0993: MetadataDescription.OWN_DELETES_ARE_VISIBLE,
0994: new Class[] { Integer.TYPE },
0995: new Object[] { new Integer(
0996: ResultSet.TYPE_SCROLL_SENSITIVE) },
0997: Boolean.TRUE);
0998: updateContainerInformation(
0999: MetadataDescription.OWN_INSERTS_ARE_VISIBLE,
1000: new Class[] { Integer.TYPE },
1001: new Object[] { new Integer(ResultSet.TYPE_FORWARD_ONLY) },
1002: Boolean.TRUE);
1003: updateContainerInformation(
1004: MetadataDescription.OWN_INSERTS_ARE_VISIBLE,
1005: new Class[] { Integer.TYPE },
1006: new Object[] { new Integer(
1007: ResultSet.TYPE_SCROLL_INSENSITIVE) },
1008: Boolean.TRUE);
1009: updateContainerInformation(
1010: MetadataDescription.OWN_INSERTS_ARE_VISIBLE,
1011: new Class[] { Integer.TYPE },
1012: new Object[] { new Integer(
1013: ResultSet.TYPE_SCROLL_SENSITIVE) },
1014: Boolean.TRUE);
1015: updateContainerInformation(
1016: MetadataDescription.OWN_UPDATES_ARE_VISIBLE,
1017: new Class[] { Integer.TYPE },
1018: new Object[] { new Integer(ResultSet.TYPE_FORWARD_ONLY) },
1019: Boolean.TRUE);
1020: updateContainerInformation(
1021: MetadataDescription.OWN_UPDATES_ARE_VISIBLE,
1022: new Class[] { Integer.TYPE },
1023: new Object[] { new Integer(
1024: ResultSet.TYPE_SCROLL_INSENSITIVE) },
1025: Boolean.TRUE);
1026: updateContainerInformation(
1027: MetadataDescription.OWN_UPDATES_ARE_VISIBLE,
1028: new Class[] { Integer.TYPE },
1029: new Object[] { new Integer(
1030: ResultSet.TYPE_SCROLL_SENSITIVE) },
1031: Boolean.TRUE);
1032:
1033: // We emulate batch updates even if they are not handled optimally yet
1034: updateContainerInformation(
1035: MetadataDescription.SUPPORTS_BATCH_UPDATES, null, null,
1036: Boolean.TRUE);
1037:
1038: // It is currently not possible for a CallableStatement to return multiple
1039: // ResultSets
1040: updateContainerInformation(
1041: MetadataDescription.SUPPORTS_MULTIPLE_OPEN_RESULTS,
1042: null, null, Boolean.FALSE);
1043:
1044: // A single call to execute can only return one ResultSet. It this suppose
1045: // to be retrived after an executeBatch?
1046: updateContainerInformation(
1047: MetadataDescription.SUPPORTS_MULTIPLE_RESULTSETS, null,
1048: null, Boolean.FALSE);
1049:
1050: // We support open cursors and statements across commit/rollback. Note this
1051: // only applies for the driver side since everything is closed right away on
1052: // the controller side.
1053: updateContainerInformation(
1054: MetadataDescription.SUPPORTS_OPEN_CURSORS_ACROSS_COMMIT,
1055: null, null, Boolean.TRUE);
1056: updateContainerInformation(
1057: MetadataDescription.SUPPORTS_OPEN_CURSORS_ACROSS_ROLLBACK,
1058: null, null, Boolean.TRUE);
1059: updateContainerInformation(
1060: MetadataDescription.SUPPORTS_OPEN_STATEMENTS_ACROSS_COMMIT,
1061: null, null, Boolean.TRUE);
1062: updateContainerInformation(
1063: MetadataDescription.SUPPORTS_OPEN_STATEMENTS_ACROSS_ROLLBACK,
1064: null, null, Boolean.TRUE);
1065:
1066: // We do not close ResultSets at commit time
1067: updateContainerInformation(
1068: MetadataDescription.SUPPORTS_RESULT_SET_HOLDABILITY,
1069: new Class[] { Integer.TYPE },
1070: new Object[] { new Integer(
1071: ResultSet.HOLD_CURSORS_OVER_COMMIT) },
1072: Boolean.TRUE);
1073: updateContainerInformation(
1074: MetadataDescription.SUPPORTS_RESULT_SET_HOLDABILITY,
1075: new Class[] { Integer.TYPE },
1076: new Object[] { new Integer(
1077: ResultSet.CLOSE_CURSORS_AT_COMMIT) },
1078: Boolean.FALSE);
1079:
1080: // We do support CONCUR_READ_ONLY and CONCUR_UPDATABLE concurrency modes
1081: // for all supported ResultSet types
1082: updateContainerInformation(
1083: MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
1084: new Class[] { Integer.TYPE, Integer.TYPE },
1085: new Object[] {
1086: new Integer(ResultSet.TYPE_FORWARD_ONLY),
1087: new Integer(ResultSet.CONCUR_READ_ONLY) },
1088: Boolean.TRUE);
1089: updateContainerInformation(
1090: MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
1091: new Class[] { Integer.TYPE, Integer.TYPE },
1092: new Object[] {
1093: new Integer(ResultSet.TYPE_FORWARD_ONLY),
1094: new Integer(ResultSet.CONCUR_UPDATABLE) },
1095: Boolean.TRUE);
1096: updateContainerInformation(
1097: MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
1098: new Class[] { Integer.TYPE, Integer.TYPE },
1099: new Object[] {
1100: new Integer(ResultSet.TYPE_SCROLL_INSENSITIVE),
1101: new Integer(ResultSet.CONCUR_READ_ONLY) },
1102: Boolean.TRUE);
1103: updateContainerInformation(
1104: MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
1105: new Class[] { Integer.TYPE, Integer.TYPE },
1106: new Object[] {
1107: new Integer(ResultSet.TYPE_SCROLL_INSENSITIVE),
1108: new Integer(ResultSet.CONCUR_UPDATABLE) },
1109: Boolean.TRUE);
1110: updateContainerInformation(
1111: MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
1112: new Class[] { Integer.TYPE, Integer.TYPE },
1113: new Object[] {
1114: new Integer(ResultSet.TYPE_SCROLL_SENSITIVE),
1115: new Integer(ResultSet.CONCUR_READ_ONLY) },
1116: Boolean.FALSE);
1117: updateContainerInformation(
1118: MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
1119: new Class[] { Integer.TYPE, Integer.TYPE },
1120: new Object[] {
1121: new Integer(ResultSet.TYPE_SCROLL_SENSITIVE),
1122: new Integer(ResultSet.CONCUR_UPDATABLE) },
1123: Boolean.FALSE);
1124:
1125: // We do support FORWARD_ONLY and SCROLL_INSENSITIVE ResultSets only
1126: updateContainerInformation(
1127: MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
1128: new Class[] { Integer.TYPE },
1129: new Object[] { new Integer(ResultSet.TYPE_FORWARD_ONLY) },
1130: Boolean.TRUE);
1131: updateContainerInformation(
1132: MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
1133: new Class[] { Integer.TYPE },
1134: new Object[] { new Integer(
1135: ResultSet.TYPE_SCROLL_INSENSITIVE) },
1136: Boolean.TRUE);
1137: updateContainerInformation(
1138: MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
1139: new Class[] { Integer.TYPE },
1140: new Object[] { new Integer(
1141: ResultSet.TYPE_SCROLL_SENSITIVE) },
1142: Boolean.FALSE);
1143:
1144: // No support for Savepoints yet
1145: updateContainerInformation(
1146: MetadataDescription.SUPPORTS_SAVEPOINTS, null, null,
1147: Boolean.FALSE);
1148:
1149: // Updates are never detected since our ResultSets are disconnected
1150: updateContainerInformation(
1151: MetadataDescription.UPDATES_ARE_DETECTED,
1152: new Class[] { Integer.TYPE },
1153: new Object[] { new Integer(ResultSet.TYPE_FORWARD_ONLY) },
1154: Boolean.FALSE);
1155: updateContainerInformation(
1156: MetadataDescription.UPDATES_ARE_DETECTED,
1157: new Class[] { Integer.TYPE },
1158: new Object[] { new Integer(
1159: ResultSet.TYPE_SCROLL_INSENSITIVE) },
1160: Boolean.FALSE);
1161: updateContainerInformation(
1162: MetadataDescription.UPDATES_ARE_DETECTED,
1163: new Class[] { Integer.TYPE },
1164: new Object[] { new Integer(
1165: ResultSet.TYPE_SCROLL_SENSITIVE) },
1166: Boolean.FALSE);
1167: }
1168:
1169: /**
1170: * Gets the list of tables of a database and add them to the database schema.
1171: * The caller must ensure that the parameters are not <code>null</code>.
1172: *
1173: * @exception SQLException if an error occurs
1174: */
1175: public void createDatabaseSchemaDynamically() throws SQLException {
1176: if (dynamicPrecision == DatabaseBackendSchemaConstants.DynamicPrecisionStatic)
1177: return;
1178: PooledConnection pooledConnection = null;
1179: boolean wasInitialized = connectionManager.isInitialized();
1180:
1181: Connection connection;
1182: try {
1183: if (!wasInitialized)
1184: connectionManager.initializeConnections();
1185:
1186: pooledConnection = connectionManager
1187: .retrieveConnectionInAutoCommit(null);
1188: if (pooledConnection == null) {
1189: String msg = Translate
1190: .get("backend.meta.connection.failed");
1191: logger.error(msg);
1192: throw new SQLException(msg);
1193: }
1194: connection = pooledConnection.getConnection();
1195: if (connection == null) {
1196: String msg = Translate
1197: .get("backend.meta.connection.failed");
1198: logger.error(msg);
1199: throw new SQLException(msg);
1200: }
1201:
1202: databaseSchema = new DatabaseSQLMetaData(logger,
1203: connection, dynamicPrecision, gatherSystemTables,
1204: schemaName).createDatabaseSchema(vdbName);
1205: } catch (Exception e) {
1206: if (e instanceof RuntimeException)
1207: logger.error(Translate
1208: .get("backend.meta.runtime.error"), e);
1209: throw new SQLException(Translate.get(
1210: "backend.meta.failed.get.info", e));
1211: } finally {
1212: if (pooledConnection != null)
1213: connectionManager.releaseConnectionInAutoCommit(null,
1214: pooledConnection);
1215:
1216: if (!wasInitialized)
1217: connectionManager.finalizeConnections();
1218:
1219: }
1220: }
1221:
1222: /**
1223: * Returns the database schema. Returns <code>null</code> If an error has
1224: * occured during the schema generation.
1225: * <p>
1226: * If the schema has not been previously computed,
1227: * {@link #createDatabaseSchemaDynamically()}is called.
1228: *
1229: * @return a <code>DatabaseSchema</code> value
1230: * @exception SQLException if a problem occurs when creating the database
1231: * schema
1232: * @see #createDatabaseSchemaDynamically
1233: */
1234: public DatabaseSchema getDatabaseSchema() throws SQLException {
1235: if (databaseSchema == null)
1236: createDatabaseSchemaDynamically();
1237: return databaseSchema;
1238: }
1239: }
|