KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > controller > backend > DatabaseBackendMetaData


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2005 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Julie Marguerite.
22  * Contributor(s): Emmanuel Cecchet, Nicolas Modrzyk, Mathieu Peltier, Jean-Bernard van Zuylen.
23  */

24
25 package org.objectweb.cjdbc.controller.backend;
26
27 import java.lang.reflect.InvocationTargetException JavaDoc;
28 import java.lang.reflect.Method JavaDoc;
29 import java.sql.Connection JavaDoc;
30 import java.sql.DatabaseMetaData JavaDoc;
31 import java.sql.ResultSet JavaDoc;
32 import java.sql.SQLException JavaDoc;
33
34 import org.objectweb.cjdbc.common.i18n.Translate;
35 import org.objectweb.cjdbc.common.log.Trace;
36 import org.objectweb.cjdbc.common.sql.metadata.MetadataContainer;
37 import org.objectweb.cjdbc.common.sql.metadata.MetadataDescription;
38 import org.objectweb.cjdbc.common.sql.schema.DatabaseSQLMetaData;
39 import org.objectweb.cjdbc.common.sql.schema.DatabaseSchema;
40 import org.objectweb.cjdbc.controller.connection.AbstractConnectionManager;
41
42 /**
43  * A <code>DatabaseBackendMetaData</code> is used to retrieve the database
44  * schema of a real database backend that will have to be bound to a virtual
45  * C-JDBC database.
46  *
47  * @author <a HREF="mailto:Julie.Marguerite@inria.fr">Julie Marguerite </a>
48  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
49  * @author <a HREF="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
50  * @author <a HREF="mailto:Mathieu.Peltier@inrialpes.fr">Mathieu Peltier </a>
51  * @author <a HREF="mailto:jbvanzuylen@transwide.com">Jean-Bernard van Zuylen
52  * </a>
53  * @version 1.0
54  */

