Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

DatabaseBackendMetaData.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2005 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Julie Marguerite.
00022  * Contributor(s): Emmanuel Cecchet, Nicolas Modrzyk, Mathieu Peltier, Jean-Bernard van Zuylen.
00023  */
00024 
00025 package org.objectweb.cjdbc.controller.backend;
00026 
00027 import java.lang.reflect.InvocationTargetException;
00028 import java.lang.reflect.Method;
00029 import java.sql.Connection;
00030 import java.sql.DatabaseMetaData;
00031 import java.sql.ResultSet;
00032 import java.sql.SQLException;
00033 
00034 import org.objectweb.cjdbc.common.i18n.Translate;
00035 import org.objectweb.cjdbc.common.log.Trace;
00036 import org.objectweb.cjdbc.common.sql.metadata.MetadataContainer;
00037 import org.objectweb.cjdbc.common.sql.metadata.MetadataDescription;
00038 import org.objectweb.cjdbc.common.sql.schema.DatabaseSQLMetaData;
00039 import org.objectweb.cjdbc.common.sql.schema.DatabaseSchema;
00040 import org.objectweb.cjdbc.controller.connection.AbstractConnectionManager;
00041 
00042 /**
00043  * A <code>DatabaseBackendMetaData</code> is used to retrieve the database
00044  * schema of a real database backend that will have to be bound to a virtual
00045  * C-JDBC database.
00046  * 
00047  * @author <a href="mailto:Julie.Marguerite@inria.fr">Julie Marguerite </a>
00048  * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
00049  * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
00050  * @author <a href="mailto:Mathieu.Peltier@inrialpes.fr">Mathieu Peltier </a>
00051  * @author <a href="mailto:jbvanzuylen@transwide.com">Jean-Bernard van Zuylen
00052  *         </a>
00053  * @version 1.0
00054  */
00055 public final class DatabaseBackendMetaData
00056 {
00057   /** Connection manager to get a connection from. */
00058   private AbstractConnectionManager connectionManager;
00059 
00060   /** Logger instance. */
00061   private Trace                     logger;
00062 
00063   /** Schema of the database backend. */
00064   private DatabaseSchema            databaseSchema;
00065 
00066   /** The precision of the dynamically generated schema */
00067   private int                       dynamicPrecision;
00068 
00069   /** Should the system tables be gathered or not */
00070   private boolean                   gatherSystemTables = false;
00071 
00072   /** The name of the schema used to gather meta data */
00073   private String                    schemaName         = null;
00074 
00075   /** Container for static metadata */
00076   private MetadataContainer         metadataContainer  = null;
00077 
00078   /**
00079    * Creates a new <code>DatabaseBackendMetaData</code> instance. This class
00080    * takes care of initializing the connection manager if needed but the driver
00081    * must have been previously loaded else the connection manager's
00082    * initialization will fail.
00083    * 
00084    * @param connectionManager the connection manager to gather the schema from
00085    * @param logger the logger (usually the backend logger) to use
00086    * @param dynamicPrecision the precision with which we gather a schema
00087    *          directly from the backend
00088    * @param gatherSystemTables true if system tables must be gathered
00089    * @param schemaName schema name to use to retrieve information
00090    */
00091   public DatabaseBackendMetaData(AbstractConnectionManager connectionManager,
00092       Trace logger, int dynamicPrecision, boolean gatherSystemTables,
00093       String schemaName)
00094   {
00095     this.connectionManager = connectionManager;
00096     this.dynamicPrecision = dynamicPrecision;
00097     this.logger = logger;
00098     this.gatherSystemTables = gatherSystemTables;
00099     this.schemaName = schemaName;
00100   }
00101 
00102   /**
00103    * This method invokes by reflection the appropriate metadata method and fills
00104    * the container with the result.
00105    * 
00106    * @param metaData metadata to invoke
00107    * @param methodName method to invoke
00108    * @param parametersType parameters type of method to invoke
00109    * @param arguments arguments to invoke the method
00110    */
00111   private void insertMetadataInContainer(DatabaseMetaData metaData,
00112       String methodName, Class[] parametersType, Object[] arguments)
00113   {
00114     Class metadataClass = metaData.getClass();
00115     try
00116     {
00117       Method method = metadataClass.getMethod(methodName, parametersType);
00118       Object result = method.invoke(metaData, arguments);
00119       updateContainerInformation(methodName, parametersType, arguments, result);
00120     }
00121     catch (SecurityException e)
00122     {
00123       if (logger.isDebugEnabled())
00124         logger.debug("Problem calling " + methodName, e);
00125       else
00126         logger.warn("Unable to get information for " + methodName);
00127     }
00128     catch (IllegalArgumentException e)
00129     {
00130       if (logger.isDebugEnabled())
00131         logger.debug("Problem calling " + methodName, e);
00132       else
00133         logger.warn("Unable to get information for " + methodName);
00134     }
00135     catch (NoSuchMethodException e)
00136     {
00137       if (logger.isDebugEnabled())
00138         logger.debug("Metadata " + methodName
00139             + " does not exists. Probably not supported by your JDK.");
00140     }
00141     catch (IllegalAccessException e)
00142     {
00143       if (logger.isDebugEnabled())
00144         logger.debug("Problem calling " + methodName, e);
00145       else
00146         logger.warn("Unable to get information for " + methodName);
00147     }
00148     catch (InvocationTargetException e)
00149     {
00150       if (logger.isDebugEnabled())
00151         logger.debug("Problem calling " + methodName, e);
00152       else
00153         logger.warn("Unable to get information for " + methodName);
00154     }
00155   }
00156 
00157   /**
00158    * Update the metadata container information for the given method.
00159    * 
00160    * @param methodName method invoked to generate the key in the container
00161    * @param parametersType parameters type of invoked method
00162    * @param arguments arguments used to invoke the method
00163    * @param result result of the method call
00164    */
00165   private void updateContainerInformation(String methodName,
00166       Class[] parametersType, Object[] arguments, Object result)
00167   {
00168     String key = MetadataContainer.getContainerKey(methodName,
00169         parametersType, arguments);
00170     metadataContainer.put(key, result);
00171     if (logger.isDebugEnabled())
00172       logger.debug("Updating metadata " + key + "=" + result);
00173   }
00174 
00175   /**
00176    * Retrieve metadata from a connection on this backend. Note that some values
00177    * are overriden with C-JDBC specific features (add-ons or limitations).
00178    * 
00179    * @return a metadata container including all metadata values
00180    * @throws SQLException if an error occurs
00181    */
00182   public MetadataContainer retrieveDatabaseMetadata() throws SQLException
00183   {
00184     if (metadataContainer != null)
00185       return metadataContainer;
00186 
00187     // Retrieve metadata
00188     Connection connection = null;
00189     boolean wasInitialized = connectionManager.isInitialized();
00190 
00191     DatabaseMetaData metaData;
00192     try
00193     {
00194       if (!wasInitialized)
00195         connectionManager.initializeConnections();
00196 
00197       connection = connectionManager.getConnection();
00198       if (connection == null)
00199       {
00200         String msg = Translate.get("backend.meta.connection.failed");
00201         logger.error(msg);
00202         throw new SQLException(msg);
00203       }
00204 
00205       metaData = connection.getMetaData();
00206       metadataContainer = new MetadataContainer(connection.getMetaData()
00207           .getURL());
00208     }
00209     catch (Exception e)
00210     {
00211       if (e instanceof RuntimeException)
00212         logger.error(Translate.get("backend.meta.runtime.error"), e);
00213       throw new SQLException(Translate.get("backend.meta.failed.get.info", e));
00214     }
00215     finally
00216     {
00217       if (connection != null)
00218         connectionManager.releaseConnection(connection);
00219 
00220       if (!wasInitialized)
00221         connectionManager.finalizeConnections();
00222     }
00223 
00224     // TODO: Move this to a separate command
00225     // Boolean.valueOf(metaData.supportsConvert(int,int)
00226 
00227     // Metadata in alphabetical order
00228     insertMetadataInContainer(metaData,
00229         MetadataDescription.ALL_PROCEDURES_ARE_CALLABLE, null, null);
00230     insertMetadataInContainer(metaData,
00231         MetadataDescription.ALL_TABLES_ARE_SELECTABLE, null, null);
00232     insertMetadataInContainer(metaData,
00233         MetadataDescription.DATA_DEFINITION_CAUSES_TRANSACTION_COMMIT, null,
00234         null);
00235     insertMetadataInContainer(metaData,
00236         MetadataDescription.DATA_DEFINITION_IGNORED_IN_TRANSACTIONS, null, null);
00237     insertMetadataInContainer(metaData,
00238         MetadataDescription.DELETES_ARE_DETECTED, new Class[]{Integer.TYPE},
00239         new Object[]{new Integer(ResultSet.TYPE_FORWARD_ONLY)});
00240     insertMetadataInContainer(metaData,
00241         MetadataDescription.DELETES_ARE_DETECTED, new Class[]{Integer.TYPE},
00242         new Object[]{new Integer(ResultSet.TYPE_SCROLL_INSENSITIVE)});
00243     insertMetadataInContainer(metaData,
00244         MetadataDescription.DELETES_ARE_DETECTED, new Class[]{Integer.TYPE},
00245         new Object[]{new Integer(ResultSet.TYPE_SCROLL_SENSITIVE)});
00246     insertMetadataInContainer(metaData,
00247         MetadataDescription.DOES_MAX_ROW_SIZE_INCLUDE_BLOBS, null, null);
00248     insertMetadataInContainer(metaData,
00249         MetadataDescription.GET_DEFAULT_TRANSACTION_ISOLATION, null, null);
00250     insertMetadataInContainer(metaData,
00251         MetadataDescription.GET_DATABASE_MAJOR_VERSION, null, null);
00252     insertMetadataInContainer(metaData,
00253         MetadataDescription.GET_DATABASE_MINOR_VERSION, null, null);
00254     insertMetadataInContainer(metaData,
00255         MetadataDescription.GET_DRIVER_MAJOR_VERSION, null, null);
00256     insertMetadataInContainer(metaData,
00257         MetadataDescription.GET_DRIVER_MINOR_VERSION, null, null);
00258     insertMetadataInContainer(metaData,
00259         MetadataDescription.GET_JDBC_MAJOR_VERSION, null, null);
00260     insertMetadataInContainer(metaData,
00261         MetadataDescription.GET_JDBC_MINOR_VERSION, null, null);
00262     insertMetadataInContainer(metaData,
00263         MetadataDescription.GET_MAX_BINARY_LITERAL_LENGTH, null, null);
00264     insertMetadataInContainer(metaData,
00265         MetadataDescription.GET_RESULTSET_HOLDABILITY, null, null);
00266     insertMetadataInContainer(metaData, MetadataDescription.GET_SQL_STATE_TYPE,
00267         null, null);
00268     insertMetadataInContainer(metaData,
00269         MetadataDescription.GET_MAX_CATALOG_NAME_LENGTH, null, null);
00270     insertMetadataInContainer(metaData,
00271         MetadataDescription.GET_MAX_CHAR_LITERAL_LENGTH, null, null);
00272     insertMetadataInContainer(metaData,
00273         MetadataDescription.GET_MAX_COLUMN_NAME_LENGTH, null, null);
00274     insertMetadataInContainer(metaData,
00275         MetadataDescription.GET_MAX_COLUMNS_IN_GROUP_BY, null, null);
00276     insertMetadataInContainer(metaData,
00277         MetadataDescription.GET_MAX_COLUMNS_IN_INDEX, null, null);
00278     insertMetadataInContainer(metaData,
00279         MetadataDescription.GET_MAX_COLUMNS_IN_ORDER_BY, null, null);
00280     insertMetadataInContainer(metaData,
00281         MetadataDescription.GET_MAX_COLUMNS_IN_SELECT, null, null);
00282     insertMetadataInContainer(metaData,
00283         MetadataDescription.GET_MAX_COLUMNS_IN_TABLE, null, null);
00284     insertMetadataInContainer(metaData,
00285         MetadataDescription.GET_MAX_CONNECTIONS, null, null);
00286     insertMetadataInContainer(metaData,
00287         MetadataDescription.GET_MAX_CURSOR_NAME_LENGTH, null, null);
00288     insertMetadataInContainer(metaData,
00289         MetadataDescription.GET_MAX_INDEX_LENGTH, null, null);
00290     insertMetadataInContainer(metaData,
00291         MetadataDescription.GET_MAX_PROCEDURE_NAME_LENGTH, null, null);
00292     insertMetadataInContainer(metaData, MetadataDescription.GET_MAX_ROW_SIZE,
00293         null, null);
00294     insertMetadataInContainer(metaData,
00295         MetadataDescription.GET_MAX_SCHEMA_NAME_LENGTH, null, null);
00296     insertMetadataInContainer(metaData,
00297         MetadataDescription.GET_MAX_STATEMENT_LENGTH, null, null);
00298     insertMetadataInContainer(metaData, MetadataDescription.GET_MAX_STATEMENTS,
00299         null, null);
00300     insertMetadataInContainer(metaData,
00301         MetadataDescription.GET_MAX_TABLE_NAME_LENGTH, null, null);
00302     insertMetadataInContainer(metaData,
00303         MetadataDescription.GET_MAX_TABLES_IN_SELECT, null, null);
00304     insertMetadataInContainer(metaData,
00305         MetadataDescription.GET_MAX_USER_NAME_LENGTH, null, null);
00306     // strings
00307     insertMetadataInContainer(metaData,
00308         MetadataDescription.GET_CATALOG_SEPARATOR, null, null);
00309     insertMetadataInContainer(metaData, MetadataDescription.GET_CATALOG_TERM,
00310         null, null);
00311     insertMetadataInContainer(metaData,
00312         MetadataDescription.GET_DATABASE_PRODUCT_NAME, null, null);
00313     insertMetadataInContainer(metaData, MetadataDescription.GET_DRIVER_NAME,
00314         null, null);
00315     insertMetadataInContainer(metaData, MetadataDescription.GET_DRIVER_VERSION,
00316         null, null);
00317     insertMetadataInContainer(metaData,
00318         MetadataDescription.GET_EXTRA_NAME_CHARACTERS, null, null);
00319     insertMetadataInContainer(metaData,
00320         MetadataDescription.GET_IDENTIFIER_QUOTE_STRING, null, null);
00321     insertMetadataInContainer(metaData,
00322         MetadataDescription.GET_NUMERIC_FUNCTIONS, null, null);
00323     insertMetadataInContainer(metaData, MetadataDescription.GET_PROCEDURE_TERM,
00324         null, null);
00325     insertMetadataInContainer(metaData, MetadataDescription.GET_SCHEMA_TERM,
00326         null, null);
00327     insertMetadataInContainer(metaData,
00328         MetadataDescription.GET_SEARCH_STRING_ESCAPE, null, null);
00329     insertMetadataInContainer(metaData, MetadataDescription.GET_SQL_KEYWORDS,
00330         null, null);
00331     insertMetadataInContainer(metaData,
00332         MetadataDescription.GET_STRING_FUNCTIONS, null, null);
00333     insertMetadataInContainer(metaData,
00334         MetadataDescription.GET_SYSTEM_FUNCTIONS, null, null);
00335     insertMetadataInContainer(metaData,
00336         MetadataDescription.GET_TIME_DATE_FUNCTIONS, null, null);
00337     insertMetadataInContainer(metaData,
00338         MetadataDescription.INSERTS_ARE_DETECTED, new Class[]{Integer.TYPE},
00339         new Object[]{new Integer(ResultSet.TYPE_FORWARD_ONLY)});
00340     insertMetadataInContainer(metaData,
00341         MetadataDescription.INSERTS_ARE_DETECTED, new Class[]{Integer.TYPE},
00342         new Object[]{new Integer(ResultSet.TYPE_SCROLL_INSENSITIVE)});
00343     insertMetadataInContainer(metaData,
00344         MetadataDescription.INSERTS_ARE_DETECTED, new Class[]{Integer.TYPE},
00345         new Object[]{new Integer(ResultSet.TYPE_SCROLL_SENSITIVE)});
00346     insertMetadataInContainer(metaData,
00347         MetadataDescription.LOCATORS_UPDATE_COPY, null, null);
00348     insertMetadataInContainer(metaData,
00349         MetadataDescription.NULL_PLUS_NON_NULL_IS_NULL, null, null);
00350     insertMetadataInContainer(metaData,
00351         MetadataDescription.NULLS_ARE_SORTED_AT_END, null, null);
00352     insertMetadataInContainer(metaData,
00353         MetadataDescription.NULLS_ARE_SORTED_AT_START, null, null);
00354     insertMetadataInContainer(metaData,
00355         MetadataDescription.NULLS_ARE_SORTED_HIGH, null, null);
00356     insertMetadataInContainer(metaData,
00357         MetadataDescription.NULLS_ARE_SORTED_LOW, null, null);
00358     insertMetadataInContainer(metaData,
00359         MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
00360         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00361             ResultSet.TYPE_FORWARD_ONLY)});
00362     insertMetadataInContainer(metaData,
00363         MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
00364         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00365             ResultSet.TYPE_SCROLL_INSENSITIVE)});
00366     insertMetadataInContainer(metaData,
00367         MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
00368         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00369             ResultSet.TYPE_SCROLL_SENSITIVE)});
00370     insertMetadataInContainer(metaData,
00371         MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
00372         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00373             ResultSet.TYPE_FORWARD_ONLY)});
00374     insertMetadataInContainer(metaData,
00375         MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
00376         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00377             ResultSet.TYPE_SCROLL_INSENSITIVE)});
00378     insertMetadataInContainer(metaData,
00379         MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
00380         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00381             ResultSet.TYPE_SCROLL_SENSITIVE)});
00382     insertMetadataInContainer(metaData,
00383         MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
00384         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00385             ResultSet.TYPE_FORWARD_ONLY)});
00386     insertMetadataInContainer(metaData,
00387         MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
00388         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00389             ResultSet.TYPE_SCROLL_INSENSITIVE)});
00390     insertMetadataInContainer(metaData,
00391         MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
00392         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00393             ResultSet.TYPE_SCROLL_SENSITIVE)});
00394     insertMetadataInContainer(metaData,
00395         MetadataDescription.OWN_DELETES_ARE_VISIBLE, new Class[]{Integer.TYPE},
00396         new Object[]{new Integer(ResultSet.TYPE_FORWARD_ONLY)});
00397     insertMetadataInContainer(metaData,
00398         MetadataDescription.OWN_DELETES_ARE_VISIBLE, new Class[]{Integer.TYPE},
00399         new Object[]{new Integer(ResultSet.TYPE_SCROLL_INSENSITIVE)});
00400     insertMetadataInContainer(metaData,
00401         MetadataDescription.OWN_DELETES_ARE_VISIBLE, new Class[]{Integer.TYPE},
00402         new Object[]{new Integer(ResultSet.TYPE_SCROLL_SENSITIVE)});
00403     insertMetadataInContainer(metaData,
00404         MetadataDescription.OWN_INSERTS_ARE_VISIBLE, new Class[]{Integer.TYPE},
00405         new Object[]{new Integer(ResultSet.TYPE_FORWARD_ONLY)});
00406     insertMetadataInContainer(metaData,
00407         MetadataDescription.OWN_INSERTS_ARE_VISIBLE, new Class[]{Integer.TYPE},
00408         new Object[]{new Integer(ResultSet.TYPE_SCROLL_INSENSITIVE)});
00409     insertMetadataInContainer(metaData,
00410         MetadataDescription.OWN_INSERTS_ARE_VISIBLE, new Class[]{Integer.TYPE},
00411         new Object[]{new Integer(ResultSet.TYPE_SCROLL_SENSITIVE)});
00412     insertMetadataInContainer(metaData,
00413         MetadataDescription.OWN_UPDATES_ARE_VISIBLE, new Class[]{Integer.TYPE},
00414         new Object[]{new Integer(ResultSet.TYPE_FORWARD_ONLY)});
00415     insertMetadataInContainer(metaData,
00416         MetadataDescription.OWN_UPDATES_ARE_VISIBLE, new Class[]{Integer.TYPE},
00417         new Object[]{new Integer(ResultSet.TYPE_SCROLL_INSENSITIVE)});
00418     insertMetadataInContainer(metaData,
00419         MetadataDescription.OWN_UPDATES_ARE_VISIBLE, new Class[]{Integer.TYPE},
00420         new Object[]{new Integer(ResultSet.TYPE_SCROLL_SENSITIVE)});
00421     insertMetadataInContainer(metaData,
00422         MetadataDescription.STORES_LOWER_CASE_IDENTIFIERS, null, null);
00423     insertMetadataInContainer(metaData,
00424         MetadataDescription.STORES_LOWER_CASE_QUOTED_IDENTIFIERS, null, null);
00425     insertMetadataInContainer(metaData,
00426         MetadataDescription.STORES_MIXED_CASE_IDENTIFIERS, null, null);
00427     insertMetadataInContainer(metaData,
00428         MetadataDescription.STORES_MIXED_CASE_QUOTED_IDENTIFIERS, null, null);
00429     insertMetadataInContainer(metaData,
00430         MetadataDescription.STORES_UPPER_CASE_IDENTIFIERS, null, null);
00431     insertMetadataInContainer(metaData,
00432         MetadataDescription.STORES_UPPER_CASE_QUOTED_IDENTIFIERS, null, null);
00433     insertMetadataInContainer(metaData,
00434         MetadataDescription.SUPPORTS_ALTER_TABLE_WITH_ADD_COLUMN, null, null);
00435     insertMetadataInContainer(metaData,
00436         MetadataDescription.SUPPORTS_ALTER_TABLE_WITH_DROP_COLUMN, null, null);
00437     insertMetadataInContainer(metaData,
00438         MetadataDescription.SUPPORTS_ANSI92_ENTRY_LEVEL_SQL, null, null);
00439     insertMetadataInContainer(metaData,
00440         MetadataDescription.SUPPORTS_ANSI92_FULL_SQL, null, null);
00441     insertMetadataInContainer(metaData,
00442         MetadataDescription.SUPPORTS_ANSI92_INTERMEDIATE_SQL, null, null);
00443     insertMetadataInContainer(metaData,
00444         MetadataDescription.SUPPORTS_BATCH_UPDATES, null, null);
00445     insertMetadataInContainer(metaData,
00446         MetadataDescription.SUPPORTS_CATALOGS_IN_DATA_MANIPULATION, null, null);
00447     insertMetadataInContainer(metaData,
00448         MetadataDescription.SUPPORTS_CATALOGS_IN_INDEX_DEFINITIONS, null, null);
00449     insertMetadataInContainer(metaData,
00450         MetadataDescription.SUPPORTS_CATALOGS_IN_PRIVILEGE_DEFINITIONS, null,
00451         null);
00452     insertMetadataInContainer(metaData,
00453         MetadataDescription.SUPPORTS_CATALOGS_IN_PROCEDURE_CALLS, null, null);
00454     insertMetadataInContainer(metaData,
00455         MetadataDescription.SUPPORTS_CATALOGS_IN_TABLE_DEFINITIONS, null, null);
00456     insertMetadataInContainer(metaData,
00457         MetadataDescription.SUPPORTS_COLUMN_ALIASING, null, null);
00458     insertMetadataInContainer(metaData, MetadataDescription.SUPPORTS_CONVERT,
00459         null, null);
00460     insertMetadataInContainer(metaData,
00461         MetadataDescription.SUPPORTS_CORE_SQL_GRAMMAR, null, null);
00462     insertMetadataInContainer(metaData,
00463         MetadataDescription.SUPPORTS_CORRELATED_SUBQUERIES, null, null);
00464     insertMetadataInContainer(
00465         metaData,
00466         MetadataDescription.SUPPORTS_DATA_DEFINITION_AND_DATA_MANIPULATION_TRANSACTIONS,
00467         null, null);
00468     insertMetadataInContainer(metaData,
00469         MetadataDescription.SUPPORTS_DATA_MANIPULATION_TRANSACTIONS_ONLY, null,
00470         null);
00471     insertMetadataInContainer(metaData,
00472         MetadataDescription.SUPPORTS_DIFFERENT_TABLE_CORRELATION_NAMES, null,
00473         null);
00474     insertMetadataInContainer(metaData,
00475         MetadataDescription.SUPPORTS_EXPRESSIONS_IN_ORDER_BY, null, null);
00476     insertMetadataInContainer(metaData,
00477         MetadataDescription.SUPPORTS_EXTENDED_SQL_GRAMMAR, null, null);
00478     insertMetadataInContainer(metaData,
00479         MetadataDescription.SUPPORTS_FULL_OUTER_JOINS, null, null);
00480     insertMetadataInContainer(metaData,
00481         MetadataDescription.SUPPORTS_GET_GENERATED_KEYS, null, null);
00482     insertMetadataInContainer(metaData, MetadataDescription.SUPPORTS_GROUP_BY,
00483         null, null);
00484     insertMetadataInContainer(metaData,
00485         MetadataDescription.SUPPORTS_GROUP_BY_BEYOND_SELECT, null, null);
00486     insertMetadataInContainer(metaData,
00487         MetadataDescription.SUPPORTS_GROUP_BY_UNRELATED, null, null);
00488     insertMetadataInContainer(metaData,
00489         MetadataDescription.SUPPORTS_INTEGRITY_ENHANCEMENT_FACILITY, null, null);
00490     insertMetadataInContainer(metaData,
00491         MetadataDescription.SUPPORTS_LIKE_ESCAPE_CLAUSE, null, null);
00492     insertMetadataInContainer(metaData,
00493         MetadataDescription.SUPPORTS_LIMITED_OUTER_JOINS, null, null);
00494     insertMetadataInContainer(metaData,
00495         MetadataDescription.SUPPORTS_MINIMUM_SQL_GRAMMAR, null, null);
00496     insertMetadataInContainer(metaData,
00497         MetadataDescription.SUPPORTS_MIXED_CASE_IDENTIFIERS, null, null);
00498     insertMetadataInContainer(metaData,
00499         MetadataDescription.SUPPORTS_MIXED_CASE_QUOTED_IDENTIFIERS, null, null);
00500     insertMetadataInContainer(metaData,
00501         MetadataDescription.SUPPORTS_MULTIPLE_OPEN_RESULTS, null, null);
00502     insertMetadataInContainer(metaData,
00503         MetadataDescription.SUPPORTS_MULTIPLE_RESULTSETS, null, null);
00504     insertMetadataInContainer(metaData,
00505         MetadataDescription.SUPPORTS_MULTIPLE_TRANSACTIONS, null, null);
00506     insertMetadataInContainer(metaData,
00507         MetadataDescription.SUPPORTS_NAMED_PARAMETERS, null, null);
00508     insertMetadataInContainer(metaData,
00509         MetadataDescription.SUPPORTS_NON_NULLABLE_COLUMNS, null, null);
00510     insertMetadataInContainer(metaData,
00511         MetadataDescription.SUPPORTS_OPEN_CURSORS_ACROSS_COMMIT, null, null);
00512     insertMetadataInContainer(metaData,
00513         MetadataDescription.SUPPORTS_OPEN_CURSORS_ACROSS_ROLLBACK, null, null);
00514     insertMetadataInContainer(metaData,
00515         MetadataDescription.SUPPORTS_OPEN_STATEMENTS_ACROSS_COMMIT, null, null);
00516     insertMetadataInContainer(metaData,
00517         MetadataDescription.SUPPORTS_OPEN_STATEMENTS_ACROSS_ROLLBACK, null,
00518         null);
00519     insertMetadataInContainer(metaData,
00520         MetadataDescription.SUPPORTS_ORDER_BY_UNRELATED, null, null);
00521     insertMetadataInContainer(metaData,
00522         MetadataDescription.SUPPORTS_OUTER_JOINS, null, null);
00523     insertMetadataInContainer(metaData,
00524         MetadataDescription.SUPPORTS_POSITIONED_DELETE, null, null);
00525     insertMetadataInContainer(metaData,
00526         MetadataDescription.SUPPORTS_POSITIONED_UPDATE, null, null);
00527     insertMetadataInContainer(metaData,
00528         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
00529         new Class[]{Integer.TYPE, Integer.TYPE},
00530         new Object[]{new Integer(ResultSet.TYPE_FORWARD_ONLY),
00531             new Integer(ResultSet.CONCUR_READ_ONLY)});
00532     insertMetadataInContainer(metaData,
00533         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
00534         new Class[]{Integer.TYPE, Integer.TYPE},
00535         new Object[]{new Integer(ResultSet.TYPE_FORWARD_ONLY),
00536             new Integer(ResultSet.CONCUR_UPDATABLE)});
00537     insertMetadataInContainer(metaData,
00538         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
00539         new Class[]{Integer.TYPE, Integer.TYPE},
00540         new Object[]{new Integer(ResultSet.TYPE_SCROLL_INSENSITIVE),
00541             new Integer(ResultSet.CONCUR_READ_ONLY)});
00542     insertMetadataInContainer(metaData,
00543         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
00544         new Class[]{Integer.TYPE, Integer.TYPE},
00545         new Object[]{new Integer(ResultSet.TYPE_SCROLL_INSENSITIVE),
00546             new Integer(ResultSet.CONCUR_UPDATABLE)});
00547     insertMetadataInContainer(metaData,
00548         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
00549         new Class[]{Integer.TYPE, Integer.TYPE},
00550         new Object[]{new Integer(ResultSet.TYPE_SCROLL_SENSITIVE),
00551             new Integer(ResultSet.CONCUR_READ_ONLY)});
00552     insertMetadataInContainer(metaData,
00553         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
00554         new Class[]{Integer.TYPE, Integer.TYPE},
00555         new Object[]{new Integer(ResultSet.TYPE_SCROLL_SENSITIVE),
00556             new Integer(ResultSet.CONCUR_UPDATABLE)});
00557     insertMetadataInContainer(metaData,
00558         MetadataDescription.SUPPORTS_RESULT_SET_HOLDABILITY,
00559         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00560             ResultSet.HOLD_CURSORS_OVER_COMMIT)});
00561     insertMetadataInContainer(metaData,
00562         MetadataDescription.SUPPORTS_RESULT_SET_HOLDABILITY,
00563         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00564             ResultSet.CLOSE_CURSORS_AT_COMMIT)});
00565     insertMetadataInContainer(metaData,
00566         MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
00567         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00568             ResultSet.TYPE_FORWARD_ONLY)});
00569     insertMetadataInContainer(metaData,
00570         MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
00571         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00572             ResultSet.TYPE_SCROLL_INSENSITIVE)});
00573     insertMetadataInContainer(metaData,
00574         MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
00575         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00576             ResultSet.TYPE_SCROLL_SENSITIVE)});
00577     insertMetadataInContainer(metaData,
00578         MetadataDescription.SUPPORTS_SAVEPOINTS, null, null);
00579     insertMetadataInContainer(metaData,
00580         MetadataDescription.SUPPORTS_SCHEMAS_IN_DATA_MANIPULATION, null, null);
00581     insertMetadataInContainer(metaData,
00582         MetadataDescription.SUPPORTS_SCHEMAS_IN_INDEX_DEFINITIONS, null, null);
00583     insertMetadataInContainer(metaData,
00584         MetadataDescription.SUPPORTS_SCHEMAS_IN_PRIVILEGE_DEFINITIONS, null,
00585         null);
00586     insertMetadataInContainer(metaData,
00587         MetadataDescription.SUPPORTS_SCHEMAS_IN_PROCEDURE_CALLS, null, null);
00588     insertMetadataInContainer(metaData,
00589         MetadataDescription.SUPPORTS_SCHEMAS_IN_TABLE_DEFINITIONS, null, null);
00590     insertMetadataInContainer(metaData,
00591         MetadataDescription.SUPPORTS_SELECT_FOR_UPDATE, null, null);
00592     insertMetadataInContainer(metaData,
00593         MetadataDescription.SUPPORTS_STATEMENT_POOLING, null, null);
00594     insertMetadataInContainer(metaData,
00595         MetadataDescription.SUPPORTS_STORED_PROCEDURES, null, null);
00596     insertMetadataInContainer(metaData,
00597         MetadataDescription.SUPPORTS_SUB_QUERIES_IN_COMPARISONS, null, null);
00598     insertMetadataInContainer(metaData,
00599         MetadataDescription.SUPPORTS_SUB_QUERIES_IN_EXISTS, null, null);
00600     insertMetadataInContainer(metaData,
00601         MetadataDescription.SUPPORTS_SUB_QUERIES_IN_INS, null, null);
00602     insertMetadataInContainer(metaData,
00603         MetadataDescription.SUPPORTS_SUB_QUERIES_IN_QUANTIFIEDS, null, null);
00604     insertMetadataInContainer(metaData,
00605         MetadataDescription.SUPPORTS_TABLE_CORRELATION_NAMES, null, null);
00606     insertMetadataInContainer(metaData,
00607         MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL,
00608         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00609             Connection.TRANSACTION_NONE)});
00610     insertMetadataInContainer(metaData,
00611         MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL,
00612         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00613             Connection.TRANSACTION_READ_COMMITTED)});
00614     insertMetadataInContainer(metaData,
00615         MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL,
00616         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00617             Connection.TRANSACTION_READ_UNCOMMITTED)});
00618     insertMetadataInContainer(metaData,
00619         MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL,
00620         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00621             Connection.TRANSACTION_REPEATABLE_READ)});
00622     insertMetadataInContainer(metaData,
00623         MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL,
00624         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00625             Connection.TRANSACTION_SERIALIZABLE)});
00626     insertMetadataInContainer(metaData,
00627         MetadataDescription.SUPPORTS_TRANSACTIONS, null, null);
00628     insertMetadataInContainer(metaData, MetadataDescription.SUPPORTS_UNION,
00629         null, null);
00630     insertMetadataInContainer(metaData, MetadataDescription.SUPPORTS_UNION_ALL,
00631         null, null);
00632     insertMetadataInContainer(metaData,
00633         MetadataDescription.UPDATES_ARE_DETECTED, new Class[]{Integer.TYPE},
00634         new Object[]{new Integer(ResultSet.TYPE_FORWARD_ONLY)});
00635     insertMetadataInContainer(metaData,
00636         MetadataDescription.UPDATES_ARE_DETECTED, new Class[]{Integer.TYPE},
00637         new Object[]{new Integer(ResultSet.TYPE_SCROLL_INSENSITIVE)});
00638     insertMetadataInContainer(metaData,
00639         MetadataDescription.UPDATES_ARE_DETECTED, new Class[]{Integer.TYPE},
00640         new Object[]{new Integer(ResultSet.TYPE_SCROLL_SENSITIVE)});
00641     insertMetadataInContainer(metaData,
00642         MetadataDescription.USES_LOCAL_FILE_PER_TABLE, null, null);
00643     insertMetadataInContainer(metaData, MetadataDescription.USES_LOCAL_FILES,
00644         null, null);
00645     insertMetadataInContainer(metaData,
00646         MetadataDescription.IS_CATALOG_AT_START, null, null);
00647 
00648     overrideCJDBCSpecificFeatures();
00649 
00650     return metadataContainer;
00651   }
00652 
00653   /**
00654    * This method overrides metdata container information with C-JDBC specific
00655    * limitations.
00656    */
00657   private void overrideCJDBCSpecificFeatures()
00658   {
00659     // C-JDBC ResultSets are disconnected therefore they cannot detect deletes,
00660     // inserts or udpates.
00661     updateContainerInformation(MetadataDescription.DELETES_ARE_DETECTED,
00662         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00663             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE);
00664     updateContainerInformation(MetadataDescription.DELETES_ARE_DETECTED,
00665         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00666             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE);
00667     updateContainerInformation(MetadataDescription.INSERTS_ARE_DETECTED,
00668         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00669             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.FALSE);
00670     updateContainerInformation(MetadataDescription.INSERTS_ARE_DETECTED,
00671         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00672             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE);
00673     updateContainerInformation(MetadataDescription.INSERTS_ARE_DETECTED,
00674         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00675             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE);
00676 
00677     // LOBs are directly updated, we do not work on a copy (on the driver side)
00678     updateContainerInformation(MetadataDescription.LOCATORS_UPDATE_COPY, null,
00679         null, Boolean.FALSE);
00680 
00681     // C-JDBC ResultSets are disconnected therefore they cannot detect deletes,
00682     // inserts or udpates.
00683     updateContainerInformation(MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
00684         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00685             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.FALSE);
00686     updateContainerInformation(MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
00687         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00688             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE);
00689     updateContainerInformation(MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
00690         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00691             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE);
00692     updateContainerInformation(MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
00693         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00694             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.FALSE);
00695     updateContainerInformation(MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
00696         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00697             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE);
00698     updateContainerInformation(MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
00699         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00700             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE);
00701     updateContainerInformation(MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
00702         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00703             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.FALSE);
00704     updateContainerInformation(MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
00705         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00706             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE);
00707     updateContainerInformation(MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
00708         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00709             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE);
00710 
00711     // C-JDBC ResultSets are updated when making changes to the database using
00712     // updatable ResultSets
00713     updateContainerInformation(MetadataDescription.OWN_DELETES_ARE_VISIBLE,
00714         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00715             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.TRUE);
00716     updateContainerInformation(MetadataDescription.OWN_DELETES_ARE_VISIBLE,
00717         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00718             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.TRUE);
00719     updateContainerInformation(MetadataDescription.OWN_DELETES_ARE_VISIBLE,
00720         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00721             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.TRUE);
00722     updateContainerInformation(MetadataDescription.OWN_INSERTS_ARE_VISIBLE,
00723         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00724             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.TRUE);
00725     updateContainerInformation(MetadataDescription.OWN_INSERTS_ARE_VISIBLE,
00726         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00727             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.TRUE);
00728     updateContainerInformation(MetadataDescription.OWN_INSERTS_ARE_VISIBLE,
00729         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00730             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.TRUE);
00731     updateContainerInformation(MetadataDescription.OWN_UPDATES_ARE_VISIBLE,
00732         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00733             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.TRUE);
00734     updateContainerInformation(MetadataDescription.OWN_UPDATES_ARE_VISIBLE,
00735         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00736             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.TRUE);
00737     updateContainerInformation(MetadataDescription.OWN_UPDATES_ARE_VISIBLE,
00738         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00739             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.TRUE);
00740 
00741     // We emulate batch updates even if they are not handled optimally yet
00742     updateContainerInformation(MetadataDescription.SUPPORTS_BATCH_UPDATES,
00743         null, null, Boolean.TRUE);
00744 
00745     // It is currently not possible for a CallableStatement to return multiple
00746     // ResultSets
00747     updateContainerInformation(
00748         MetadataDescription.SUPPORTS_MULTIPLE_OPEN_RESULTS, null, null,
00749         Boolean.FALSE);
00750 
00751     // A single call to execute can only return one ResultSet. It this suppose
00752     // to be retrived after an executeBatch?
00753     updateContainerInformation(
00754         MetadataDescription.SUPPORTS_MULTIPLE_RESULTSETS, null, null,
00755         Boolean.FALSE);
00756 
00757     // We support open cursors and statements across commit/rollback. Note this
00758     // only applies for the driver side since everything is closed right away on
00759     // the controller side.
00760     updateContainerInformation(
00761         MetadataDescription.SUPPORTS_OPEN_CURSORS_ACROSS_COMMIT, null, null,
00762         Boolean.TRUE);
00763     updateContainerInformation(
00764         MetadataDescription.SUPPORTS_OPEN_CURSORS_ACROSS_ROLLBACK, null, null,
00765         Boolean.TRUE);
00766     updateContainerInformation(
00767         MetadataDescription.SUPPORTS_OPEN_STATEMENTS_ACROSS_COMMIT, null, null,
00768         Boolean.TRUE);
00769     updateContainerInformation(
00770         MetadataDescription.SUPPORTS_OPEN_STATEMENTS_ACROSS_ROLLBACK, null,
00771         null, Boolean.TRUE);
00772 
00773     // We do not close ResultSets at commit time
00774     updateContainerInformation(
00775         MetadataDescription.SUPPORTS_RESULT_SET_HOLDABILITY,
00776         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00777             ResultSet.HOLD_CURSORS_OVER_COMMIT)}, Boolean.TRUE);
00778     updateContainerInformation(
00779         MetadataDescription.SUPPORTS_RESULT_SET_HOLDABILITY,
00780         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00781             ResultSet.CLOSE_CURSORS_AT_COMMIT)}, Boolean.FALSE);
00782 
00783     // We do support CONCUR_READ_ONLY and CONCUR_UPDATABLE concurrency modes
00784     // for all supported ResultSet types
00785     updateContainerInformation(
00786         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
00787         new Class[]{Integer.TYPE, Integer.TYPE},
00788         new Object[]{new Integer(ResultSet.TYPE_FORWARD_ONLY),
00789             new Integer(ResultSet.CONCUR_READ_ONLY)}, Boolean.TRUE);
00790     updateContainerInformation(
00791         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
00792         new Class[]{Integer.TYPE, Integer.TYPE},
00793         new Object[]{new Integer(ResultSet.TYPE_FORWARD_ONLY),
00794             new Integer(ResultSet.CONCUR_UPDATABLE)}, Boolean.TRUE);
00795     updateContainerInformation(
00796         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
00797         new Class[]{Integer.TYPE, Integer.TYPE},
00798         new Object[]{new Integer(ResultSet.TYPE_SCROLL_INSENSITIVE),
00799             new Integer(ResultSet.CONCUR_READ_ONLY)}, Boolean.TRUE);
00800     updateContainerInformation(
00801         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
00802         new Class[]{Integer.TYPE, Integer.TYPE},
00803         new Object[]{new Integer(ResultSet.TYPE_SCROLL_INSENSITIVE),
00804             new Integer(ResultSet.CONCUR_UPDATABLE)}, Boolean.TRUE);
00805     updateContainerInformation(
00806         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
00807         new Class[]{Integer.TYPE, Integer.TYPE},
00808         new Object[]{new Integer(ResultSet.TYPE_SCROLL_SENSITIVE),
00809             new Integer(ResultSet.CONCUR_READ_ONLY)}, Boolean.FALSE);
00810     updateContainerInformation(
00811         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY,
00812         new Class[]{Integer.TYPE, Integer.TYPE},
00813         new Object[]{new Integer(ResultSet.TYPE_SCROLL_SENSITIVE),
00814             new Integer(ResultSet.CONCUR_UPDATABLE)}, Boolean.FALSE);
00815     
00816     // We do support FORWARD_ONLY and SCROLL_INSENSITIVE ResultSets only
00817     updateContainerInformation(MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
00818         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00819             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.TRUE);
00820     updateContainerInformation(MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
00821         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00822             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.TRUE);
00823     updateContainerInformation(MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
00824         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00825             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE);
00826 
00827     // No support for Savepoints yet
00828     updateContainerInformation(MetadataDescription.SUPPORTS_SAVEPOINTS, null,
00829         null, Boolean.FALSE);
00830 
00831     // Updates are never detected since our ResultSets are disconnected
00832     updateContainerInformation(MetadataDescription.UPDATES_ARE_DETECTED,
00833         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00834             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.FALSE);
00835     updateContainerInformation(MetadataDescription.UPDATES_ARE_DETECTED,
00836         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00837             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE);
00838     updateContainerInformation(MetadataDescription.UPDATES_ARE_DETECTED,
00839         new Class[]{Integer.TYPE}, new Object[]{new Integer(
00840             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE);
00841   }
00842 
00843   /**
00844    * Gets the list of tables of a database and add them to the database schema.
00845    * The caller must ensure that the parameters are not <code>null</code>.
00846    * 
00847    * @exception SQLException if an error occurs
00848    */
00849   public void createDatabaseSchemaDynamically() throws SQLException
00850   {
00851     if (dynamicPrecision == DatabaseBackendSchemaConstants.DynamicPrecisionStatic)
00852       return;
00853     Connection connection = null;
00854     boolean wasInitialized = connectionManager.isInitialized();
00855 
00856     try
00857     {
00858       if (!wasInitialized)
00859         connectionManager.initializeConnections();
00860 
00861       connection = connectionManager.getConnection();
00862       if (connection == null)
00863       {
00864         String msg = Translate.get("backend.meta.connection.failed");
00865         logger.error(msg);
00866         throw new SQLException(msg);
00867       }
00868 
00869       databaseSchema = new DatabaseSQLMetaData(logger, connection,
00870           dynamicPrecision, gatherSystemTables, schemaName)
00871           .createDatabaseSchema();
00872 
00873     }
00874     catch (Exception e)
00875     {
00876       if (e instanceof RuntimeException)
00877         logger.error(Translate.get("backend.meta.runtime.error"), e);
00878       throw new SQLException(Translate.get("backend.meta.failed.get.info", e));
00879     }
00880     finally
00881     {
00882       if (connection != null)
00883         connectionManager.releaseConnection(connection);
00884 
00885       if (!wasInitialized)
00886         connectionManager.finalizeConnections();
00887 
00888     }
00889   }
00890 
00891   /**
00892    * Returns the database schema. Returns <code>null</code> If an error has
00893    * occured during the schema generation.
00894    * <p>
00895    * If the schema has not been previously computed,
00896    * {@link #createDatabaseSchemaDynamically()}is called.
00897    * 
00898    * @return a <code>DatabaseSchema</code> value
00899    * @exception SQLException if a problem occurs when creating the database
00900    *              schema
00901    * @see #createDatabaseSchemaDynamically
00902    */
00903   public DatabaseSchema getDatabaseSchema() throws SQLException
00904   {
00905     if (databaseSchema == null)
00906       createDatabaseSchemaDynamically();
00907     return databaseSchema;
00908   }
00909 }

Generated on Mon Apr 11 22:01:31 2005 for C-JDBC by  doxygen 1.3.9.1