55 public final class DatabaseBackendMetaData
56 {
57   /** Connection manager to get a connection from. */
58   private AbstractConnectionManager connectionManager;
59
60   /** Logger instance. */
61   private Trace logger;
62
63   /** Schema of the database backend. */
64   private DatabaseSchema databaseSchema;
65
66   /** The precision of the dynamically generated schema */
67   private int dynamicPrecision;
68
69   /** Should the system tables be gathered or not */
70   private boolean gatherSystemTables = false;
71
72   /** The name of the schema used to gather meta data */
73   private String JavaDoc schemaName = null;
74
75   /** Container for static metadata */
76   private MetadataContainer metadataContainer = null;
77
78   /**
79    * Creates a new <code>DatabaseBackendMetaData</code> instance. This class
80    * takes care of initializing the connection manager if needed but the driver
81    * must have been previously loaded else the connection manager's
82    * initialization will fail.
83    *
84    * @param connectionManager the connection manager to gather the schema from
85    * @param logger the logger (usually the backend logger) to use
86    * @param dynamicPrecision the precision with which we gather a schema
87    * directly from the backend
88    * @param gatherSystemTables true if system tables must be gathered
89    * @param schemaName schema name to use to retrieve information
90    */

91   public DatabaseBackendMetaData(AbstractConnectionManager connectionManager,
92       Trace logger, int dynamicPrecision, boolean gatherSystemTables,
93       String JavaDoc schemaName)
94   {
95     this.connectionManager = connectionManager;
96     this.dynamicPrecision = dynamicPrecision;
97     this.logger = logger;
98     this.gatherSystemTables = gatherSystemTables;
99     this.schemaName = schemaName;
100   }
101
102   /**
103    * This method invokes by reflection the appropriate metadata method and fills
104    * the container with the result.
105    *
106    * @param metaData metadata to invoke
107    * @param methodName method to invoke
108    * @param parametersType parameters type of method to invoke
109    * @param arguments arguments to invoke the method
110    */

111   private void insertMetadataInContainer(DatabaseMetaData JavaDoc metaData,
112       String JavaDoc methodName, Class JavaDoc[] parametersType, Object JavaDoc[] arguments)
113   {
114     Class JavaDoc metadataClass = metaData.getClass();
115     try
116     {
117       Method JavaDoc method = metadataClass.getMethod(methodName, parametersType);
118       Object JavaDoc result = method.invoke(metaData, arguments);
119       updateContainerInformation(methodName, parametersType, arguments, result);
120     }
121     catch (SecurityException JavaDoc e)
122     {
123       if (logger.isDebugEnabled())
124         logger.debug("Problem calling " + methodName, e);
125       else
126         logger.warn("Unable to get information for " + methodName);
127     }
128     catch (IllegalArgumentException JavaDoc e)
129     {
130       if (logger.isDebugEnabled())
131         logger.debug("Problem calling " + methodName, e);
132       else
133         logger.warn("Unable to get information for " + methodName);
134     }
135     catch (NoSuchMethodException JavaDoc e)
136     {
137       if (logger.isDebugEnabled())
138         logger.debug("Metadata " + methodName
139             + " does not exists. Probably not supported by your JDK.");
140     }
141     catch (IllegalAccessException JavaDoc e)
142     {
143       if (logger.isDebugEnabled())
144         logger.debug("Problem calling " + methodName, e);
145       else
146         logger.warn("Unable to get information for " + methodName);
147     }
148     catch (InvocationTargetException JavaDoc e)
149     {
150       if (logger.isDebugEnabled())
151         logger.debug("Problem calling " + methodName, e);
152       else
153         logger.warn("Unable to get information for " + methodName);
154     }
155     catch (AbstractMethodError JavaDoc e)
156     {
157       // user Wolfgang Koppenberger reported problems with code compiled with
158
// java 1.3, it throws AbstractMethodError instead of
159
// NoSuchMethodException
160
if (logger.isDebugEnabled())
161         logger.debug("Metadata " + methodName
162             + " does not exists. Probably not supported by your jdbc-driver.");
163     }
164   }
165
166   /**
167    * Update the metadata container information for the given method.
168    *
169    * @param methodName method invoked to generate the key in the container
170    * @param parametersType parameters type of invoked method
171    * @param arguments arguments used to invoke the method
172    * @param result result of the method call
173    */

174   private void updateContainerInformation(String JavaDoc methodName,
175       Class JavaDoc[] parametersType, Object JavaDoc[] arguments, Object JavaDoc result)
176   {
177     String JavaDoc key = MetadataContainer.getContainerKey(methodName, parametersType,
178         arguments);
179     metadataContainer.put(key, result);
180     if (logger.isDebugEnabled())
181       logger.debug("Updating metadata " + key + "=" + result);
182   }
183
184   /**
185    * Retrieve metadata from a connection on this backend and build the
186    * ("getDataXXX(Y,Z,...)", value) hash table. Note that some values are
187    * overriden with C-JDBC specific features (add-ons or limitations).
188    *
189    * @return a metadata container including all metadata values
190    * @throws SQLException if an error occurs
191    */

192   public MetadataContainer retrieveDatabaseMetadata() throws SQLException JavaDoc
193   {
194     if (metadataContainer != null)
195       return metadataContainer;
196
197     // Retrieve metadata
198
Connection JavaDoc connection = null;
199     boolean wasInitialized = connectionManager.isInitialized();
200
201     DatabaseMetaData JavaDoc metaData;
202     try
203     {
204       if (!wasInitialized)
205         connectionManager.initializeConnections();
206
207       connection = connectionManager.getConnection();
208       if (connection == null)
209       {
210         String JavaDoc msg = Translate.get("backend.meta.connection.failed");
211         logger.error(msg);
212         throw new SQLException JavaDoc(msg);
213       }
214
215       metaData = connection.getMetaData();
216       metadataContainer = new MetadataContainer(connection.getMetaData()
217           .getURL());
218
219       // TODO: Move this to a separate command
220
// Boolean.valueOf(metaData.supportsConvert(int,int)
221

222       // Metadata in alphabetical order.
223
// These calls do not seem to throw anything, but require a valid
224
// connection (which is closed in the finally block).
225
insertMetadataInContainer(metaData,
226           MetadataDescription.ALL_PROCEDURES_ARE_CALLABLE, null, null);
227       insertMetadataInContainer(metaData,
228           MetadataDescription.ALL_TABLES_ARE_SELECTABLE, null, null);
229       insertMetadataInContainer(metaData,
230           MetadataDescription.DATA_DEFINITION_CAUSES_TRANSACTION_COMMIT, null,
231           null);
232       insertMetadataInContainer(metaData,
233           MetadataDescription.DATA_DEFINITION_IGNORED_IN_TRANSACTIONS, null,
234           null);
235       insertMetadataInContainer(metaData,
236           MetadataDescription.DELETES_ARE_DETECTED, new Class JavaDoc[]{Integer.TYPE},
237           new Object JavaDoc[]{new Integer JavaDoc(ResultSet.TYPE_FORWARD_ONLY)});
238       insertMetadataInContainer(metaData,
239           MetadataDescription.DELETES_ARE_DETECTED, new Class JavaDoc[]{Integer.TYPE},
240           new Object JavaDoc[]{new Integer JavaDoc(ResultSet.TYPE_SCROLL_INSENSITIVE)});
241       insertMetadataInContainer(metaData,
242           MetadataDescription.DELETES_ARE_DETECTED, new Class JavaDoc[]{Integer.TYPE},
243           new Object JavaDoc[]{new Integer JavaDoc(ResultSet.TYPE_SCROLL_SENSITIVE)});
244       insertMetadataInContainer(metaData,
245           MetadataDescription.DOES_MAX_ROW_SIZE_INCLUDE_BLOBS, null, null);
246       insertMetadataInContainer(metaData,
247           MetadataDescription.GET_DEFAULT_TRANSACTION_ISOLATION, null, null);
248       insertMetadataInContainer(metaData,
249           MetadataDescription.GET_DATABASE_MAJOR_VERSION, null, null);
250       insertMetadataInContainer(metaData,
251           MetadataDescription.GET_DATABASE_MINOR_VERSION, null, null);
252       insertMetadataInContainer(metaData,
253           MetadataDescription.GET_DRIVER_MAJOR_VERSION, null, null);
254       insertMetadataInContainer(metaData,
255           MetadataDescription.GET_DRIVER_MINOR_VERSION, null, null);
256       insertMetadataInContainer(metaData,
257           MetadataDescription.GET_JDBC_MAJOR_VERSION, null, null);
258       insertMetadataInContainer(metaData,
259           MetadataDescription.GET_JDBC_MINOR_VERSION, null, null);
260       insertMetadataInContainer(metaData,
261           MetadataDescription.GET_MAX_BINARY_LITERAL_LENGTH, null, null);
262       insertMetadataInContainer(metaData,
263           MetadataDescription.GET_RESULTSET_HOLDABILITY, null, null);
264       insertMetadataInContainer(metaData,
265           MetadataDescription.GET_SQL_STATE_TYPE, null, null);
266       insertMetadataInContainer(metaData,
267           MetadataDescription.GET_MAX_CATALOG_NAME_LENGTH, null, null);
268       insertMetadataInContainer(metaData,
269           MetadataDescription.GET_MAX_CHAR_LITERAL_LENGTH, null, null);
270       insertMetadataInContainer(metaData,
271           MetadataDescription.GET_MAX_COLUMN_NAME_LENGTH, null, null);
272       insertMetadataInContainer(metaData,
273           MetadataDescription.GET_MAX_COLUMNS_IN_GROUP_BY, null, null);
274       insertMetadataInContainer(metaData,
275           MetadataDescription.GET_MAX_COLUMNS_IN_INDEX, null, null);
276       insertMetadataInContainer(metaData,
277           MetadataDescription.GET_MAX_COLUMNS_IN_ORDER_BY, null, null);
278       insertMetadataInContainer(metaData,
279           MetadataDescription.GET_MAX_COLUMNS_IN_SELECT, null, null);
280       insertMetadataInContainer(metaData,
281           MetadataDescription.GET_MAX_COLUMNS_IN_TABLE, null, null);
282       insertMetadataInContainer(metaData,
283           MetadataDescription.GET_MAX_CONNECTIONS, null, null);
284       insertMetadataInContainer(metaData,
285           MetadataDescription.GET_MAX_CURSOR_NAME_LENGTH, null, null);
286       insertMetadataInContainer(metaData,
287           MetadataDescription.GET_MAX_INDEX_LENGTH, null, null);
288       insertMetadataInContainer(metaData,
289           MetadataDescription.GET_MAX_PROCEDURE_NAME_LENGTH, null, null);
290       insertMetadataInContainer(metaData, MetadataDescription.GET_MAX_ROW_SIZE,
291           null, null);
292       insertMetadataInContainer(metaData,
293           MetadataDescription.GET_MAX_SCHEMA_NAME_LENGTH, null, null);
294       insertMetadataInContainer(metaData,
295           MetadataDescription.GET_MAX_STATEMENT_LENGTH, null, null);
296       insertMetadataInContainer(metaData,
297           MetadataDescription.GET_MAX_STATEMENTS, null, null);
298       insertMetadataInContainer(metaData,
299           MetadataDescription.GET_MAX_TABLE_NAME_LENGTH, null, null);
300       insertMetadataInContainer(metaData,
301           MetadataDescription.GET_MAX_TABLES_IN_SELECT, null, null);
302       insertMetadataInContainer(metaData,
303           MetadataDescription.GET_MAX_USER_NAME_LENGTH, null, null);
304       // strings
305
insertMetadataInContainer(metaData,
306           MetadataDescription.GET_CATALOG_SEPARATOR, null, null);
307       insertMetadataInContainer(metaData, MetadataDescription.GET_CATALOG_TERM,
308           null, null);
309       insertMetadataInContainer(metaData,
310           MetadataDescription.GET_DATABASE_PRODUCT_NAME, null, null);
311       insertMetadataInContainer(metaData, MetadataDescription.GET_DRIVER_NAME,
312           null, null);
313       insertMetadataInContainer(metaData,
314           MetadataDescription.GET_DRIVER_VERSION, null, null);
315       insertMetadataInContainer(metaData,
316           MetadataDescription.GET_EXTRA_NAME_CHARACTERS, null, null);
317       insertMetadataInContainer(metaData,
318           MetadataDescription.GET_IDENTIFIER_QUOTE_STRING, null, null);
319       insertMetadataInContainer(metaData,
320           MetadataDescription.GET_NUMERIC_FUNCTIONS, null, null);
321       insertMetadataInContainer(metaData,
322           MetadataDescription.GET_PROCEDURE_TERM, null, null);
323       insertMetadataInContainer(metaData, MetadataDescription.GET_SCHEMA_TERM,
324           null, null);
325       insertMetadataInContainer(metaData,
326           MetadataDescription.GET_SEARCH_STRING_ESCAPE, null, null);
327       insertMetadataInContainer(metaData, MetadataDescription.GET_SQL_KEYWORDS,
328           null, null);
329       insertMetadataInContainer(metaData,
330           MetadataDescription.GET_STRING_FUNCTIONS, null, null);
331       insertMetadataInContainer(metaData,
332           MetadataDescription.GET_SYSTEM_FUNCTIONS, null, null);
333       insertMetadataInContainer(metaData,
334           MetadataDescription.GET_TIME_DATE_FUNCTIONS, null, null);
335       insertMetadataInContainer(metaData,
336           MetadataDescription.INSERTS_ARE_DETECTED, new Class JavaDoc[]{Integer.TYPE},
337           new Object JavaDoc[]{new Integer JavaDoc(ResultSet.TYPE_FORWARD_ONLY)});
338       insertMetadataInContainer(metaData,
339           MetadataDescription.INSERTS_ARE_DETECTED, new Class JavaDoc[]{Integer.TYPE},
340           new Object JavaDoc[]{new Integer JavaDoc(ResultSet.TYPE_SCROLL_INSENSITIVE)});
341       insertMetadataInContainer(metaData,
342           MetadataDescription.INSERTS_ARE_DETECTED, new Class JavaDoc[]{Integer.TYPE},
343           new Object JavaDoc[]{new Integer JavaDoc(ResultSet.TYPE_SCROLL_SENSITIVE)});
344       insertMetadataInContainer(metaData,
345           MetadataDescription.LOCATORS_UPDATE_COPY, null, null);
346       insertMetadataInContainer(metaData,
347           MetadataDescription.NULL_PLUS_NON_NULL_IS_NULL, null, null);
348       insertMetadataInContainer(metaData,
349           MetadataDescription.NULLS_ARE_SORTED_AT_END, null, null);
350       insertMetadataInContainer(metaData,
351           MetadataDescription.NULLS_ARE_SORTED_AT_START, null, null);
352       insertMetadataInContainer(metaData,
353           MetadataDescription.NULLS_ARE_SORTED_HIGH, null, null);
354       insertMetadataInContainer(metaData,
355           MetadataDescription.NULLS_ARE_SORTED_LOW, null, null);
356       insertMetadataInContainer(metaData,
357           MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
358           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
359               ResultSet.TYPE_FORWARD_ONLY)});
360       insertMetadataInContainer(metaData,
361           MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
362           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
363               ResultSet.TYPE_SCROLL_INSENSITIVE)});
364       insertMetadataInContainer(metaData,
365           MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
366           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
367               ResultSet.TYPE_SCROLL_SENSITIVE)});
368       insertMetadataInContainer(metaData,
369           MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
370           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
371               ResultSet.TYPE_FORWARD_ONLY)});
372       insertMetadataInContainer(metaData,
373           MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
374           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
375               ResultSet.TYPE_SCROLL_INSENSITIVE)});
376       insertMetadataInContainer(metaData,
377           MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
378           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
379               ResultSet.TYPE_SCROLL_SENSITIVE)});
380       insertMetadataInContainer(metaData,
381           MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
382           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
383               ResultSet.TYPE_FORWARD_ONLY)});
384       insertMetadataInContainer(metaData,
385           MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
386           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
387               ResultSet.TYPE_SCROLL_INSENSITIVE)});
388       insertMetadataInContainer(metaData,
389           MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
390           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
391               ResultSet.TYPE_SCROLL_SENSITIVE)});
392       insertMetadataInContainer(metaData,
393           MetadataDescription.OWN_DELETES_ARE_VISIBLE,
394           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
395               ResultSet.TYPE_FORWARD_ONLY)});
396       insertMetadataInContainer(metaData,
397           MetadataDescription.OWN_DELETES_ARE_VISIBLE,
398           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
399               ResultSet.TYPE_SCROLL_INSENSITIVE)});
400       insertMetadataInContainer(metaData,
401           MetadataDescription.OWN_DELETES_ARE_VISIBLE,
402           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
403               ResultSet.TYPE_SCROLL_SENSITIVE)});
404       insertMetadataInContainer(metaData,
405           MetadataDescription.OWN_INSERTS_ARE_VISIBLE,
406           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
407               ResultSet.TYPE_FORWARD_ONLY)});
408       insertMetadataInContainer(metaData,
409           MetadataDescription.OWN_INSERTS_ARE_VISIBLE,
410           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
411               ResultSet.TYPE_SCROLL_INSENSITIVE)});
412       insertMetadataInContainer(metaData,
413           MetadataDescription.OWN_INSERTS_ARE_VISIBLE,
414           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
415               ResultSet.TYPE_SCROLL_SENSITIVE)});
416       insertMetadataInContainer(metaData,
417           MetadataDescription.OWN_UPDATES_ARE_VISIBLE,
418           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
419               ResultSet.TYPE_FORWARD_ONLY)});
420       insertMetadataInContainer(metaData,
421           MetadataDescription.OWN_UPDATES_ARE_VISIBLE,
422           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
423               ResultSet.TYPE_SCROLL_INSENSITIVE)});
424       insertMetadataInContainer(metaData,
425           MetadataDescription.OWN_UPDATES_ARE_VISIBLE,
426           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
427               ResultSet.TYPE_SCROLL_SENSITIVE)});
428       insertMetadataInContainer(metaData,
429           MetadataDescription.STORES_LOWER_CASE_IDENTIFIERS, null, null);
430       insertMetadataInContainer(metaData,
431           MetadataDescription.STORES_LOWER_CASE_QUOTED_IDENTIFIERS, null, null);
432       insertMetadataInContainer(metaData,
433           MetadataDescription.STORES_MIXED_CASE_IDENTIFIERS, null, null);
434       insertMetadataInContainer(metaData,
435           MetadataDescription.STORES_MIXED_CASE_QUOTED_IDENTIFIERS, null, null);
436       insertMetadataInContainer(metaData,
437           MetadataDescription.STORES_UPPER_CASE_IDENTIFIERS, null, null);
438       insertMetadataInContainer(metaData,
439           MetadataDescription.STORES_UPPER_CASE_QUOTED_IDENTIFIERS, null, null);
440       insertMetadataInContainer(metaData,
441           MetadataDescription.SUPPORTS_ALTER_TABLE_WITH_ADD_COLUMN, null, null);
442       insertMetadataInContainer(metaData,
443           MetadataDescription.SUPPORTS_ALTER_TABLE_WITH_DROP_COLUMN, null, null);
444       insertMetadataInContainer(metaData,
445           MetadataDescription.SUPPORTS_ANSI92_ENTRY_LEVEL_SQL, null, null);
446       insertMetadataInContainer(metaData,
447           MetadataDescription.SUPPORTS_ANSI92_FULL_SQL, null, null);
448       insertMetadataInContainer(metaData,
449           MetadataDescription.SUPPORTS_ANSI92_INTERMEDIATE_SQL, null, null);
450       insertMetadataInContainer(metaData,
451           MetadataDescription.SUPPORTS_BATCH_UPDATES, null, null);
452       insertMetadataInContainer(metaData,
453           MetadataDescription.SUPPORTS_CATALOGS_IN_DATA_MANIPULATION, null,
454           null);
455       insertMetadataInContainer(metaData,
456           MetadataDescription.SUPPORTS_CATALOGS_IN_INDEX_DEFINITIONS, null,
457           null);
458       insertMetadataInContainer(metaData,
459           MetadataDescription.SUPPORTS_CATALOGS_IN_PRIVILEGE_DEFINITIONS, null,
460           null);
461       insertMetadataInContainer(metaData,
462           MetadataDescription.SUPPORTS_CATALOGS_IN_PROCEDURE_CALLS, null, null);
463       insertMetadataInContainer(metaData,
464           MetadataDescription.SUPPORTS_CATALOGS_IN_TABLE_DEFINITIONS, null,
465           null);
466       insertMetadataInContainer(metaData,
467           MetadataDescription.SUPPORTS_COLUMN_ALIASING, null, null);
468       insertMetadataInContainer(metaData, MetadataDescription.SUPPORTS_CONVERT,
469           null, null);
470       insertMetadataInContainer(metaData,
471           MetadataDescription.SUPPORTS_CORE_SQL_GRAMMAR, null, null);
472       insertMetadataInContainer(metaData,
473           MetadataDescription.SUPPORTS_CORRELATED_SUBQUERIES, null, null);
474       insertMetadataInContainer(
475           metaData,
476           MetadataDescription.SUPPORTS_DATA_DEFINITION_AND_DATA_MANIPULATION_TRANSACTIONS,
477           null, null);
478       insertMetadataInContainer(metaData,
479           MetadataDescription.SUPPORTS_DATA_MANIPULATION_TRANSACTIONS_ONLY,
480           null, null);
481       insertMetadataInContainer(metaData,
482           MetadataDescription.SUPPORTS_DIFFERENT_TABLE_CORRELATION_NAMES, null,
483           null);
484       insertMetadataInContainer(metaData,
485           MetadataDescription.SUPPORTS_EXPRESSIONS_IN_ORDER_BY, null, null);
486       insertMetadataInContainer(metaData,
487           MetadataDescription.SUPPORTS_EXTENDED_SQL_GRAMMAR, null, null);
488       insertMetadataInContainer(metaData,
489           MetadataDescription.SUPPORTS_FULL_OUTER_JOINS, null, null);
490       insertMetadataInContainer(metaData,
491           MetadataDescription.SUPPORTS_GET_GENERATED_KEYS, null, null);
492       insertMetadataInContainer(metaData,
493           MetadataDescription.SUPPORTS_GROUP_BY, null, null);
494       insertMetadataInContainer(metaData,
495           MetadataDescription.SUPPORTS_GROUP_BY_BEYOND_SELECT, null, null);
496       insertMetadataInContainer(metaData,
497           MetadataDescription.SUPPORTS_GROUP_BY_UNRELATED, null, null);
498       insertMetadataInContainer(metaData,
499           MetadataDescription.SUPPORTS_INTEGRITY_ENHANCEMENT_FACILITY, null,
500           null);
501       insertMetadataInContainer(metaData,
502           MetadataDescription.SUPPORTS_LIKE_ESCAPE_CLAUSE, null, null);
503       insertMetadataInContainer(metaData,
504           MetadataDescription.SUPPORTS_LIMITED_OUTER_JOINS, null, null);
505       insertMetadataInContainer(metaData,
506           MetadataDescription.SUPPORTS_MINIMUM_SQL_GRAMMAR, null, null);
507       insertMetadataInContainer(metaData,
508           MetadataDescription.SUPPORTS_MIXED_CASE_IDENTIFIERS, null, null);
509       insertMetadataInContainer(metaData,
510           MetadataDescription.SUPPORTS_MIXED_CASE_QUOTED_IDENTIFIERS, null,
511           null);
512       insertMetadataInContainer(metaData,
513           MetadataDescription.SUPPORTS_MULTIPLE_OPEN_RESULTS, null, null);
514       insertMetadataInContainer(metaData,
515           MetadataDescription.SUPPORTS_MULTIPLE_RESULTSETS, null, null);
516       insertMetadataInContainer(metaData,
517           MetadataDescription.SUPPORTS_MULTIPLE_TRANSACTIONS, null, null);
518       insertMetadataInContainer(metaData,
519           MetadataDescription.SUPPORTS_NAMED_PARAMETERS, null, null);
520       insertMetadataInContainer(metaData,
521           MetadataDescription.SUPPORTS_NON_NULLABLE_COLUMNS, null, null);
522       insertMetadataInContainer(metaData,
523           MetadataDescription.SUPPORTS_OPEN_CURSORS_ACROSS_COMMIT, null, null);
524       insertMetadataInContainer(metaData,
525           MetadataDescription.SUPPORTS_OPEN_CURSORS_ACROSS_ROLLBACK, null, null);
526       insertMetadataInContainer(metaData,
527           MetadataDescription.SUPPORTS_OPEN_STATEMENTS_ACROSS_COMMIT, null,
528           null);
529       insertMetadataInContainer(metaData,
530           MetadataDescription.SUPPORTS_OPEN_STATEMENTS_ACROSS_ROLLBACK, null,
531           null);
532       insertMetadataInContainer(metaData,
533           MetadataDescription.SUPPORTS_ORDER_BY_UNRELATED, null, null);
534       insertMetadataInContainer(metaData,
535           MetadataDescription.SUPPORTS_OUTER_JOINS, null, null);
536       insertMetadataInContainer(metaData,
537           MetadataDescription.SUPPORTS_POSITIONED_DELETE, null, null);
538       insertMetadataInContainer(metaData,
539           MetadataDescription.SUPPORTS_POSITIONED_UPDATE, null, null);
540       insertMetadataInContainer(metaData,
541           MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class JavaDoc[]{
542               Integer.TYPE, Integer.TYPE}, new Object JavaDoc[]{
543               new Integer JavaDoc(ResultSet.TYPE_FORWARD_ONLY),
544               new Integer JavaDoc(ResultSet.CONCUR_READ_ONLY)});
545       insertMetadataInContainer(metaData,
546           MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class JavaDoc[]{
547               Integer.TYPE, Integer.TYPE}, new Object JavaDoc[]{
548               new Integer JavaDoc(ResultSet.TYPE_FORWARD_ONLY),
549               new Integer JavaDoc(ResultSet.CONCUR_UPDATABLE)});
550       insertMetadataInContainer(metaData,
551           MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class JavaDoc[]{
552               Integer.TYPE, Integer.TYPE}, new Object JavaDoc[]{
553               new Integer JavaDoc(ResultSet.TYPE_SCROLL_INSENSITIVE),
554               new Integer JavaDoc(ResultSet.CONCUR_READ_ONLY)});
555       insertMetadataInContainer(metaData,
556           MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class JavaDoc[]{
557               Integer.TYPE, Integer.TYPE}, new Object JavaDoc[]{
558               new Integer JavaDoc(ResultSet.TYPE_SCROLL_INSENSITIVE),
559               new Integer JavaDoc(ResultSet.CONCUR_UPDATABLE)});
560       insertMetadataInContainer(metaData,
561           MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class JavaDoc[]{
562               Integer.TYPE, Integer.TYPE}, new Object JavaDoc[]{
563               new Integer JavaDoc(ResultSet.TYPE_SCROLL_SENSITIVE),
564               new Integer JavaDoc(ResultSet.CONCUR_READ_ONLY)});
565       insertMetadataInContainer(metaData,
566           MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class JavaDoc[]{
567               Integer.TYPE, Integer.TYPE}, new Object JavaDoc[]{
568               new Integer JavaDoc(ResultSet.TYPE_SCROLL_SENSITIVE),
569               new Integer JavaDoc(ResultSet.CONCUR_UPDATABLE)});
570       insertMetadataInContainer(metaData,
571           MetadataDescription.SUPPORTS_RESULT_SET_HOLDABILITY,
572           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
573               ResultSet.HOLD_CURSORS_OVER_COMMIT)});
574       insertMetadataInContainer(metaData,
575           MetadataDescription.SUPPORTS_RESULT_SET_HOLDABILITY,
576           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
577               ResultSet.CLOSE_CURSORS_AT_COMMIT)});
578       insertMetadataInContainer(metaData,
579           MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
580           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
581               ResultSet.TYPE_FORWARD_ONLY)});
582       insertMetadataInContainer(metaData,
583           MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
584           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
585               ResultSet.TYPE_SCROLL_INSENSITIVE)});
586       insertMetadataInContainer(metaData,
587           MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
588           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
589               ResultSet.TYPE_SCROLL_SENSITIVE)});
590       insertMetadataInContainer(metaData,
591           MetadataDescription.SUPPORTS_SAVEPOINTS, null, null);
592       insertMetadataInContainer(metaData,
593           MetadataDescription.SUPPORTS_SCHEMAS_IN_DATA_MANIPULATION, null, null);
594       insertMetadataInContainer(metaData,
595           MetadataDescription.SUPPORTS_SCHEMAS_IN_INDEX_DEFINITIONS, null, null);
596       insertMetadataInContainer(metaData,
597           MetadataDescription.SUPPORTS_SCHEMAS_IN_PRIVILEGE_DEFINITIONS, null,
598           null);
599       insertMetadataInContainer(metaData,
600           MetadataDescription.SUPPORTS_SCHEMAS_IN_PROCEDURE_CALLS, null, null);
601       insertMetadataInContainer(metaData,
602           MetadataDescription.SUPPORTS_SCHEMAS_IN_TABLE_DEFINITIONS, null, null);
603       insertMetadataInContainer(metaData,
604           MetadataDescription.SUPPORTS_SELECT_FOR_UPDATE, null, null);
605       insertMetadataInContainer(metaData,
606           MetadataDescription.SUPPORTS_STATEMENT_POOLING, null, null);
607       insertMetadataInContainer(metaData,
608           MetadataDescription.SUPPORTS_STORED_PROCEDURES, null, null);
609       insertMetadataInContainer(metaData,
610           MetadataDescription.SUPPORTS_SUB_QUERIES_IN_COMPARISONS, null, null);
611       insertMetadataInContainer(metaData,
612           MetadataDescription.SUPPORTS_SUB_QUERIES_IN_EXISTS, null, null);
613       insertMetadataInContainer(metaData,
614           MetadataDescription.SUPPORTS_SUB_QUERIES_IN_INS, null, null);
615       insertMetadataInContainer(metaData,
616           MetadataDescription.SUPPORTS_SUB_QUERIES_IN_QUANTIFIEDS, null, null);
617       insertMetadataInContainer(metaData,
618           MetadataDescription.SUPPORTS_TABLE_CORRELATION_NAMES, null, null);
619       insertMetadataInContainer(metaData,
620           MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL,
621           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
622               Connection.TRANSACTION_NONE)});
623       insertMetadataInContainer(metaData,
624           MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL,
625           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
626               Connection.TRANSACTION_READ_COMMITTED)});
627       insertMetadataInContainer(metaData,
628           MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL,
629           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
630               Connection.TRANSACTION_READ_UNCOMMITTED)});
631       insertMetadataInContainer(metaData,
632           MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL,
633           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
634               Connection.TRANSACTION_REPEATABLE_READ)});
635       insertMetadataInContainer(metaData,
636           MetadataDescription.SUPPORTS_TRANSACTION_ISOLATION_LEVEL,
637           new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
638               Connection.TRANSACTION_SERIALIZABLE)});
639       insertMetadataInContainer(metaData,
640           MetadataDescription.SUPPORTS_TRANSACTIONS, null, null);
641       insertMetadataInContainer(metaData, MetadataDescription.SUPPORTS_UNION,
642           null, null);
643       insertMetadataInContainer(metaData,
644           MetadataDescription.SUPPORTS_UNION_ALL, null, null);
645       insertMetadataInContainer(metaData,
646           MetadataDescription.UPDATES_ARE_DETECTED, new Class JavaDoc[]{Integer.TYPE},
647           new Object JavaDoc[]{new Integer JavaDoc(ResultSet.TYPE_FORWARD_ONLY)});
648       insertMetadataInContainer(metaData,
649           MetadataDescription.UPDATES_ARE_DETECTED, new Class JavaDoc[]{Integer.TYPE},
650           new Object JavaDoc[]{new Integer JavaDoc(ResultSet.TYPE_SCROLL_INSENSITIVE)});
651       insertMetadataInContainer(metaData,
652           MetadataDescription.UPDATES_ARE_DETECTED, new Class JavaDoc[]{Integer.TYPE},
653           new Object JavaDoc[]{new Integer JavaDoc(ResultSet.TYPE_SCROLL_SENSITIVE)});
654       insertMetadataInContainer(metaData,
655           MetadataDescription.USES_LOCAL_FILE_PER_TABLE, null, null);
656       insertMetadataInContainer(metaData, MetadataDescription.USES_LOCAL_FILES,
657           null, null);
658       insertMetadataInContainer(metaData,
659           MetadataDescription.IS_CATALOG_AT_START, null, null);
660
661       overrideCJDBCSpecificFeatures();
662     }
663     catch (Exception JavaDoc e)
664     {
665       if (e instanceof RuntimeException JavaDoc)
666         logger.error(Translate.get("backend.meta.runtime.error"), e);
667       throw new SQLException JavaDoc(Translate.get("backend.meta.failed.get.info", e));
668     }
669
670     finally
671     {
672       // IGOR's fix: do that after we are finished with all DB accesses
673
if (connection != null)
674         connectionManager.releaseConnection(connection);
675
676       if (!wasInitialized)
677         connectionManager.finalizeConnections();
678     }
679     return metadataContainer;
680   }
681
682   /**
683    * This method overrides metdata container information with C-JDBC specific
684    * limitations.
685    */

686   private void overrideCJDBCSpecificFeatures()
687   {
688     // C-JDBC ResultSets are disconnected therefore they cannot detect deletes,
689
// inserts or udpates.
690
updateContainerInformation(MetadataDescription.DELETES_ARE_DETECTED,
691         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
692             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE);
693     updateContainerInformation(MetadataDescription.DELETES_ARE_DETECTED,
694         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
695             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE);
696     updateContainerInformation(MetadataDescription.INSERTS_ARE_DETECTED,
697         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
698             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.FALSE);
699     updateContainerInformation(MetadataDescription.INSERTS_ARE_DETECTED,
700         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
701             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE);
702     updateContainerInformation(MetadataDescription.INSERTS_ARE_DETECTED,
703         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
704             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE);
705
706     // we don't implement Blob references (= LOCATORs), the driver
707
// delivers only copies that the application has to put back by itself.
708
updateContainerInformation(MetadataDescription.LOCATORS_UPDATE_COPY, null,
709         null, Boolean.TRUE);
710
711     // C-JDBC ResultSets are disconnected therefore they cannot detect deletes,
712
// inserts or udpates.
713
updateContainerInformation(MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
714         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
715             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.FALSE);
716     updateContainerInformation(MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
717         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
718             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE);
719     updateContainerInformation(MetadataDescription.OTHERS_DELETES_ARE_VISIBLE,
720         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
721             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE);
722     updateContainerInformation(MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
723         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
724             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.FALSE);
725     updateContainerInformation(MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
726         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
727             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE);
728     updateContainerInformation(MetadataDescription.OTHERS_INSERTS_ARE_VISIBLE,
729         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
730             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE);
731     updateContainerInformation(MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
732         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
733             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.FALSE);
734     updateContainerInformation(MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
735         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
736             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE);
737     updateContainerInformation(MetadataDescription.OTHERS_UPDATES_ARE_VISIBLE,
738         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
739             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE);
740
741     // C-JDBC ResultSets are updated when making changes to the database using
742
// updatable ResultSets
743
updateContainerInformation(MetadataDescription.OWN_DELETES_ARE_VISIBLE,
744         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
745             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.TRUE);
746     updateContainerInformation(MetadataDescription.OWN_DELETES_ARE_VISIBLE,
747         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
748             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.TRUE);
749     updateContainerInformation(MetadataDescription.OWN_DELETES_ARE_VISIBLE,
750         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
751             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.TRUE);
752     updateContainerInformation(MetadataDescription.OWN_INSERTS_ARE_VISIBLE,
753         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
754             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.TRUE);
755     updateContainerInformation(MetadataDescription.OWN_INSERTS_ARE_VISIBLE,
756         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
757             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.TRUE);
758     updateContainerInformation(MetadataDescription.OWN_INSERTS_ARE_VISIBLE,
759         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
760             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.TRUE);
761     updateContainerInformation(MetadataDescription.OWN_UPDATES_ARE_VISIBLE,
762         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
763             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.TRUE);
764     updateContainerInformation(MetadataDescription.OWN_UPDATES_ARE_VISIBLE,
765         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
766             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.TRUE);
767     updateContainerInformation(MetadataDescription.OWN_UPDATES_ARE_VISIBLE,
768         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
769             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.TRUE);
770
771     // We emulate batch updates even if they are not handled optimally yet
772
updateContainerInformation(MetadataDescription.SUPPORTS_BATCH_UPDATES,
773         null, null, Boolean.TRUE);
774
775     // It is currently not possible for a CallableStatement to return multiple
776
// ResultSets
777
updateContainerInformation(
778         MetadataDescription.SUPPORTS_MULTIPLE_OPEN_RESULTS, null, null,
779         Boolean.FALSE);
780
781     // A single call to execute can only return one ResultSet. It this suppose
782
// to be retrived after an executeBatch?
783
updateContainerInformation(
784         MetadataDescription.SUPPORTS_MULTIPLE_RESULTSETS, null, null,
785         Boolean.FALSE);
786
787     // We support open cursors and statements across commit/rollback. Note this
788
// only applies for the driver side since everything is closed right away on
789
// the controller side.
790
updateContainerInformation(
791         MetadataDescription.SUPPORTS_OPEN_CURSORS_ACROSS_COMMIT, null, null,
792         Boolean.TRUE);
793     updateContainerInformation(
794         MetadataDescription.SUPPORTS_OPEN_CURSORS_ACROSS_ROLLBACK, null, null,
795         Boolean.TRUE);
796     updateContainerInformation(
797         MetadataDescription.SUPPORTS_OPEN_STATEMENTS_ACROSS_COMMIT, null, null,
798         Boolean.TRUE);
799     updateContainerInformation(
800         MetadataDescription.SUPPORTS_OPEN_STATEMENTS_ACROSS_ROLLBACK, null,
801         null, Boolean.TRUE);
802
803     // We do not close ResultSets at commit time
804
updateContainerInformation(
805         MetadataDescription.SUPPORTS_RESULT_SET_HOLDABILITY,
806         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
807             ResultSet.HOLD_CURSORS_OVER_COMMIT)}, Boolean.TRUE);
808     updateContainerInformation(
809         MetadataDescription.SUPPORTS_RESULT_SET_HOLDABILITY,
810         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
811             ResultSet.CLOSE_CURSORS_AT_COMMIT)}, Boolean.FALSE);
812
813     // We do support CONCUR_READ_ONLY and CONCUR_UPDATABLE concurrency modes
814
// for all supported ResultSet types
815
updateContainerInformation(
816         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class JavaDoc[]{
817             Integer.TYPE, Integer.TYPE}, new Object JavaDoc[]{
818             new Integer JavaDoc(ResultSet.TYPE_FORWARD_ONLY),
819             new Integer JavaDoc(ResultSet.CONCUR_READ_ONLY)}, Boolean.TRUE);
820     updateContainerInformation(
821         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class JavaDoc[]{
822             Integer.TYPE, Integer.TYPE}, new Object JavaDoc[]{
823             new Integer JavaDoc(ResultSet.TYPE_FORWARD_ONLY),
824             new Integer JavaDoc(ResultSet.CONCUR_UPDATABLE)}, Boolean.TRUE);
825     updateContainerInformation(
826         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class JavaDoc[]{
827             Integer.TYPE, Integer.TYPE}, new Object JavaDoc[]{
828             new Integer JavaDoc(ResultSet.TYPE_SCROLL_INSENSITIVE),
829             new Integer JavaDoc(ResultSet.CONCUR_READ_ONLY)}, Boolean.TRUE);
830     updateContainerInformation(
831         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class JavaDoc[]{
832             Integer.TYPE, Integer.TYPE}, new Object JavaDoc[]{
833             new Integer JavaDoc(ResultSet.TYPE_SCROLL_INSENSITIVE),
834             new Integer JavaDoc(ResultSet.CONCUR_UPDATABLE)}, Boolean.TRUE);
835     updateContainerInformation(
836         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class JavaDoc[]{
837             Integer.TYPE, Integer.TYPE}, new Object JavaDoc[]{
838             new Integer JavaDoc(ResultSet.TYPE_SCROLL_SENSITIVE),
839             new Integer JavaDoc(ResultSet.CONCUR_READ_ONLY)}, Boolean.FALSE);
840     updateContainerInformation(
841         MetadataDescription.SUPPORTS_RESULT_SET_CONCURRENCY, new Class JavaDoc[]{
842             Integer.TYPE, Integer.TYPE}, new Object JavaDoc[]{
843             new Integer JavaDoc(ResultSet.TYPE_SCROLL_SENSITIVE),
844             new Integer JavaDoc(ResultSet.CONCUR_UPDATABLE)}, Boolean.FALSE);
845
846     // We do support FORWARD_ONLY and SCROLL_INSENSITIVE ResultSets only
847
updateContainerInformation(MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
848         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
849             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.TRUE);
850     updateContainerInformation(MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
851         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
852             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.TRUE);
853     updateContainerInformation(MetadataDescription.SUPPORTS_RESULT_SET_TYPE,
854         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
855             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE);
856
857     // No support for Savepoints yet
858
updateContainerInformation(MetadataDescription.SUPPORTS_SAVEPOINTS, null,
859         null, Boolean.FALSE);
860
861     // Updates are never detected since our ResultSets are disconnected
862
updateContainerInformation(MetadataDescription.UPDATES_ARE_DETECTED,
863         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
864             ResultSet.TYPE_FORWARD_ONLY)}, Boolean.FALSE);
865     updateContainerInformation(MetadataDescription.UPDATES_ARE_DETECTED,
866         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
867             ResultSet.TYPE_SCROLL_INSENSITIVE)}, Boolean.FALSE);
868     updateContainerInformation(MetadataDescription.UPDATES_ARE_DETECTED,
869         new Class JavaDoc[]{Integer.TYPE}, new Object JavaDoc[]{new Integer JavaDoc(
870             ResultSet.TYPE_SCROLL_SENSITIVE)}, Boolean.FALSE);
871   }
872
873   /**
874    * Gets the list of tables of a database and add them to the database schema.
875    * The caller must ensure that the parameters are not <code>null</code>.
876    *
877    * @exception SQLException if an error occurs
878    */

879   public void createDatabaseSchemaDynamically() throws SQLException JavaDoc
880   {
881     if (dynamicPrecision == DatabaseBackendSchemaConstants.DynamicPrecisionStatic)
882       return;
883     Connection JavaDoc connection = null;
884     boolean wasInitialized = connectionManager.isInitialized();
885
886     try
887     {
888       if (!wasInitialized)
889         connectionManager.initializeConnections();
890
891       connection = connectionManager.getConnection();
892       if (connection == null)
893       {
894         String JavaDoc msg = Translate.get("backend.meta.connection.failed");
895         logger.error(msg);
896         throw new SQLException JavaDoc(msg);
897       }
898
899       databaseSchema = new DatabaseSQLMetaData(logger, connection,
900           dynamicPrecision, gatherSystemTables, schemaName)
901           .createDatabaseSchema();
902
903     }
904     catch (Exception JavaDoc e)
905     {
906       if (e instanceof RuntimeException JavaDoc)
907         logger.error(Translate.get("backend.meta.runtime.error"), e);
908       throw new SQLException JavaDoc(Translate.get("backend.meta.failed.get.info", e));
909     }
910     finally
911     {
912       if (connection != null)
913         connectionManager.releaseConnection(connection);
914
915       if (!wasInitialized)
916         connectionManager.finalizeConnections();
917
918     }
919   }
920
921   /**
922    * Returns the database schema. Returns <code>null</code> If an error has
923    * occured during the schema generation.
924    * <p>
925    * If the schema has not been previously computed,
926    * {@link #createDatabaseSchemaDynamically()}is called.
927    *
928    * @return a <code>DatabaseSchema</code> value
929    * @exception SQLException if a problem occurs when creating the database
930    * schema
931    * @see #createDatabaseSchemaDynamically
932    */

933   public DatabaseSchema getDatabaseSchema() throws SQLException JavaDoc
934   {
935     if (databaseSchema == null)
936       createDatabaseSchemaDynamically();
937     return databaseSchema;
938   }
939 }
940
Popular Tags