KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > in > co > daffodil > db > jdbc > DaffodilDBDatabaseMetaData


1 package in.co.daffodil.db.jdbc;
2
3 import java.sql.*;
4 import com.daffodilwoods.database.resource.*;
5 import java.util.*;
6 import java.io.*;
7 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.Datatype;
8 import com.daffodilwoods.daffodildb.client._RecordSetBuffer;
9 import com.daffodilwoods.daffodildb.client._RecordSetBufferIterator;
10 import com.daffodilwoods.daffodildb.client._Record;
11 import com.daffodilwoods.daffodildb.server.datadictionarysystem.SystemTables;
12 import in.co.daffodil.db.general.*;
13 import com.daffodilwoods.daffodildb.client.RecordSet;
14 import com.daffodilwoods.daffodildb.server.sql99.dql.listenerevents.IteratorConstants;
15
16 /**
17  * Comprehensive information about the database as a whole.
18  *
19  * <P>Many of the methods here return lists of information in
20  * the form of <code>ResultSet</code> objects.
21  * You can use the normal <code>ResultSet</code> methods such as getString and getInt
22  * to retrieve the data from these <code>ResultSet</code>. If a given form of
23  * metadata is not available, these methods should throw an SQLException.
24  *
25  * <P>Some of these methods take arguments that are String patterns. These
26  * arguments all have names such as fooPattern. Within a pattern String, "%"
27  * means match any substring of 0 or more characters, and "_" means match
28  * any one character. Only metadata entries matching the search pattern
29  * are returned. If a search pattern argument is set to a null ref,
30  * that argument's criteria will be dropped from the search.
31  *
32  * <P>An <code>SQLException</code> will be thrown if a driver does not support a meta
33  * data method. In the case of methods that return a <code>ResultSet</code>,
34  * either a <code>ResultSet</code> (which may be empty) is returned or a
35  * SQLException is thrown.
36  */

37 public class DaffodilDBDatabaseMetaData
38     implements DatabaseMetaData {
39
40   /** @todo there are two column_offset constant defined one is here
41    * and second one is in DaffodilDBDriver */

42   /** @todo check the use of sytem connection and user connection
43    * at the moment everywhere system connection is used */

44   private static int COLUMN_OFFSET = 1;
45   DaffodilDBConnection systemConnection;
46   DaffodilDBConnection userConnection;
47   String JavaDoc url;
48
49   public DaffodilDBDatabaseMetaData(DaffodilDBConnection userCon,
50                                     DaffodilDBConnection systemCon,
51                                     String JavaDoc url0) {
52     systemConnection = systemCon;
53     userConnection = userCon;
54     url = url0;
55   }
56
57   public Connection getConnection() {
58     return userConnection;
59   }
60
61
62   /**
63    * Can all the procedures returned by getProcedures be called by the
64    * current user?
65    *
66    * @return <code>true</code> if so; <code>false</code> otherwise
67    * @exception SQLException if a database access error occurs
68    */

69   public boolean allProceduresAreCallable() throws SQLException {
70     return DatabaseProperties.allProceduresAreCallable;
71   }
72
73   /**
74    * Can all the tables returned by getTable be SELECTed by the
75    * current user?
76    *
77    * @return <code>true</code> if so; <code>false</code> otherwise
78    * @exception SQLException if a database access error occurs
79    */

80   public boolean allTablesAreSelectable() throws SQLException {
81     return DatabaseProperties.allTablesAreSelectable;
82   }
83
84   /**
85    * What's the url for this database?
86    *
87    * @return the url or null if it cannot be generated
88    * @exception SQLException if a database access error occurs
89    */

90   public String JavaDoc getURL() throws SQLException {
91     return url;
92   }
93
94   /**
95    * What's our user name as known to the database?
96    *
97    * @return our database user name
98    * @exception SQLException if a database access error occurs
99    */

100   public String JavaDoc getUserName() throws SQLException {
101     try {
102       return userConnection.getServerConnection().getCurrentUser();
103     }
104     catch (DException ex) {
105       throw ex.getSqlException(systemConnection.getLocale());
106     }
107   }
108
109   /**
110    * Is the database in read-only mode?
111    *
112    * @return <code>true</code> if so; <code>false</code> otherwise
113    * @exception SQLException if a database access error occurs
114    */

115   public boolean isReadOnly() throws SQLException {
116     return systemConnection.isReadOnly();
117   }
118
119   /**
120    * Are NULL values sorted high?
121    *
122    * @return <code>true</code> if so; <code>false</code> otherwise
123    * @exception SQLException if a database access error occurs
124    */

125   public boolean nullsAreSortedHigh() throws SQLException {
126     return DatabaseProperties.nullsAreSortedHigh;
127   }
128
129   /**
130    * Are NULL values sorted low?
131    *
132    * @return <code>true</code> if so; <code>false</code> otherwise
133    * @exception SQLException if a database access error occurs
134    */

135   public boolean nullsAreSortedLow() throws SQLException {
136     return DatabaseProperties.nullsAreSortedLow;
137   }
138
139   /**
140    * Are NULL values sorted at the start regardless of sort order?
141    *
142    * @return <code>true</code> if so; <code>false</code> otherwise
143    * @exception SQLException if a database access error occurs
144    */

145   public boolean nullsAreSortedAtStart() throws SQLException {
146     return DatabaseProperties.nullsAreSortedAtStart;
147   }
148
149   /**
150    * Are NULL values sorted at the end regardless of sort order?
151    *
152    * @return <code>true</code> if so; <code>false</code> otherwise
153    * @exception SQLException if a database access error occurs
154    */

155   public boolean nullsAreSortedAtEnd() throws SQLException {
156     return DatabaseProperties.nullsAreSortedAtEnd;
157   }
158
159   /**
160    * What's the name of this database product?
161    *
162    * @return database product name
163    * @exception SQLException if a database access error occurs
164    */

165   public String JavaDoc getDatabaseProductName() throws SQLException {
166     return DatabaseProperties.databaseProductName;
167   }
168
169   /**
170    * What's the version of this database product?
171    *
172    * @return database version
173    * @exception SQLException if a database access error occurs
174    */

175   public String JavaDoc getDatabaseProductVersion() throws SQLException {
176     return DatabaseProperties.databaseProductVersion;
177   }
178
179   /**
180    * What's the name of this JDBC driver?
181    *
182    * @return JDBC driver name
183    * @exception SQLException if a database access error occurs
184    */

185   public String JavaDoc getDriverName() throws SQLException {
186     return DatabaseProperties.driverName;
187   }
188
189   /**
190    * What's the version of this JDBC driver?
191    *
192    * @return JDBC driver version
193    * @exception SQLException if a database access error occurs
194    */

195   public String JavaDoc getDriverVersion() throws SQLException {
196     return DatabaseProperties.driverVersion;
197   }
198
199   /**
200    * What's this JDBC driver's major version number?
201    *
202    * @return JDBC driver major version
203    */

204   public int getDriverMajorVersion() {
205     return DatabaseProperties.driverMajorVersion;
206   }
207
208   /**
209    * What's this JDBC driver's minor version number?
210    *
211    * @return JDBC driver minor version number
212    */

213   public int getDriverMinorVersion() {
214     return DatabaseProperties.driverMinorVersion;
215   }
216
217   /**
218    * Does the database store tables in a local file?
219    *
220    * @return <code>true</code> if so; <code>false</code> otherwise
221    * @exception SQLException if a database access error occurs
222    */

223   public boolean usesLocalFiles() throws SQLException {
224     return DatabaseProperties.usesLocalFiles;
225   }
226
227   /**
228    * Does the database use a file for each table?
229    *
230    * @return true if the database uses a local file for each table
231    * @exception SQLException if a database access error occurs
232    */

233   public boolean usesLocalFilePerTable() throws SQLException {
234     return DatabaseProperties.usesLocalFilePerTable;
235   }
236
237   /**
238    * Does the database treat mixed case unquoted SQL identifiers as
239    * case sensitive and as a result store them in mixed case?
240    *
241    * A JDBC Compliant<sup><font size=-2>TM</font></sup> driver will always return false.
242    *
243    * @return <code>true</code> if so; <code>false</code> otherwise
244    * @exception SQLException if a database access error occurs
245    */

246   public boolean supportsMixedCaseIdentifiers() throws SQLException {
247     return DatabaseProperties.supportsMixedCaseIdentifiers;
248   }
249
250   /**
251    * Does the database treat mixed case unquoted SQL identifiers as
252    * case insensitive and store them in upper case?
253    *
254    * @return <code>true</code> if so; <code>false</code> otherwise
255    * @exception SQLException if a database access error occurs
256    */

257   public boolean storesUpperCaseIdentifiers() throws SQLException {
258     return DatabaseProperties.storesUpperCaseIdentifiers;
259   }
260
261   /**
262    * Does the database treat mixed case unquoted SQL identifiers as
263    * case insensitive and store them in lower case?
264    *
265    * @return <code>true</code> if so; <code>false</code> otherwise
266    * @exception SQLException if a database access error occurs
267    */

268   public boolean storesLowerCaseIdentifiers() throws SQLException {
269     return DatabaseProperties.storesLowerCaseIdentifiers;
270   }
271
272   /**
273    * Does the database treat mixed case unquoted SQL identifiers as
274    * case insensitive and store them in mixed case?
275    *
276    * @return <code>true</code> if so; <code>false</code> otherwise
277    * @exception SQLException if a database access error occurs
278    */

279   public boolean storesMixedCaseIdentifiers() throws SQLException {
280     return DatabaseProperties.storesMixedCaseIdentifiers;
281   }
282
283   /**
284    * Does the database treat mixed case quoted SQL identifiers as
285    * case sensitive and as a result store them in mixed case?
286    *
287    * A JDBC Compliant<sup><font size=-2>TM</font></sup> driver will always return true.
288    *
289    * @return <code>true</code> if so; <code>false</code> otherwise
290    * @exception SQLException if a database access error occurs
291    */

292   public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
293     return DatabaseProperties.supportsMixedCaseQuotedIdentifiers;
294   }
295
296   /**
297    * Does the database treat mixed case quoted SQL identifiers as
298    * case insensitive and store them in upper case?
299    *
300    * @return <code>true</code> if so; <code>false</code> otherwise
301    * @exception SQLException if a database access error occurs
302    */

303   public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
304     return DatabaseProperties.storesUpperCaseQuotedIdentifiers;
305   }
306
307   /**
308    * Does the database treat mixed case quoted SQL identifiers as
309    * case insensitive and store them in lower case?
310    *
311    * @return <code>true</code> if so; <code>false</code> otherwise
312    * @exception SQLException if a database access error occurs
313    */

314   public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
315     return DatabaseProperties.storesLowerCaseQuotedIdentifiers;
316   }
317
318   /**
319    * Does the database treat mixed case quoted SQL identifiers as
320    * case insensitive and store them in mixed case?
321    *
322    * @return <code>true</code> if so; <code>false</code> otherwise
323    * @exception SQLException if a database access error occurs
324    */

325   public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
326     return DatabaseProperties.storesMixedCaseQuotedIdentifiers;
327   }
328
329   /**
330    * What's the string used to quote SQL identifiers?
331    * This returns a space " " if identifier quoting isn't supported.
332    *
333    * A JDBC Compliant<sup><font size=-2>TM</font></sup>
334    * driver always uses a double quote character.
335    *
336    * @return the quoting string
337    * @exception SQLException if a database access error occurs
338    */

339   public String JavaDoc getIdentifierQuoteString() throws SQLException {
340     return DatabaseProperties.identifierQuoteString;
341   }
342
343   /**
344    * Gets a comma-separated list of all a database's SQL keywords
345    * that are NOT also SQL92 keywords.
346    *
347    * @return the list
348    * @exception SQLException if a database access error occurs
349    */

350   public String JavaDoc getSQLKeywords() throws SQLException {
351     return DatabaseProperties.getSQLKeywords();
352   }
353
354   /**
355    * Gets a comma-separated list of math functions. These are the
356    * X/Open CLI math function names used in the JDBC function escape
357    * clause.
358    *
359    * @return the list
360    * @exception SQLException if a database access error occurs
361    */

362   public String JavaDoc getNumericFunctions() throws SQLException {
363     return DatabaseProperties.getNumericFunctions();
364   }
365
366   /**
367    * Gets a comma-separated list of string functions. These are the
368    * X/Open CLI string function names used in the JDBC function escape
369    * clause.
370    *
371    * @return the list
372    * @exception SQLException if a database access error occurs
373    */

374   public String JavaDoc getStringFunctions() throws SQLException {
375     return DatabaseProperties.getStringFunctions();
376   }
377
378   /**
379    * Gets a comma-separated list of system functions. These are the
380    * X/Open CLI system function names used in the JDBC function escape
381    * clause.
382    *
383    * @return the list
384    * @exception SQLException if a database access error occurs
385    */

386   public String JavaDoc getSystemFunctions() throws SQLException {
387     return DatabaseProperties.getSystemFunctions();
388   }
389
390   /**
391    * Gets a comma-separated list of time and date functions.
392    *
393    * @return the list
394    * @exception SQLException if a database access error occurs
395    */

396   public String JavaDoc getTimeDateFunctions() throws SQLException {
397     return DatabaseProperties.getTimeDateFunctions();
398   }
399
400   /**
401    * Gets the string that can be used to escape wildcard characters.
402    * This is the string that can be used to escape '_' or '%' in
403    * the string pattern style catalog search parameters.
404    *
405    * <P>The '_' character represents any single character.
406    * <P>The '%' character represents any sequence of zero or
407    * more characters.
408    *
409    * @return the string used to escape wildcard characters
410    * @exception SQLException if a database access error occurs
411    */

412   public String JavaDoc getSearchStringEscape() throws SQLException {
413     return DatabaseProperties.getSearchStringEscape();
414   }
415
416   /**
417    * Gets all the "extra" characters that can be used in unquoted
418    * identifier names (those beyond a-z, A-Z, 0-9 and _).
419    *
420    * @return the string containing the extra characters
421    * @exception SQLException if a database access error occurs
422    */

423   public String JavaDoc getExtraNameCharacters() throws SQLException {
424     return DatabaseProperties.getExtraNameCharacters();
425   }
426
427
428   /**
429    * Is "ALTER TABLE" with add column supported?
430    *
431    * @return <code>true</code> if so; <code>false</code> otherwise
432    * @exception SQLException if a database access error occurs
433    */

434   public boolean supportsAlterTableWithAddColumn() throws SQLException {
435     return DatabaseProperties.supportsAlterTableWithAddColumn;
436   }
437
438   /**
439    * Is "ALTER TABLE" with drop column supported?
440    *
441    * @return <code>true</code> if so; <code>false</code> otherwise
442    * @exception SQLException if a database access error occurs
443    */

444   public boolean supportsAlterTableWithDropColumn() throws SQLException {
445     return DatabaseProperties.supportsAlterTableWithDropColumn;
446   }
447
448   /**
449    * Is column aliasing supported?
450    *
451    * <P>If so, the SQL AS clause can be used to provide names for
452    * computed columns or to provide alias names for columns as
453    * required.
454    *
455        * A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
456    *
457    * @return <code>true</code> if so; <code>false</code> otherwise
458    * @exception SQLException if a database access error occurs
459    */

460   public boolean supportsColumnAliasing() throws SQLException {
461     return DatabaseProperties.supportsColumnAliasing;
462   }
463
464   /**
465    * Are concatenations between NULL and non-NULL values NULL?
466    * For SQL-92 compliance, a JDBC technology-enabled driver will
467    * return <code>true</code>.
468    *
469    * @return <code>true</code> if so; <code>false</code> otherwise
470    * @exception SQLException if a database access error occurs
471    */

472   public boolean nullPlusNonNullIsNull() throws SQLException {
473     return DatabaseProperties.nullPlusNonNullIsNull;
474   }
475
476   /**
477    * Is the CONVERT function between SQL types supported?
478    *
479    * @return <code>true</code> if so; <code>false</code> otherwise
480    * @exception SQLException if a database access error occurs
481    */

482   public boolean supportsConvert() throws SQLException {
483     return DatabaseProperties.supportsConvert;
484   }
485
486   /**
487    * Is CONVERT between the given SQL types supported?
488    *
489    * @param fromType the type to convert from
490    * @param toType the type to convert to
491    * @return <code>true</code> if so; <code>false</code> otherwise
492    * @exception SQLException if a database access error occurs
493    * @see Types
494    */

495   public boolean supportsConvert(int fromType, int toType) throws SQLException {
496     return DatabaseProperties.supportsConvert(fromType, toType);
497   }
498
499   /**
500    * Are table correlation names supported?
501    *
502        * A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
503    *
504    * @return <code>true</code> if so; <code>false</code> otherwise
505    * @exception SQLException if a database access error occurs
506    */

507   public boolean supportsTableCorrelationNames() throws SQLException {
508     return DatabaseProperties.supportsTableCorrelationNames;
509   }
510
511   /**
512    * If table correlation names are supported, are they restricted
513    * to be different from the names of the tables?
514    *
515    * @return <code>true</code> if so; <code>false</code> otherwise
516    * @exception SQLException if a database access error occurs
517    */

518   public boolean supportsDifferentTableCorrelationNames() throws SQLException {
519     return DatabaseProperties.supportsDifferentTableCorrelationNames;
520   }
521
522   /**
523    * Are expressions in "ORDER BY" lists supported?
524    *
525    * @return <code>true</code> if so; <code>false</code> otherwise
526    * @exception SQLException if a database access error occurs
527    */

528   public boolean supportsExpressionsInOrderBy() throws SQLException {
529     return DatabaseProperties.supportsExpressionsInOrderBy;
530   }
531
532   /**
533    * Can an "ORDER BY" clause use columns not in the SELECT statement?
534    *
535    * @return <code>true</code> if so; <code>false</code> otherwise
536    * @exception SQLException if a database access error occurs
537    */

538   public boolean supportsOrderByUnrelated() throws SQLException {
539     return DatabaseProperties.supportsOrderByUnrelated;
540   }
541
542   /**
543    * Is some form of "GROUP BY" clause supported?
544    *
545    * @return <code>true</code> if so; <code>false</code> otherwise
546    * @exception SQLException if a database access error occurs
547    */

548   public boolean supportsGroupBy() throws SQLException {
549     return DatabaseProperties.supportsGroupBy;
550   }
551
552   /**
553    * Can a "GROUP BY" clause use columns not in the SELECT?
554    *
555    * @return <code>true</code> if so; <code>false</code> otherwise
556    * @exception SQLException if a database access error occurs
557    */

558   public boolean supportsGroupByUnrelated() throws SQLException {
559     return DatabaseProperties.supportsGroupByUnrelated;
560   }
561
562   /**
563    * Can a "GROUP BY" clause add columns not in the SELECT
564    * provided it specifies all the columns in the SELECT?
565    *
566    * @return <code>true</code> if so; <code>false</code> otherwise
567    * @exception SQLException if a database access error occurs
568    */

569   public boolean supportsGroupByBeyondSelect() throws SQLException {
570     return DatabaseProperties.supportsGroupByBeyondSelect;
571   }
572
573   /**
574    * Is the escape character in "LIKE" clauses supported?
575    *
576        * A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
577    *
578    * @return <code>true</code> if so; <code>false</code> otherwise
579    * @exception SQLException if a database access error occurs
580    */

581   public boolean supportsLikeEscapeClause() throws SQLException {
582     return DatabaseProperties.supportsLikeEscapeClause;
583   }
584
585   /**
586    * Are multiple <code>ResultSet</code> from a single execute supported?
587    *
588    * @return <code>true</code> if so; <code>false</code> otherwise
589    * @exception SQLException if a database access error occurs
590    */

591   public boolean supportsMultipleResultSets() throws SQLException {
592     return DatabaseProperties.supportsMultipleResultSets;
593   }
594
595   /**
596    * Can we have multiple transactions open at once (on different
597    * connections)?
598    *
599    * @return <code>true</code> if so; <code>false</code> otherwise
600    * @exception SQLException if a database access error occurs
601    */

602   public boolean supportsMultipleTransactions() throws SQLException {
603     return DatabaseProperties.supportsMultipleTransactions;
604   }
605
606   /**
607    * Can columns be defined as non-nullable?
608    *
609        * A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
610    *
611    * @return <code>true</code> if so; <code>false</code> otherwise
612    * @exception SQLException if a database access error occurs
613    */

614   public boolean supportsNonNullableColumns() throws SQLException {
615     return DatabaseProperties.supportsNonNullableColumns;
616   }
617
618   /**
619    * Is the ODBC Minimum SQL grammar supported?
620    *
621        * All JDBC Compliant<sup><font size=-2>TM</font></sup> drivers must return true.
622    *
623    * @return <code>true</code> if so; <code>false</code> otherwise
624    * @exception SQLException if a database access error occurs
625    */

626   public boolean supportsMinimumSQLGrammar() throws SQLException {
627     return DatabaseProperties.supportsMinimumSQLGrammar;
628   }
629
630   /**
631    * Is the ODBC Core SQL grammar supported?
632    *
633    * @return <code>true</code> if so; <code>false</code> otherwise
634    * @exception SQLException if a database access error occurs
635    */

636   public boolean supportsCoreSQLGrammar() throws SQLException {
637     return DatabaseProperties.supportsCoreSQLGrammar;
638   }
639
640   /**
641    * Is the ODBC Extended SQL grammar supported?
642    *
643    * @return <code>true</code> if so; <code>false</code> otherwise
644    * @exception SQLException if a database access error occurs
645    */

646   public boolean supportsExtendedSQLGrammar() throws SQLException {
647     return DatabaseProperties.supportsExtendedSQLGrammar;
648   }
649
650   /**
651    * Is the ANSI92 entry level SQL grammar supported?
652    *
653        * All JDBC Compliant<sup><font size=-2>TM</font></sup> drivers must return true.
654    *
655    * @return <code>true</code> if so; <code>false</code> otherwise
656    * @exception SQLException if a database access error occurs
657    */

658   public boolean supportsANSI92EntryLevelSQL() throws SQLException {
659     return DatabaseProperties.supportsANSI92EntryLevelSQL;
660   }
661
662   /**
663    * Is the ANSI92 intermediate SQL grammar supported?
664    *
665    * @return <code>true</code> if so; <code>false</code> otherwise
666    * @exception SQLException if a database access error occurs
667    */

668   public boolean supportsANSI92IntermediateSQL() throws SQLException {
669     return DatabaseProperties.supportsANSI92IntermediateSQL;
670   }
671
672   /**
673    * Is the ANSI92 full SQL grammar supported?
674    *
675    * @return <code>true</code> if so; <code>false</code> otherwise
676    * @exception SQLException if a database access error occurs
677    */

678   public boolean supportsANSI92FullSQL() throws SQLException {
679     return DatabaseProperties.supportsANSI92FullSQL;
680   }
681
682   /**
683    * Is the SQL Integrity Enhancement Facility supported?
684    *
685    * @return <code>true</code> if so; <code>false</code> otherwise
686    * @exception SQLException if a database access error occurs
687    */

688   public boolean supportsIntegrityEnhancementFacility() throws SQLException {
689     return DatabaseProperties.supportsIntegrityEnhancementFacility;
690   }
691
692   /**
693    * Is some form of outer join supported?
694    *
695    * @return <code>true</code> if so; <code>false</code> otherwise
696    * @exception SQLException if a database access error occurs
697    */

698   public boolean supportsOuterJoins() throws SQLException {
699     return DatabaseProperties.supportsOuterJoins;
700   }
701
702   /**
703    * Are full nested outer joins supported?
704    *
705    * @return <code>true</code> if so; <code>false</code> otherwise
706    * @exception SQLException if a database access error occurs
707    */

708   public boolean supportsFullOuterJoins() throws SQLException {
709     return DatabaseProperties.supportsFullOuterJoins;
710   }
711
712   /**
713    * Is there limited support for outer joins? (This will be true
714    * if supportFullOuterJoins is true.)
715    *
716    * @return <code>true</code> if so; <code>false</code> otherwise
717    * @exception SQLException if a database access error occurs
718    */

719   public boolean supportsLimitedOuterJoins() throws SQLException {
720     return DatabaseProperties.supportsLimitedOuterJoins;
721   }
722
723   /**
724    * What's the database vendor's preferred term for "schema"?
725    *
726    * @return the vendor term
727    * @exception SQLException if a database access error occurs
728    */

729   public String JavaDoc getSchemaTerm() throws SQLException {
730     return DatabaseProperties.schemaTerm;
731   }
732
733   /**
734    * What's the database vendor's preferred term for "procedure"?
735    *
736    * @return the vendor term
737    * @exception SQLException if a database access error occurs
738    */

739   public String JavaDoc getProcedureTerm() throws SQLException {
740     return DatabaseProperties.procedureTerm;
741   }
742
743   /**
744    * What's the database vendor's preferred term for "catalog"?
745    *
746    * @return the vendor term
747    * @exception SQLException if a database access error occurs
748    */

749   public String JavaDoc getCatalogTerm() throws SQLException {
750     return DatabaseProperties.catalogTerm;
751   }
752
753   /**
754    * Does a catalog appear at the start of a qualified table name?
755    * (Otherwise it appears at the end)
756    *
757    * @return true if it appears at the start
758    * @exception SQLException if a database access error occurs
759    */

760   public boolean isCatalogAtStart() throws SQLException {
761     return DatabaseProperties.isCatalogAtStart;
762   }
763
764   /**
765    * What's the separator between catalog and table name?
766    *
767    * @return the separator string
768    * @exception SQLException if a database access error occurs
769    */

770   public String JavaDoc getCatalogSeparator() throws SQLException {
771     return DatabaseProperties.catalogSeparator;
772   }
773
774   /**
775    * Can a schema name be used in a data manipulation statement?
776    *
777    * @return <code>true</code> if so; <code>false</code> otherwise
778    * @exception SQLException if a database access error occurs
779    */

780   public boolean supportsSchemasInDataManipulation() throws SQLException {
781     return DatabaseProperties.supportsSchemasInDataManipulation;
782   }
783
784   /**
785    * Can a schema name be used in a procedure call statement?
786    *
787    * @return <code>true</code> if so; <code>false</code> otherwise
788    * @exception SQLException if a database access error occurs
789    */

790   public boolean supportsSchemasInProcedureCalls() throws SQLException {
791     return DatabaseProperties.supportsSchemasInProcedureCalls;
792   }
793
794   /**
795    * Can a schema name be used in a table definition statement?
796    *
797    * @return <code>true</code> if so; <code>false</code> otherwise
798    * @exception SQLException if a database access error occurs
799    */

800   public boolean supportsSchemasInTableDefinitions() throws SQLException {
801     return DatabaseProperties.supportsSchemasInTableDefinitions;
802   }
803
804   /**
805    * Can a schema name be used in an index definition statement?
806    *
807    * @return <code>true</code> if so; <code>false</code> otherwise
808    * @exception SQLException if a database access error occurs
809    */

810   public boolean supportsSchemasInIndexDefinitions() throws SQLException {
811     return DatabaseProperties.supportsSchemasInIndexDefinitions;
812   }
813
814   /**
815    * Can a schema name be used in a privilege definition statement?
816    *
817    * @return <code>true</code> if so; <code>false</code> otherwise
818    * @exception SQLException if a database access error occurs
819    */

820   public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
821     return DatabaseProperties.supportsSchemasInPrivilegeDefinitions;
822   }
823
824   /**
825    * Can a catalog name be used in a data manipulation statement?
826    *
827    * @return <code>true</code> if so; <code>false</code> otherwise
828    * @exception SQLException if a database access error occurs
829    */

830   public boolean supportsCatalogsInDataManipulation() throws SQLException {
831     return DatabaseProperties.supportsCatalogsInDataManipulation;
832   }
833
834   /**
835    * Can a catalog name be used in a procedure call statement?
836    *
837    * @return <code>true</code> if so; <code>false</code> otherwise
838    * @exception SQLException if a database access error occurs
839    */

840   public boolean supportsCatalogsInProcedureCalls() throws SQLException {
841     return DatabaseProperties.supportsCatalogsInProcedureCalls;
842   }
843
844   /**
845    * Can a catalog name be used in a table definition statement?
846    *
847    * @return <code>true</code> if so; <code>false</code> otherwise
848    * @exception SQLException if a database access error occurs
849    */

850   public boolean supportsCatalogsInTableDefinitions() throws SQLException {
851     return DatabaseProperties.supportsCatalogsInTableDefinitions;
852   }
853
854   /**
855    * Can a catalog name be used in an index definition statement?
856    *
857    * @return <code>true</code> if so; <code>false</code> otherwise
858    * @exception SQLException if a database access error occurs
859    */

860   public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
861     return DatabaseProperties.supportsCatalogsInIndexDefinitions;
862   }
863
864   /**
865    * Can a catalog name be used in a privilege definition statement?
866    *
867    * @return <code>true</code> if so; <code>false</code> otherwise
868    * @exception SQLException if a database access error occurs
869    */

870   public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
871     return DatabaseProperties.supportsCatalogsInPrivilegeDefinitions;
872   }
873
874   /**
875    * Is positioned DELETE supported?
876    *
877    * @return <code>true</code> if so; <code>false</code> otherwise
878    * @exception SQLException if a database access error occurs
879    */

880   public boolean supportsPositionedDelete() throws SQLException {
881     return DatabaseProperties.supportsPositionedDelete;
882   }
883
884   /**
885    * Is positioned UPDATE supported?
886    *
887    * @return <code>true</code> if so; <code>false</code> otherwise
888    * @exception SQLException if a database access error occurs
889    */

890   public boolean supportsPositionedUpdate() throws SQLException {
891     return DatabaseProperties.supportsPositionedUpdate;
892   }
893
894   /**
895    * Is SELECT for UPDATE supported?
896    *
897    * @return <code>true</code> if so; <code>false</code> otherwise
898    * @exception SQLException if a database access error occurs
899    */

900   public boolean supportsSelectForUpdate() throws SQLException {
901     return DatabaseProperties.supportsSelectForUpdate;
902   }
903
904   /**
905    * Are stored procedure calls using the stored procedure escape
906    * syntax supported?
907    *
908    * @return <code>true</code> if so; <code>false</code> otherwise
909    * @exception SQLException if a database access error occurs
910    */

911   public boolean supportsStoredProcedures() throws SQLException {
912     return DatabaseProperties.supportsStoredProcedures;
913   }
914
915   /**
916    * Are subqueries in comparison expressions supported?
917    *
918        * A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
919    *
920    * @return <code>true</code> if so; <code>false</code> otherwise
921    * @exception SQLException if a database access error occurs
922    */

923   public boolean supportsSubqueriesInComparisons() throws SQLException {
924     return DatabaseProperties.supportsSubqueriesInComparisons;
925   }
926
927   /**
928    * Are subqueries in 'exists' expressions supported?
929    *
930        * A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
931    *
932    * @return <code>true</code> if so; <code>false</code> otherwise
933    * @exception SQLException if a database access error occurs
934    */

935   public boolean supportsSubqueriesInExists() throws SQLException {
936     return DatabaseProperties.supportsSubqueriesInExists;
937   }
938
939   /**
940    * Are subqueries in 'in' statements supported?
941    *
942        * A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
943    *
944    * @return <code>true</code> if so; <code>false</code> otherwise
945    * @exception SQLException if a database access error occurs
946    */

947   public boolean supportsSubqueriesInIns() throws SQLException {
948     return DatabaseProperties.supportsSubqueriesInIns;
949   }
950
951   /**
952    * Are subqueries in quantified expressions supported?
953    *
954        * A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
955    *
956    * @return <code>true</code> if so; <code>false</code> otherwise
957    * @exception SQLException if a database access error occurs
958    */

959   public boolean supportsSubqueriesInQuantifieds() throws SQLException {
960     return DatabaseProperties.supportsSubqueriesInQuantifieds;
961   }
962
963   /**
964    * Are correlated subqueries supported?
965    *
966        * A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
967    *
968    * @return <code>true</code> if so; <code>false</code> otherwise
969    * @exception SQLException if a database access error occurs
970    */

971   public boolean supportsCorrelatedSubqueries() throws SQLException {
972     return DatabaseProperties.supportsCorrelatedSubqueries;
973   }
974
975   /**
976    * Is SQL UNION supported?
977    *
978    * @return <code>true</code> if so; <code>false</code> otherwise
979    * @exception SQLException if a database access error occurs
980    */

981   public boolean supportsUnion() throws SQLException {
982     return DatabaseProperties.supportsUnion;
983   }
984
985   /**
986    * Is SQL UNION ALL supported?
987    *
988    * @return <code>true</code> if so; <code>false</code> otherwise
989    * @exception SQLException if a database access error occurs
990    */

991   public boolean supportsUnionAll() throws SQLException {
992     return DatabaseProperties.supportsUnionAll;
993   }
994
995   /**
996    * Can cursors remain open across commits?
997    *
998    * @return <code>true</code> if cursors always remain open;
999    * <code>false</code> if they might not remain open
1000   * @exception SQLException if a database access error occurs
1001   */

1002  public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
1003    return DatabaseProperties.supportsOpenCursorsAcrossCommit;
1004  }
1005
1006  /**
1007   * Can cursors remain open across rollbacks?
1008   *
1009   * @return <code>true</code> if cursors always remain open;
1010   * <code>false</code> if they might not remain open
1011   * @exception SQLException if a database access error occurs
1012   */

1013  public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
1014    return DatabaseProperties.supportsOpenCursorsAcrossRollback;
1015  }
1016
1017  /**
1018   * Can statements remain open across commits?
1019   *
1020   * @return <code>true</code> if statements always remain open;
1021   * <code>false</code> if they might not remain open
1022   * @exception SQLException if a database access error occurs
1023   */

1024  public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
1025    return DatabaseProperties.supportsOpenStatementsAcrossCommit;
1026  }
1027
1028  /**
1029   * Can statements remain open across rollbacks?
1030   *
1031   * @return <code>true</code> if statements always remain open;
1032   * <code>false</code> if they might not remain open
1033   * @exception SQLException if a database access error occurs
1034   */

1035  public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
1036    return DatabaseProperties.supportsOpenCursorsAcrossRollback;
1037  }
1038
1039
1040  /**
1041   * How many hex characters can you have in an inline binary literal?
1042   *
1043   * @return max binary literal length in hex characters;
1044       * a result of zero means that there is no limit or the limit is not known
1045   * @exception SQLException if a database access error occurs
1046   */

1047  public int getMaxBinaryLiteralLength() throws SQLException {
1048    return DatabaseProperties.maxBinaryLiteralLength;
1049  }
1050
1051  /**
1052   * What's the max length for a character literal?
1053   *
1054   * @return max literal length;
1055       * a result of zero means that there is no limit or the limit is not known
1056   * @exception SQLException if a database access error occurs
1057   */

1058  public int getMaxCharLiteralLength() throws SQLException {
1059    return DatabaseProperties.maxCharLiteralLength;
1060  }
1061
1062  /**
1063   * What's the limit on column name length?
1064   *
1065   * @return max column name length;
1066       * a result of zero means that there is no limit or the limit is not known
1067   * @exception SQLException if a database access error occurs
1068   */

1069  public int getMaxColumnNameLength() throws SQLException {
1070    return DatabaseProperties.maxColumnNameLength;
1071  }
1072
1073  /**
1074   * What's the maximum number of columns in a "GROUP BY" clause?
1075   *
1076   * @return max number of columns;
1077       * a result of zero means that there is no limit or the limit is not known
1078   * @exception SQLException if a database access error occurs
1079   */

1080  public int getMaxColumnsInGroupBy() throws SQLException {
1081    return DatabaseProperties.maxColumnsInGroupBy;
1082  }
1083
1084  /**
1085   * What's the maximum number of columns allowed in an index?
1086   *
1087   * @return max number of columns;
1088       * a result of zero means that there is no limit or the limit is not known
1089   * @exception SQLException if a database access error occurs
1090   */

1091  public int getMaxColumnsInIndex() throws SQLException {
1092    return DatabaseProperties.maxColumnsInIndex;
1093  }
1094
1095  /**
1096   * What's the maximum number of columns in an "ORDER BY" clause?
1097   *
1098   * @return max number of columns;
1099       * a result of zero means that there is no limit or the limit is not known
1100   * @exception SQLException if a database access error occurs
1101   */

1102  public int getMaxColumnsInOrderBy() throws SQLException {
1103    return DatabaseProperties.maxColumnsInOrderBy;
1104  }
1105
1106  /**
1107   * What's the maximum number of columns in a "SELECT" list?
1108   *
1109   * @return max number of columns;
1110       * a result of zero means that there is no limit or the limit is not known
1111   * @exception SQLException if a database access error occurs
1112   */

1113  public int getMaxColumnsInSelect() throws SQLException {
1114    return DatabaseProperties.maxColumnsInSelect;
1115  }
1116
1117  /**
1118   * What's the maximum number of columns in a table?
1119   *
1120   * @return max number of columns;
1121       * a result of zero means that there is no limit or the limit is not known
1122   * @exception SQLException if a database access error occurs
1123   */

1124  public int getMaxColumnsInTable() throws SQLException {
1125    return DatabaseProperties.maxColumnsInTable;
1126  }
1127
1128  /**
1129   * How many active connections can we have at a time to this database?
1130   *
1131   * @return max number of active connections;
1132       * a result of zero means that there is no limit or the limit is not known
1133   * @exception SQLException if a database access error occurs
1134   */

1135  public int getMaxConnections() throws SQLException {
1136    return DatabaseProperties.maxConnections;
1137  }
1138
1139  /**
1140   * What's the maximum cursor name length?
1141   *
1142   * @return max cursor name length in bytes;
1143       * a result of zero means that there is no limit or the limit is not known
1144   * @exception SQLException if a database access error occurs
1145   */

1146  public int getMaxCursorNameLength() throws SQLException {
1147    return DatabaseProperties.maxCursorNameLength;
1148  }
1149
1150  /**
1151   * Retrieves the maximum number of bytes for an index, including all
1152   * of the parts of the index.
1153   *
1154   * @return max index length in bytes, which includes the composite of all
1155   * the constituent parts of the index;
1156       * a result of zero means that there is no limit or the limit is not known
1157   * @exception SQLException if a database access error occurs
1158   */

1159  public int getMaxIndexLength() throws SQLException {
1160    return DatabaseProperties.maxIndexLength;
1161  }
1162
1163  /**
1164   * What's the maximum length allowed for a schema name?
1165   *
1166   * @return max name length in bytes;
1167       * a result of zero means that there is no limit or the limit is not known
1168   * @exception SQLException if a database access error occurs
1169   */

1170  public int getMaxSchemaNameLength() throws SQLException {
1171    return DatabaseProperties.maxSchemaNameLength;
1172  }
1173
1174  /**
1175   * What's the maximum length of a procedure name?
1176   *
1177   * @return max name length in bytes;
1178       * a result of zero means that there is no limit or the limit is not known
1179   * @exception SQLException if a database access error occurs
1180   */

1181  public int getMaxProcedureNameLength() throws SQLException {
1182    return DatabaseProperties.maxProcedureNameLength;
1183  }
1184
1185  /**
1186   * What's the maximum length of a catalog name?
1187   *
1188   * @return max name length in bytes;
1189       * a result of zero means that there is no limit or the limit is not known
1190   * @exception SQLException if a database access error occurs
1191   */

1192  public int getMaxCatalogNameLength() throws SQLException {
1193    return DatabaseProperties.maxCatalogNameLength;
1194  }
1195
1196  /**
1197   * What's the maximum length of a single row?
1198   *
1199   * @return max row size in bytes;
1200       * a result of zero means that there is no limit or the limit is not known
1201   * @exception SQLException if a database access error occurs
1202   */

1203  public int getMaxRowSize() throws SQLException {
1204    return DatabaseProperties.maxRowSize;
1205  }
1206
1207  /**
1208   * Did getMaxRowSize() include LONGVARCHAR and LONGVARBINARY
1209   * blobs?
1210   *
1211   * @return <code>true</code> if so; <code>false</code> otherwise
1212   * @exception SQLException if a database access error occurs
1213   */

1214  public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {
1215    return DatabaseProperties.doesMaxRowSizeIncludeBlobs;
1216  }
1217
1218  /**
1219   * What's the maximum length of an SQL statement?
1220   *
1221   * @return max length in bytes;
1222       * a result of zero means that there is no limit or the limit is not known
1223   * @exception SQLException if a database access error occurs
1224   */

1225  public int getMaxStatementLength() throws SQLException {
1226    return DatabaseProperties.maxStatementLength;
1227  }
1228
1229  /**
1230   * How many active statements can we have open at one time to this
1231   * database?
1232   *
1233   * @return the maximum number of statements that can be open at one time;
1234       * a result of zero means that there is no limit or the limit is not known
1235   * @exception SQLException if a database access error occurs
1236   */

1237  public int getMaxStatements() throws SQLException {
1238    return DatabaseProperties.maxStatements;
1239  }
1240
1241  /**
1242   * What's the maximum length of a table name?
1243   *
1244   * @return max name length in bytes;
1245       * a result of zero means that there is no limit or the limit is not known
1246   * @exception SQLException if a database access error occurs
1247   */

1248  public int getMaxTableNameLength() throws SQLException {
1249    return DatabaseProperties.maxTableNameLength;
1250  }
1251
1252  /**
1253   * What's the maximum number of tables in a SELECT statement?
1254   *
1255   * @return the maximum number of tables allowed in a SELECT statement;
1256       * a result of zero means that there is no limit or the limit is not known
1257   * @exception SQLException if a database access error occurs
1258   */

1259  public int getMaxTablesInSelect() throws SQLException {
1260    return DatabaseProperties.maxTablesInSelect;
1261  }
1262
1263  /**
1264   * What's the maximum length of a user name?
1265   *
1266   * @return max user name length in bytes;
1267       * a result of zero means that there is no limit or the limit is not known
1268   * @exception SQLException if a database access error occurs
1269   */

1270  public int getMaxUserNameLength() throws SQLException {
1271    return DatabaseProperties.maxUserNameLength;
1272  }
1273
1274
1275  /**
1276   * What's the database's default transaction isolation level? The
1277   * values are defined in <code>java.sql.Connection</code>.
1278   *
1279   * @return the default isolation level
1280   * @exception SQLException if a database access error occurs
1281   * @see Connection
1282   */

1283  public int getDefaultTransactionIsolation() throws SQLException {
1284    return DatabaseProperties.defaultTransactionIsolation;
1285  }
1286
1287  /**
1288   * Are transactions supported? If not, invoking the method
1289   * <code>commit</code> is a noop and the
1290   * isolation level is TRANSACTION_NONE.
1291   *
1292   * @return <code>true</code> if transactions are supported; <code>false</code> otherwise
1293   * @exception SQLException if a database access error occurs
1294   */

1295  public boolean supportsTransactions() throws SQLException {
1296    return DatabaseProperties.supportsTransactions;
1297  }
1298
1299  /**
1300   * Does this database support the given transaction isolation level?
1301   *
1302   * @param level the values are defined in <code>java.sql.Connection</code>
1303   * @return <code>true</code> if so; <code>false</code> otherwise
1304   * @exception SQLException if a database access error occurs
1305   * @see Connection
1306   */

1307  public boolean supportsTransactionIsolationLevel(int level) throws
1308      SQLException {
1309    return DatabaseProperties.supportsTransactionIsolationLevel(level);
1310  }
1311
1312  /**
1313   * Are both data definition and data manipulation statements
1314   * within a transaction supported?
1315   *
1316   * @return <code>true</code> if so; <code>false</code> otherwise
1317   * @exception SQLException if a database access error occurs
1318   */

1319  public boolean supportsDataDefinitionAndDataManipulationTransactions() throws
1320      SQLException {
1321    return DatabaseProperties.
1322        supportsDataDefinitionAndDataManipulationTransactions;
1323  }
1324
1325  /**
1326   * Are only data manipulation statements within a transaction
1327   * supported?
1328   *
1329   * @return <code>true</code> if so; <code>false</code> otherwise
1330   * @exception SQLException if a database access error occurs
1331   */

1332  public boolean supportsDataManipulationTransactionsOnly() throws SQLException {
1333    return DatabaseProperties.supportsDataManipulationTransactionsOnly;
1334  }
1335
1336  /**
1337   * Does a data definition statement within a transaction force the
1338   * transaction to commit?
1339   *
1340   * @return <code>true</code> if so; <code>false</code> otherwise
1341   * @exception SQLException if a database access error occurs
1342   */

1343  public boolean dataDefinitionCausesTransactionCommit() throws SQLException {
1344    return DatabaseProperties.dataDefinitionCausesTransactionCommit;
1345  }
1346
1347  /**
1348   * Is a data definition statement within a transaction ignored?
1349   *
1350   * @return <code>true</code> if so; <code>false</code> otherwise
1351   * @exception SQLException if a database access error occurs
1352   */

1353  public boolean dataDefinitionIgnoredInTransactions() throws SQLException {
1354    return DatabaseProperties.dataDefinitionIgnoredInTransactions;
1355  }
1356
1357  /**
1358   * Gets a description of the stored procedures available in a
1359   * catalog.
1360   *
1361   * <P>Only procedure descriptions matching the schema and
1362   * procedure name criteria are returned. They are ordered by
1363   * PROCEDURE_SCHEM, and PROCEDURE_NAME.
1364   *
1365   * <P>Each procedure description has the the following columns:
1366   * <OL>
1367   * <LI><B>PROCEDURE_CAT</B> String => procedure catalog (may be null)
1368   * <LI><B>PROCEDURE_SCHEM</B> String => procedure schema (may be null)
1369   * <LI><B>PROCEDURE_NAME</B> String => procedure name
1370   * <LI> reserved for future use
1371   * <LI> reserved for future use
1372   * <LI> reserved for future use
1373   * <LI><B>REMARKS</B> String => explanatory comment on the procedure
1374   * <LI><B>PROCEDURE_TYPE</B> short => kind of procedure:
1375   * <UL>
1376   * <LI> procedureResultUnknown - May return a result
1377   * <LI> procedureNoResult - Does not return a result
1378   * <LI> procedureReturnsResult - Returns a result
1379   * </UL>
1380   * </OL>
1381   *
1382   * @param catalog a catalog name; "" retrieves those without a
1383   * catalog; null means drop catalog name from the selection criteria
1384   * @param schemaPattern a schema name pattern; "" retrieves those
1385   * without a schema
1386   * @param procedureNamePattern a procedure name pattern
1387   * @return <code>ResultSet</code> - each row is a procedure description
1388   * @exception SQLException if a database access error occurs
1389   * @see #getSearchStringEscape
1390   * @ todo
1391   */

1392
1393  public ResultSet getProcedures(String JavaDoc catalog, String JavaDoc schemaPattern,
1394                                 String JavaDoc procedureNamePattern) throws
1395      SQLException {
1396    String JavaDoc query = DatabaseProperties.getProceduresQuery(catalog, schemaPattern,
1397        procedureNamePattern);
1398    return getTempResultSetForProcedures(query);
1399  }
1400
1401  /**
1402   * A possible value for column <code>PROCEDURE_TYPE</code> in the
1403   * <code>ResultSet</code> object returned by the method
1404   * <code>getProcedures</code>.
1405   * <p> Indicates that it is not known whether the procedure returns
1406   * a result.
1407   */

1408  /**
1409   * A possible value for column <code>PROCEDURE_TYPE</code> in the
1410   * <code>ResultSet</code> object returned by the method
1411   * <code>getProcedures</code>.
1412   * <p> Indicates that the procedure does not return
1413   * a result.
1414   */

1415  /**
1416   * A possible value for column <code>PROCEDURE_TYPE</code> in the
1417   * <code>ResultSet</code> object returned by the method
1418   * <code>getProcedures</code>.
1419   * <p> Indicates that the procedure returns
1420   * a result.
1421   */

1422  /**
1423   * Gets a description of a catalog's stored procedure parameters
1424   * and result columns.
1425   *
1426   * <P>Only descriptions matching the schema, procedure and
1427   * parameter name criteria are returned. They are ordered by
1428   * PROCEDURE_SCHEM and PROCEDURE_NAME. Within this, the return value,
1429   * if any, is first. Next are the parameter descriptions in call
1430   * order. The column descriptions follow in column number order.
1431   *
1432   * <P>Each row in the <code>ResultSet</code> is a parameter description or
1433   * column description with the following fields:
1434   * <OL>
1435   * <LI><B>PROCEDURE_CAT</B> String => procedure catalog (may be null)
1436   * <LI><B>PROCEDURE_SCHEM</B> String => procedure schema (may be null)
1437   * <LI><B>PROCEDURE_NAME</B> String => procedure name
1438   * <LI><B>COLUMN_NAME</B> String => column/parameter name
1439   * <LI><B>COLUMN_TYPE</B> Short => kind of column/parameter:
1440   * <UL>
1441   * <LI> procedureColumnUnknown - nobody knows
1442   * <LI> procedureColumnIn - IN parameter
1443   * <LI> procedureColumnInOut - INOUT parameter
1444   * <LI> procedureColumnOut - OUT parameter
1445   * <LI> procedureColumnReturn - procedure return value
1446   * <LI> procedureColumnResult - result column in <code>ResultSet</code>
1447   * </UL>
1448   * <LI><B>DATA_TYPE</B> short => SQL type from java.sql.Types
1449   * <LI><B>TYPE_NAME</B> String => SQL type name, for a UDT type the
1450   * type name is fully qualified
1451   * <LI><B>PRECISION</B> int => precision
1452   * <LI><B>LENGTH</B> int => length in bytes of data
1453   * <LI><B>SCALE</B> short => scale
1454   * <LI><B>RADIX</B> short => radix
1455   * <LI><B>NULLABLE</B> short => can it contain NULL?
1456   * <UL>
1457   * <LI> procedureNoNulls - does not allow NULL values
1458   * <LI> procedureNullable - allows NULL values
1459   * <LI> procedureNullableUnknown - nullability unknown
1460   * </UL>
1461   * <LI><B>REMARKS</B> String => comment describing parameter/column
1462   * </OL>
1463   *
1464   * <P><B>Note:</B> Some databases may not return the column
1465   * descriptions for a procedure. Additional columns beyond
1466   * REMARKS can be defined by the database.
1467   *
1468   * @param catalog a catalog name; "" retrieves those without a
1469   * catalog; null means drop catalog name from the selection criteria
1470   * @param schemaPattern a schema name pattern; "" retrieves those
1471   * without a schema
1472   * @param procedureNamePattern a procedure name pattern
1473   * @param columnNamePattern a column name pattern
1474   * @return <code>ResultSet</code> - each row describes a stored procedure parameter or
1475   * column
1476   * @exception SQLException if a database access error occurs
1477   * @see #getSearchStringEscape
1478   * @todo procedureColumns
1479   */

1480
1481  public ResultSet getProcedureColumns(String JavaDoc catalog, String JavaDoc schemaPattern,
1482                                       String JavaDoc procedureNamePattern,
1483                                       String JavaDoc columnNamePattern) throws
1484      SQLException {
1485    String JavaDoc query = DatabaseProperties.getProcedureColumnsQuery(catalog,
1486        schemaPattern, procedureNamePattern, columnNamePattern);
1487    return getTempResultSetForProcedureColumns(query);
1488  }
1489
1490  /**
1491   * Indicates that type of the column is unknown.
1492   * A possible value for the column
1493   * <code>COLUMN_TYPE</code>
1494   * in the <code>ResultSet</code>
1495   * returned by the method <code>getProcedureColumns</code>.
1496   */

1497  /**
1498   * Indicates that the column stores IN parameters.
1499   * A possible value for the column
1500   * <code>COLUMN_TYPE</code>
1501   * in the <code>ResultSet</code>
1502   * returned by the method <code>getProcedureColumns</code>.
1503   */

1504  /**
1505   * Indicates that the column stores INOUT parameters.
1506   * A possible value for the column
1507   * <code>COLUMN_TYPE</code>
1508   * in the <code>ResultSet</code>
1509   * returned by the method <code>getProcedureColumns</code>.
1510   */

1511  /**
1512   * Indicates that the column stores OUT parameters.
1513   * A possible value for the column
1514   * <code>COLUMN_TYPE</code>
1515   * in the <code>ResultSet</code>
1516   * returned by the method <code>getProcedureColumns</code>.
1517   */

1518  /**
1519   * Indicates that the column stores return values.
1520   * A possible value for the column
1521   * <code>COLUMN_TYPE</code>
1522   * in the <code>ResultSet</code>
1523   * returned by the method <code>getProcedureColumns</code>.
1524   */

1525  /**
1526   * Indicates that the column stores results.
1527   * A possible value for the column
1528   * <code>COLUMN_TYPE</code>
1529   * in the <code>ResultSet</code>
1530   * returned by the method <code>getProcedureColumns</code>.
1531   */

1532  /**
1533   * Indicates that <code>NULL</code> values are not allowed.
1534   * A possible value for the column
1535   * <code>NULLABLE</code>
1536   * in the <code>ResultSet</code>
1537   * returned by the method <code>getProcedureColumns</code>.
1538   */

1539  /**
1540   * Indicates that <code>NULL</code> values are allowed.
1541   * A possible value for the column
1542   * <code>NULLABLE</code>
1543   * in the <code>ResultSet</code>
1544   * returned by the method <code>getProcedureColumns</code>.
1545   */

1546  /**
1547   * Indicates that whether <code>NULL</code> values are allowed
1548   * is unknown.
1549   * A possible value for the column
1550   * <code>NULLABLE</code>
1551   * in the <code>ResultSet</code>
1552   * returned by the method <code>getProcedureColumns</code>.
1553   */

1554  /**
1555   * Gets a description of tables available in a catalog.
1556   *
1557   * <P>Only table descriptions matching the catalog, schema, table
1558   * name and type criteria are returned. They are ordered by
1559   * TABLE_TYPE, TABLE_SCHEM and TABLE_NAME.
1560   *
1561   * <P>Each table description has the following columns:
1562   * <OL>
1563   * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
1564   * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
1565   * <LI><B>TABLE_NAME</B> String => table name
1566   * <LI><B>TABLE_TYPE</B> String => table type. Typical types are "TABLE",
1567   * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
1568   * "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
1569   * <LI><B>REMARKS</B> String => explanatory comment on the table
1570   * </OL>
1571   *
1572   * <P><B>Note:</B> Some databases may not return information for
1573   * all tables.
1574   *
1575   * @param catalog a catalog name; "" retrieves those without a
1576   * catalog; null means drop catalog name from the selection criteria
1577   * @param schemaPattern a schema name pattern; "" retrieves those
1578   * without a schema
1579   * @param tableNamePattern a table name pattern
1580   * @param types a list of table types to include; null returns all types
1581   * @return <code>ResultSet</code> - each row is a table description
1582   * @exception SQLException if a database access error occurs
1583   * @see #getSearchStringEscape
1584   * @ todo
1585   */

1586  public ResultSet getTables(String JavaDoc catalog, String JavaDoc schemaPattern,
1587                             String JavaDoc tableNamePattern, String JavaDoc types[]) throws
1588      SQLException {
1589    String JavaDoc query = DatabaseProperties.getTablesQuery(catalog,
1590        schemaPattern, tableNamePattern, types);
1591    return getTempResultSetForTables(query);
1592  }
1593
1594  /**
1595   * Gets the schema names available in this database. The results
1596   * are ordered by schema name.
1597   *
1598   * <P>The schema column is:
1599   * <OL>
1600   * <LI><B>TABLE_SCHEM</B> String => schema name
1601   * </OL>
1602   *
1603       * @return <code>ResultSet</code> - each row has a single String column that is a
1604   * schema name
1605   * @exception SQLException if a database access error occurs
1606   * @ todo
1607   */

1608
1609  public ResultSet getSchemas() throws SQLException {
1610    String JavaDoc query = DatabaseProperties.getSchemasQuery();
1611    return getTempResultSetForSchemas(query);
1612  }
1613
1614  /**
1615   * Gets the catalog names available in this database. The results
1616   * are ordered by catalog name.
1617   *
1618   * <P>The catalog column is:
1619   * <OL>
1620   * <LI><B>TABLE_CAT</B> String => catalog name
1621   * </OL>
1622   *
1623       * @return <code>ResultSet</code> - each row has a single String column that is a
1624   * catalog name
1625   * @exception SQLException if a database access error occurs
1626   * @ todo
1627   */

1628
1629  public ResultSet getCatalogs() throws SQLException {
1630    String JavaDoc query = DatabaseProperties.getCatalogsQuery();
1631    return getTempResultSetForCatalogs(query);
1632  }
1633
1634  /**
1635   * Gets the table types available in this database. The results
1636   * are ordered by table type.
1637   *
1638   * <P>The table type is:
1639   * <OL>
1640   * <LI><B>TABLE_TYPE</B> String => table type. Typical types are "TABLE",
1641   * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
1642   * "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
1643   * </OL>
1644   *
1645       * @return <code>ResultSet</code> - each row has a single String column that is a
1646   * table type
1647   * @exception SQLException if a database access error occurs
1648   * @ todo Tabletypes
1649   */

1650
1651  public ResultSet getTableTypes() throws SQLException {
1652    try {
1653      String JavaDoc[] columnNames = new String JavaDoc[] {
1654          "TABLE_TYPE"};
1655      Object JavaDoc[][] metaData = new Object JavaDoc[1][20];
1656      metaData[0][0] = null;
1657      metaData[0][1] = null;
1658      metaData[0][2] = null;
1659      metaData[0][3] = "TABLE_TYPE";
1660      metaData[0][4] = new Integer JavaDoc(Types.VARCHAR);
1661      metaData[0][5] = "TABLE_TYPE";
1662      metaData[0][6] = new Integer JavaDoc(Utilities.getPrecision(Types.VARCHAR));
1663      metaData[0][7] = null;
1664      metaData[0][8] = new Integer JavaDoc("TABLE_TYPE".length());
1665      metaData[0][9] = "java.lang.String";
1666      metaData[0][10] = Utilities.getCorrespondingJavaClassesOfSqlTypes(Types.
1667          VARCHAR);
1668      metaData[0][11] = Utilities.getBooleanValue(false);
1669      metaData[0][12] = Utilities.getBooleanValue(false);
1670      metaData[0][13] = Utilities.getBooleanValue(false);
1671      metaData[0][14] = Utilities.getBooleanValue(false);
1672      metaData[0][15] = Utilities.getBooleanValue(false);
1673      metaData[0][16] = Utilities.getBooleanValue(true);
1674      metaData[0][17] = Utilities.getBooleanValue(true);
1675      metaData[0][18] = Utilities.getBooleanValue(true);
1676      metaData[0][19] = new Integer JavaDoc(ResultSetMetaData.columnNullableUnknown);
1677      TempResultSetMetaData resultSetMetaData = new TempResultSetMetaData(
1678          metaData);
1679      String JavaDoc[] tableTypes = DatabaseProperties.getTableTypes();
1680      int length = tableTypes.length;
1681      Object JavaDoc[][] values = new Object JavaDoc[length][1];
1682      for (int i = 0; i < length; i++)
1683        values[i][0] = tableTypes[i];
1684      TempResultSet resultSet = new TempResultSet(values, columnNames);
1685      resultSet.setConnection(systemConnection);
1686      resultSet.setMetaData(resultSetMetaData);
1687      return resultSet;
1688    }
1689    catch (DException de) {
1690      throw de.getSqlException(systemConnection.getLocale());
1691    }
1692  }
1693
1694  /**
1695   * Gets a description of table columns available in
1696   * the specified catalog.
1697   *
1698   * <P>Only column descriptions matching the catalog, schema, table
1699   * and column name criteria are returned. They are ordered by
1700   * TABLE_SCHEM, TABLE_NAME and ORDINAL_POSITION.
1701   *
1702   * <P>Each column description has the following columns:
1703   * <OL>
1704   * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
1705   * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
1706   * <LI><B>TABLE_NAME</B> String => table name
1707   * <LI><B>COLUMN_NAME</B> String => column name
1708   * <LI><B>DATA_TYPE</B> short => SQL type from java.sql.Types
1709   * <LI><B>TYPE_NAME</B> String => Data source dependent type name,
1710   * for a UDT the type name is fully qualified
1711   * <LI><B>COLUMN_SIZE</B> int => column size. For char or date
1712   * types this is the maximum number of characters, for numeric or
1713   * decimal types this is precision.
1714   * <LI><B>BUFFER_LENGTH</B> is not used.
1715   * <LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits
1716   * <LI><B>NUM_PREC_RADIX</B> int => Radix (typically either 10 or 2)
1717   * <LI><B>NULLABLE</B> int => is NULL allowed?
1718   * <UL>
1719   * <LI> columnNoNulls - might not allow NULL values
1720   * <LI> columnNullable - definitely allows NULL values
1721   * <LI> columnNullableUnknown - nullability unknown
1722   * </UL>
1723   * <LI><B>REMARKS</B> String => comment describing column (may be null)
1724   * <LI><B>COLUMN_DEF</B> String => default value (may be null)
1725   * <LI><B>SQL_DATA_TYPE</B> int => unused
1726   * <LI><B>SQL_DATETIME_SUB</B> int => unused
1727   * <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the
1728   * maximum number of bytes in the column
1729   * <LI><B>ORDINAL_POSITION</B> int => index of column in table
1730   * (starting at 1)
1731   * <LI><B>IS_NULLABLE</B> String => "NO" means column definitely
1732   * does not allow NULL values; "YES" means the column might
1733   * allow NULL values. An empty string means nobody knows.
1734   * </OL>
1735   *
1736   * @param catalog a catalog name; "" retrieves those without a
1737   * catalog; null means drop catalog name from the selection criteria
1738   * @param schemaPattern a schema name pattern; "" retrieves those
1739   * without a schema
1740   * @param tableNamePattern a table name pattern
1741   * @param columnNamePattern a column name pattern
1742   * @return <code>ResultSet</code> - each row is a column description
1743   * @exception SQLException if a database access error occurs
1744   * @see #getSearchStringEscape
1745   * @todo
1746   */

1747
1748  public ResultSet getColumns(String JavaDoc catalog, String JavaDoc schemaPattern,
1749                              String JavaDoc tableNamePattern, String JavaDoc columnNamePattern) throws
1750      SQLException {
1751    String JavaDoc query = DatabaseProperties.getColumnsQuery(catalog, schemaPattern,
1752        tableNamePattern, columnNamePattern);
1753    return getTempResultSetForColumns(query);
1754  }
1755
1756  /**
1757   * Indicates that the column might not allow NULL values.
1758   * A possible value for the column
1759   * <code>NULLABLE</code>
1760   * in the <code>ResultSet</code> returned by the method
1761   * <code>getColumns</code>.
1762   *
1763   int columnNoNulls = 0;
1764   /**
1765    * Indicates that the column definitely allows <code>NULL</code> values.
1766    * A possible value for the column
1767    * <code>NULLABLE</code>
1768    * in the <code>ResultSet</code> returned by the method
1769    * <code>getColumns</code>.
1770    *
1771    int columnNullable = 1;
1772    /**
1773     * Indicates that the nullability of columns is unknown.
1774     * A possible value for the column
1775     * <code>NULLABLE</code>
1776     * in the <code>ResultSet</code> returned by the method
1777     * <code>getColumns</code>.
1778     *
1779     int columnNullableUnknown = 2;
1780     /**
1781      * Gets a description of the access rights for a table's columns.
1782      *
1783      * <P>Only privileges matching the column name criteria are
1784      * returned. They are ordered by COLUMN_NAME and PRIVILEGE.
1785      *
1786      * <P>Each privilige description has the following columns:
1787      * <OL>
1788      * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
1789      * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
1790      * <LI><B>TABLE_NAME</B> String => table name
1791      * <LI><B>COLUMN_NAME</B> String => column name
1792      * <LI><B>GRANTOR</B> => grantor of access (may be null)
1793      * <LI><B>GRANTEE</B> String => grantee of access
1794      * <LI><B>PRIVILEGE</B> String => name of access (SELECT,
1795      * INSERT, UPDATE, REFRENCES, ...)
1796      * <LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
1797      * to grant to others; "NO" if not; null if unknown
1798      * </OL>
1799      *
1800      * @param catalog a catalog name; "" retrieves those without a
1801      * catalog; null means drop catalog name from the selection criteria
1802      * @param schema a schema name; "" retrieves those without a schema
1803      * @param table a table name
1804      * @param columnNamePattern a column name pattern
1805          * @return <code>ResultSet</code> - each row is a column privilege description
1806      * @exception SQLException if a database access error occurs
1807      * @see #getSearchStringEscape
1808      * @ todo
1809      */

1810
1811     public ResultSet getColumnPrivileges(String JavaDoc catalog, String JavaDoc schema,
1812                                          String JavaDoc table,
1813                                          String JavaDoc columnNamePattern) throws
1814         SQLException {
1815       String JavaDoc query = DatabaseProperties.getColumnPrivilegesQuery(catalog,
1816           schema, table, columnNamePattern);
1817       Statement statement = systemConnection.createStatement();
1818       return statement.executeQuery(query);
1819     }
1820
1821  /**
1822   * Gets a description of the access rights for each table available
1823   * in a catalog. Note that a table privilege applies to one or
1824   * more columns in the table. It would be wrong to assume that
1825   * this priviledge applies to all columns (this may be true for
1826   * some systems but is not true for all.)
1827   *
1828   * <P>Only privileges matching the schema and table name
1829   * criteria are returned. They are ordered by TABLE_SCHEM,
1830   * TABLE_NAME, and PRIVILEGE.
1831   *
1832   * <P>Each privilige description has the following columns:
1833   * <OL>
1834   * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
1835   * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
1836   * <LI><B>TABLE_NAME</B> String => table name
1837   * <LI><B>GRANTOR</B> => grantor of access (may be null)
1838   * <LI><B>GRANTEE</B> String => grantee of access
1839   * <LI><B>PRIVILEGE</B> String => name of access (SELECT,
1840   * INSERT, UPDATE, REFRENCES, ...)
1841   * <LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
1842   * to grant to others; "NO" if not; null if unknown
1843   * </OL>
1844   *
1845   * @param catalog a catalog name; "" retrieves those without a
1846   * catalog; null means drop catalog name from the selection criteria
1847   * @param schemaPattern a schema name pattern; "" retrieves those
1848   * without a schema
1849   * @param tableNamePattern a table name pattern
1850   * @return <code>ResultSet</code> - each row is a table privilege description
1851   * @exception SQLException if a database access error occurs
1852   * @see #getSearchStringEscape
1853   */

1854
1855  public ResultSet getTablePrivileges(String JavaDoc catalog, String JavaDoc schemaPattern,
1856                                      String JavaDoc tableNamePattern) throws
1857      SQLException {
1858    String JavaDoc query = DatabaseProperties.getTablePrivilegesQuery(catalog,
1859        schemaPattern, tableNamePattern);
1860    Statement statement = systemConnection.createStatement();
1861    return statement.executeQuery(query);
1862  }
1863
1864  /**
1865   * Gets a description of a table's optimal set of columns that
1866   * uniquely identifies a row. They are ordered by SCOPE.
1867   *
1868   * <P>Each column description has the following columns:
1869   * <OL>
1870   * <LI><B>SCOPE</B> short => actual scope of result
1871   * <UL>
1872   * <LI> bestRowTemporary - very temporary, while using row
1873   * <LI> bestRowTransaction - valid for remainder of current transaction
1874   * <LI> bestRowSession - valid for remainder of current session
1875   * </UL>
1876   * <LI><B>COLUMN_NAME</B> String => column name
1877   * <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
1878   * <LI><B>TYPE_NAME</B> String => Data source dependent type name,
1879   * for a UDT the type name is fully qualified
1880   * <LI><B>COLUMN_SIZE</B> int => precision
1881   * <LI><B>BUFFER_LENGTH</B> int => not used
1882   * <LI><B>DECIMAL_DIGITS</B> short => scale
1883   * <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column
1884   * like an Oracle ROWID
1885   * <UL>
1886   * <LI> bestRowUnknown - may or may not be pseudo column
1887   * <LI> bestRowNotPseudo - is NOT a pseudo column
1888   * <LI> bestRowPseudo - is a pseudo column
1889   * </UL>
1890   * </OL>
1891   *
1892   * @param catalog a catalog name; "" retrieves those without a
1893   * catalog; null means drop catalog name from the selection criteria
1894   * @param schema a schema name; "" retrieves those without a schema
1895   * @param table a table name
1896   * @param scope the scope of interest; use same values as SCOPE
1897   * @param nullable include columns that are nullable?
1898   * @return <code>ResultSet</code> - each row is a column description
1899   * @exception SQLException if a database access error occurs
1900   * @todo
1901   */

1902
1903  public ResultSet getBestRowIdentifier(String JavaDoc catalog, String JavaDoc schema,
1904                                        String JavaDoc table, int scope,
1905                                        boolean nullable) throws SQLException {
1906    String JavaDoc query = DatabaseProperties.getBestRowIdentifierQuery(catalog, schema,
1907        table, scope, nullable);
1908    if (query == null) {
1909      DException dex = new DException("DSE16",
1910                                      new Object JavaDoc[] {"getBestRowIdentifier"});
1911    }
1912    return getTempResultSetForBestRowIdentifier(query);
1913  }
1914
1915  /**
1916   * Indicates that the scope of the best row identifier is
1917   * very temporary, lasting only while the
1918   * row is being used.
1919   * A possible value for the column
1920   * <code>SCOPE</code>
1921   * in the <code>ResultSet</code> object
1922   * returned by the method <code>getBestRowIdentifier</code>.
1923   *
1924      int bestRowTemporary = 0;
1925       /**
1926    * Indicates that the scope of the best row identifier is
1927    * the remainder of the current transaction.
1928    * A possible value for the column
1929    * <code>SCOPE</code>
1930    * in the <code>ResultSet</code> object
1931    * returned by the method <code>getBestRowIdentifier</code>.
1932    *
1933       int bestRowTransaction = 1;
1934        /**
1935     * Indicates that the scope of the best row identifier is
1936     * the remainder of the current session.
1937     * A possible value for the column
1938     * <code>SCOPE</code>
1939     * in the <code>ResultSet</code> object
1940     * returned by the method <code>getBestRowIdentifier</code>.
1941     *
1942        int bestRowSession = 2;
1943         /**
1944          * Indicates that the best row identifier may or may not be a pseudo column.
1945      * A possible value for the column
1946      * <code>PSEUDO_COLUMN</code>
1947      * in the <code>ResultSet</code> object
1948      * returned by the method <code>getBestRowIdentifier</code>.
1949      *
1950         int bestRowUnknown = 0;
1951          /**
1952       * Indicates that the best row identifier is NOT a pseudo column.
1953       * A possible value for the column
1954       * <code>PSEUDO_COLUMN</code>
1955       * in the <code>ResultSet</code> object
1956       * returned by the method <code>getBestRowIdentifier</code>.
1957       *
1958          int bestRowNotPseudo = 1;
1959           /**
1960        * Indicates that the best row identifier is a pseudo column.
1961        * A possible value for the column
1962        * <code>PSEUDO_COLUMN</code>
1963        * in the <code>ResultSet</code> object
1964        * returned by the method <code>getBestRowIdentifier</code>.
1965        *
1966           int bestRowPseudo = 2;
1967            /**
1968         * Gets a description of a table's columns that are automatically
1969         * updated when any value in a row is updated. They are
1970         * unordered.
1971         *
1972         * <P>Each column description has the following columns:
1973         * <OL>
1974         * <LI><B>SCOPE</B> short => is not used
1975         * <LI><B>COLUMN_NAME</B> String => column name
1976         * <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
1977         * <LI><B>TYPE_NAME</B> String => Data source dependent type name
1978         * <LI><B>COLUMN_SIZE</B> int => precision
1979         * <LI><B>BUFFER_LENGTH</B> int => length of column value in bytes
1980         * <LI><B>DECIMAL_DIGITS</B> short => scale
1981         * <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column
1982         * like an Oracle ROWID
1983         * <UL>
1984         * <LI> versionColumnUnknown - may or may not be pseudo column
1985         * <LI> versionColumnNotPseudo - is NOT a pseudo column
1986         * <LI> versionColumnPseudo - is a pseudo column
1987         * </UL>
1988         * </OL>
1989         *
1990         * @param catalog a catalog name; "" retrieves those without a
1991         * catalog; null means drop catalog name from the selection criteria
1992         * @param schema a schema name; "" retrieves those without a schema
1993         * @param table a table name
1994         * @return <code>ResultSet</code> - each row is a column description
1995         * @exception SQLException if a database access error occurs
1996         * @todo
1997         */

1998
1999        public ResultSet getVersionColumns(String JavaDoc catalog, String JavaDoc schema,
2000                                           String JavaDoc table) throws SQLException {
2001          String JavaDoc query = DatabaseProperties.getVersionColumnsQuery(catalog,
2002              schema, table);
2003          if (query == null) {
2004            DException dex = new DException("DSE16",
2005                                            new Object JavaDoc[] {"getVersionColumns"});
2006          }
2007          return getTempResultSetForVersionColumns(query);
2008        }
2009
2010  /**
2011   * Indicates that this version column may or may not be a pseudo column.
2012   * A possible value for the column
2013   * <code>PSEUDO_COLUMN</code>
2014   * in the <code>ResultSet</code> object
2015   * returned by the method <code>getVersionColumns</code>.
2016   *
2017      int versionColumnUnknown = 0;
2018       /**
2019    * Indicates that this version column is NOT a pseudo column.
2020    * A possible value for the column
2021    * <code>PSEUDO_COLUMN</code>
2022    * in the <code>ResultSet</code> object
2023    * returned by the method <code>getVersionColumns</code>.
2024    *
2025       int versionColumnNotPseudo = 1;
2026        /**
2027     * Indicates that this version column is a pseudo column.
2028     * A possible value for the column
2029     * <code>PSEUDO_COLUMN</code>
2030     * in the <code>ResultSet</code> object
2031     * returned by the method <code>getVersionColumns</code>.
2032     *
2033        int versionColumnPseudo = 2;
2034         /**
2035      * Gets a description of a table's primary key columns. They
2036      * are ordered by COLUMN_NAME.
2037      *
2038      * <P>Each primary key column description has the following columns:
2039      * <OL>
2040      * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
2041      * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
2042      * <LI><B>TABLE_NAME</B> String => table name
2043      * <LI><B>COLUMN_NAME</B> String => column name
2044      * <LI><B>KEY_SEQ</B> short => sequence number within primary key
2045      * <LI><B>PK_NAME</B> String => primary key name (may be null)
2046      * </OL>
2047      *
2048      * @param catalog a catalog name; "" retrieves those without a
2049      * catalog; null means drop catalog name from the selection criteria
2050      * @param schema a schema name; "" retrieves those
2051      * without a schema
2052      * @param table a table name
2053          * @return <code>ResultSet</code> - each row is a primary key column description
2054      * @exception SQLException if a database access error occurs
2055      * @ todo
2056      */

2057
2058     public ResultSet getPrimaryKeys(String JavaDoc catalog, String JavaDoc schema,
2059                                     String JavaDoc table) throws SQLException {
2060       String JavaDoc query = DatabaseProperties.getPrimaryKeysQuery(catalog, schema,
2061           table);
2062       return getTempResultSetForPrimaryKeys(query);
2063     }
2064
2065  /**
2066   * Gets a description of the primary key columns that are
2067   * referenced by a table's foreign key columns (the primary keys
2068   * imported by a table). They are ordered by PKTABLE_CAT,
2069   * PKTABLE_SCHEM, PKTABLE_NAME, and KEY_SEQ.
2070   *
2071   * <P>Each primary key column description has the following columns:
2072   * <OL>
2073   * <LI><B>PKTABLE_CAT</B> String => primary key table catalog
2074   * being imported (may be null)
2075   * <LI><B>PKTABLE_SCHEM</B> String => primary key table schema
2076   * being imported (may be null)
2077   * <LI><B>PKTABLE_NAME</B> String => primary key table name
2078   * being imported
2079   * <LI><B>PKCOLUMN_NAME</B> String => primary key column name
2080   * being imported
2081   * <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
2082   * <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
2083   * <LI><B>FKTABLE_NAME</B> String => foreign key table name
2084   * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
2085   * <LI><B>KEY_SEQ</B> short => sequence number within foreign key
2086   * <LI><B>UPDATE_RULE</B> short => What happens to
2087   * foreign key when primary is updated:
2088   * <UL>
2089   * <LI> importedNoAction - do not allow update of primary
2090   * key if it has been imported
2091   * <LI> importedKeyCascade - change imported key to agree
2092   * with primary key update
2093   * <LI> importedKeySetNull - change imported key to NULL if
2094   * its primary key has been updated
2095   * <LI> importedKeySetDefault - change imported key to default values
2096   * if its primary key has been updated
2097   * <LI> importedKeyRestrict - same as importedKeyNoAction
2098   * (for ODBC 2.x compatibility)
2099   * </UL>
2100   * <LI><B>DELETE_RULE</B> short => What happens to
2101   * the foreign key when primary is deleted.
2102   * <UL>
2103   * <LI> importedKeyNoAction - do not allow delete of primary
2104   * key if it has been imported
2105   * <LI> importedKeyCascade - delete rows that import a deleted key
2106   * <LI> importedKeySetNull - change imported key to NULL if
2107   * its primary key has been deleted
2108   * <LI> importedKeyRestrict - same as importedKeyNoAction
2109   * (for ODBC 2.x compatibility)
2110   * <LI> importedKeySetDefault - change imported key to default if
2111   * its primary key has been deleted
2112   * </UL>
2113   * <LI><B>FK_NAME</B> String => foreign key name (may be null)
2114   * <LI><B>PK_NAME</B> String => primary key name (may be null)
2115   * <LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key
2116   * constraints be deferred until commit
2117   * <UL>
2118   * <LI> importedKeyInitiallyDeferred - see SQL92 for definition
2119   * <LI> importedKeyInitiallyImmediate - see SQL92 for definition
2120   * <LI> importedKeyNotDeferrable - see SQL92 for definition
2121   * </UL>
2122   * </OL>
2123   *
2124   * @param catalog a catalog name; "" retrieves those without a
2125   * catalog; null means drop catalog name from the selection criteria
2126   * @param schema a schema name; "" retrieves those
2127   * without a schema
2128   * @param table a table name
2129       * @return <code>ResultSet</code> - each row is a primary key column description
2130   * @exception SQLException if a database access error occurs
2131   * @see #getExportedKeys
2132   * @ todo
2133   */

2134
2135  public ResultSet getImportedKeys(String JavaDoc catalog, String JavaDoc schema, String JavaDoc table) throws
2136      SQLException {
2137    String JavaDoc query = DatabaseProperties.getImportedKeysQuery(catalog, schema,
2138        table);
2139    return getTempResultSetForImportedKeys(query);
2140  }
2141
2142  /**
2143   * A possible value for the columns <code>UPDATE_RULE</code>
2144   * and <code>DELETE_RULE</code> in the
2145   * <code>ResultSet</code> objects returned by the methods
2146   * <code>getImportedKeys</code>, <code>getExportedKeys</code>,
2147   * and <code>getCrossReference</code>.
2148   * <P>For the column <code>UPDATE_RULE</code>,
2149   * it indicates that
2150   * when the primary key is updated, the foreign key (imported key)
2151   * is changed to agree with it.
2152   * <P>For the column <code>DELETE_RULE</code>,
2153   * it indicates that
2154   * when the primary key is deleted, rows that imported that key
2155   * are deleted.
2156   *
2157      int importedKeyCascade = 0;
2158       /**
2159    * A possible value for the columns <code>UPDATE_RULE</code>
2160    * and <code>DELETE_RULE</code> in the
2161    * <code>ResultSet</code> objects returned by the methods
2162    * <code>getImportedKeys</code>, <code>getExportedKeys</code>,
2163    * and <code>getCrossReference</code>.
2164    * <P>For the column <code>UPDATE_RULE</code>, it indicates that
2165    * a primary key may not be updated if it has been imported by
2166    * another table as a foreign key.
2167    * <P>For the column <code>DELETE_RULE</code>, it indicates that
2168    * a primary key may not be deleted if it has been imported by
2169    * another table as a foreign key.
2170    *
2171       int importedKeyRestrict = 1;
2172        /**
2173     * A possible value for the columns <code>UPDATE_RULE</code>
2174     * and <code>DELETE_RULE</code> in the
2175     * <code>ResultSet</code> objects returned by the methods
2176     * <code>getImportedKeys</code>, <code>getExportedKeys</code>,
2177     * and <code>getCrossReference</code>.
2178     * <P>For the columns <code>UPDATE_RULE</code>
2179     * and <code>DELETE_RULE</code>,
2180     * it indicates that
2181         * when the primary key is updated or deleted, the foreign key (imported key)
2182     * is changed to <code>NULL</code>.
2183     *
2184        int importedKeySetNull = 2;
2185         /**
2186      * A possible value for the columns <code>UPDATE_RULE</code>
2187      * and <code>DELETE_RULE</code> in the
2188      * <code>ResultSet</code> objects returned by the methods
2189      * <code>getImportedKeys</code>, <code>getExportedKeys</code>,
2190      * and <code>getCrossReference</code>.
2191      * <P>For the columns <code>UPDATE_RULE</code>
2192      * and <code>DELETE_RULE</code>,
2193      * it indicates that
2194      * if the primary key has been imported, it cannot be updated or deleted.
2195      *
2196         int importedKeyNoAction = 3;
2197          /**
2198       * A possible value for the columns <code>UPDATE_RULE</code>
2199       * and <code>DELETE_RULE</code> in the
2200       * <code>ResultSet</code> objects returned by the methods
2201       * <code>getImportedKeys</code>, <code>getExportedKeys</code>,
2202       * and <code>getCrossReference</code>.
2203       * <P>For the columns <code>UPDATE_RULE</code>
2204       * and <code>DELETE_RULE</code>,
2205       * it indicates that
2206           * if the primary key is updated or deleted, the foreign key (imported key)
2207       * is set to the default value.
2208       *
2209          int importedKeySetDefault = 4;
2210           /**
2211        * A possible value for the column <code>DEFERRABILITY</code>
2212        * in the
2213        * <code>ResultSet</code> objects returned by the methods
2214        * <code>getImportedKeys</code>, <code>getExportedKeys</code>,
2215        * and <code>getCrossReference</code>.
2216        * <P>Indicates deferrability. See SQL-92 for a definition.
2217        *
2218           int importedKeyInitiallyDeferred = 5;
2219            /**
2220         * A possible value for the column <code>DEFERRABILITY</code>
2221         * in the
2222         * <code>ResultSet</code> objects returned by the methods
2223         * <code>getImportedKeys</code>, <code>getExportedKeys</code>,
2224         * and <code>getCrossReference</code>.
2225         * <P>Indicates deferrability. See SQL-92 for a definition.
2226         *
2227            int importedKeyInitiallyImmediate = 6;
2228             /**
2229          * A possible value for the column <code>DEFERRABILITY</code>
2230          * in the
2231          * <code>ResultSet</code> objects returned by the methods
2232          * <code>getImportedKeys</code>, <code>getExportedKeys</code>,
2233          * and <code>getCrossReference</code>.
2234          * <P>Indicates deferrability. See SQL-92 for a definition.
2235          *
2236             int importedKeyNotDeferrable = 7;
2237              /**
2238           * Gets a description of the foreign key columns that reference a
2239           * table's primary key columns (the foreign keys exported by a
2240           * table). They are ordered by FKTABLE_CAT, FKTABLE_SCHEM,
2241           * FKTABLE_NAME, and KEY_SEQ.
2242           *
2243           * <P>Each foreign key column description has the following columns:
2244           * <OL>
2245               * <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
2246               * <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
2247           * <LI><B>PKTABLE_NAME</B> String => primary key table name
2248           * <LI><B>PKCOLUMN_NAME</B> String => primary key column name
2249               * <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
2250           * being exported (may be null)
2251               * <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
2252           * being exported (may be null)
2253           * <LI><B>FKTABLE_NAME</B> String => foreign key table name
2254           * being exported
2255           * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
2256           * being exported
2257           * <LI><B>KEY_SEQ</B> short => sequence number within foreign key
2258           * <LI><B>UPDATE_RULE</B> short => What happens to
2259           * foreign key when primary is updated:
2260           * <UL>
2261           * <LI> importedNoAction - do not allow update of primary
2262           * key if it has been imported
2263           * <LI> importedKeyCascade - change imported key to agree
2264           * with primary key update
2265           * <LI> importedKeySetNull - change imported key to NULL if
2266           * its primary key has been updated
2267               * <LI> importedKeySetDefault - change imported key to default values
2268           * if its primary key has been updated
2269           * <LI> importedKeyRestrict - same as importedKeyNoAction
2270           * (for ODBC 2.x compatibility)
2271           * </UL>
2272           * <LI><B>DELETE_RULE</B> short => What happens to
2273           * the foreign key when primary is deleted.
2274           * <UL>
2275           * <LI> importedKeyNoAction - do not allow delete of primary
2276           * key if it has been imported
2277               * <LI> importedKeyCascade - delete rows that import a deleted key
2278           * <LI> importedKeySetNull - change imported key to NULL if
2279           * its primary key has been deleted
2280           * <LI> importedKeyRestrict - same as importedKeyNoAction
2281           * (for ODBC 2.x compatibility)
2282               * <LI> importedKeySetDefault - change imported key to default if
2283           * its primary key has been deleted
2284           * </UL>
2285           * <LI><B>FK_NAME</B> String => foreign key name (may be null)
2286           * <LI><B>PK_NAME</B> String => primary key name (may be null)
2287               * <LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key
2288           * constraints be deferred until commit
2289           * <UL>
2290           * <LI> importedKeyInitiallyDeferred - see SQL92 for definition
2291           * <LI> importedKeyInitiallyImmediate - see SQL92 for definition
2292           * <LI> importedKeyNotDeferrable - see SQL92 for definition
2293           * </UL>
2294           * </OL>
2295           *
2296           * @param catalog a catalog name; "" retrieves those without a
2297           * catalog; null means drop catalog name from the selection criteria
2298           * @param schema a schema name; "" retrieves those
2299           * without a schema
2300           * @param table a table name
2301               * @return <code>ResultSet</code> - each row is a foreign key column description
2302           * @exception SQLException if a database access error occurs
2303           * @see #getImportedKeys
2304           */

2305
2306          public ResultSet getExportedKeys(String JavaDoc catalog, String JavaDoc schema,
2307                                           String JavaDoc table) throws SQLException {
2308            String JavaDoc query = DatabaseProperties.getExportedKeysQuery(catalog,
2309                schema, table);
2310            return getTempResultSetForExportedKeys(query);
2311          }
2312
2313  /**
2314   * Gets a description of the foreign key columns in the foreign key
2315   * table that reference the primary key columns of the primary key
2316   * table (describe how one table imports another's key.) This
2317   * should normally return a single foreign key/primary key pair
2318   * (most tables only import a foreign key from a table once.) They
2319   * are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and
2320   * KEY_SEQ.
2321   *
2322   * <P>Each foreign key column description has the following columns:
2323   * <OL>
2324   * <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
2325   * <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
2326   * <LI><B>PKTABLE_NAME</B> String => primary key table name
2327   * <LI><B>PKCOLUMN_NAME</B> String => primary key column name
2328   * <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
2329   * being exported (may be null)
2330   * <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
2331   * being exported (may be null)
2332   * <LI><B>FKTABLE_NAME</B> String => foreign key table name
2333   * being exported
2334   * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
2335   * being exported
2336   * <LI><B>KEY_SEQ</B> short => sequence number within foreign key
2337   * <LI><B>UPDATE_RULE</B> short => What happens to
2338   * foreign key when primary is updated:
2339   * <UL>
2340   * <LI> importedNoAction - do not allow update of primary
2341   * key if it has been imported
2342   * <LI> importedKeyCascade - change imported key to agree
2343   * with primary key update
2344   * <LI> importedKeySetNull - change imported key to NULL if
2345   * its primary key has been updated
2346   * <LI> importedKeySetDefault - change imported key to default values
2347   * if its primary key has been updated
2348   * <LI> importedKeyRestrict - same as importedKeyNoAction
2349   * (for ODBC 2.x compatibility)
2350   * </UL>
2351   * <LI><B>DELETE_RULE</B> short => What happens to
2352   * the foreign key when primary is deleted.
2353   * <UL>
2354   * <LI> importedKeyNoAction - do not allow delete of primary
2355   * key if it has been imported
2356   * <LI> importedKeyCascade - delete rows that import a deleted key
2357   * <LI> importedKeySetNull - change imported key to NULL if
2358   * its primary key has been deleted
2359   * <LI> importedKeyRestrict - same as importedKeyNoAction
2360   * (for ODBC 2.x compatibility)
2361   * <LI> importedKeySetDefault - change imported key to default if
2362   * its primary key has been deleted
2363   * </UL>
2364   * <LI><B>FK_NAME</B> String => foreign key name (may be null)
2365   * <LI><B>PK_NAME</B> String => primary key name (may be null)
2366   * <LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key
2367   * constraints be deferred until commit
2368   * <UL>
2369   * <LI> importedKeyInitiallyDeferred - see SQL92 for definition
2370   * <LI> importedKeyInitiallyImmediate - see SQL92 for definition
2371   * <LI> importedKeyNotDeferrable - see SQL92 for definition
2372   * </UL>
2373   * </OL>
2374   *
2375   * @param primaryCatalog a catalog name; "" retrieves those without a
2376   * catalog; null means drop catalog name from the selection criteria
2377   * @param primarySchema a schema name; "" retrieves those
2378   * without a schema
2379   * @param primaryTable the table name that exports the key
2380   * @param foreignCatalog a catalog name; "" retrieves those without a
2381   * catalog; null means drop catalog name from the selection criteria
2382   * @param foreignSchema a schema name; "" retrieves those
2383   * without a schema
2384   * @param foreignTable the table name that imports the key
2385       * @return <code>ResultSet</code> - each row is a foreign key column description
2386   * @exception SQLException if a database access error occurs
2387   * @see #getImportedKeys
2388   * @t odo
2389   */

2390
2391  public ResultSet getCrossReference(String JavaDoc primaryCatalog,
2392                                     String JavaDoc primarySchema, String JavaDoc primaryTable,
2393                                     String JavaDoc foreignCatalog,
2394                                     String JavaDoc foreignSchema, String JavaDoc foreignTable) throws
2395      SQLException {
2396    String JavaDoc query = DatabaseProperties.getCrossReferenceQuery(primaryCatalog,
2397        primarySchema, primaryTable, foreignCatalog, foreignSchema,
2398        foreignTable);
2399    return getTempResultSetForCrossReference(query);
2400  }
2401
2402  /**
2403   * Gets a description of all the standard SQL types supported by
2404   * this database. They are ordered by DATA_TYPE and then by how
2405   * closely the data type maps to the corresponding JDBC SQL type.
2406   *
2407   * <P>Each type description has the following columns:
2408   * <OL>
2409   * <LI><B>TYPE_NAME</B> String => Type name
2410   * <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
2411   * <LI><B>PRECISION</B> int => maximum precision
2412   * <LI><B>LITERAL_PREFIX</B> String => prefix used to quote a literal
2413   * (may be null)
2414   * <LI><B>LITERAL_SUFFIX</B> String => suffix used to quote a literal
2415           (may be null)
2416   * <LI><B>CREATE_PARAMS</B> String => parameters used in creating
2417   * the type (may be null)
2418   * <LI><B>NULLABLE</B> short => can you use NULL for this type?
2419   * <UL>
2420   * <LI> typeNoNulls - does not allow NULL values
2421   * <LI> typeNullable - allows NULL values
2422   * <LI> typeNullableUnknown - nullability unknown
2423   * </UL>
2424   * <LI><B>CASE_SENSITIVE</B> boolean=> is it case sensitive?
2425   * <LI><B>SEARCHABLE</B> short => can you use "WHERE" based on this type:
2426   * <UL>
2427   * <LI> typePredNone - No support
2428   * <LI> typePredChar - Only supported with WHERE .. LIKE
2429   * <LI> typePredBasic - Supported except for WHERE .. LIKE
2430   * <LI> typeSearchable - Supported for all WHERE ..
2431   * </UL>
2432   * <LI><B>UNSIGNED_ATTRIBUTE</B> boolean => is it unsigned?
2433   * <LI><B>FIXED_PREC_SCALE</B> boolean => can it be a money value?
2434   * <LI><B>AUTO_INCREMENT</B> boolean => can it be used for an
2435   * auto-increment value?
2436   * <LI><B>LOCAL_TYPE_NAME</B> String => localized version of type name
2437   * (may be null)
2438   * <LI><B>MINIMUM_SCALE</B> short => minimum scale supported
2439   * <LI><B>MAXIMUM_SCALE</B> short => maximum scale supported
2440   * <LI><B>SQL_DATA_TYPE</B> int => unused
2441   * <LI><B>SQL_DATETIME_SUB</B> int => unused
2442   * <LI><B>NUM_PREC_RADIX</B> int => usually 2 or 10
2443   * </OL>
2444   *
2445   * @return <code>ResultSet</code> - each row is an SQL type description
2446   * @exception SQLException if a database access error occurs
2447   * @ todo
2448   */

2449
2450  public ResultSet getTypeInfo() throws SQLException {
2451    try {
2452      String JavaDoc[] columnNames = new String JavaDoc[] {
2453          "TYPE_NAME", "DATA_TYPE", "PRECISION", "LITERAL_PREFIX",
2454          "LITERAL_SUFFIX", "CREATE_PARAMS", "NULLABLE", "CASE_SENSITIVE",
2455          "SEARCHABLE", "UNSIGNED_ATTRIBUTE", "FIXED_PREC_SCALE",
2456          "AUTO_INCREMENT",
2457          "LOCAL_TYPE_NAME", "MINIMUM_SCALE", "MAXIMUM_SCALE", "SQL_DATA_TYPE",
2458          "SQL_DATETIME_SUB", "NUM_PREC_RADIX"};
2459      Object JavaDoc[][] typeInfo = DatabaseProperties.getTypeInfo();
2460      for (int i = 0, size = typeInfo.length; i < size; i++) {
2461        Object JavaDoc[] currentTypeInfo = new Object JavaDoc[typeInfo[i].length + 2];
2462        currentTypeInfo[0] = currentTypeInfo[1] = new Long JavaDoc(i + 1);
2463        System.arraycopy(typeInfo[i], 0, currentTypeInfo, 2, typeInfo[i].length);
2464      }
2465      int rowCount = columnNames.length;
2466      Object JavaDoc[][] metaData = new Object JavaDoc[rowCount][20];
2467      for (int i = 0; i < columnNames.length; i++) {
2468        metaData[i][0] = null;
2469        metaData[i][1] = null;
2470        metaData[i][2] = null;
2471        metaData[i][3] = columnNames[i];
2472        metaData[i][4] = new Integer JavaDoc(getColumnTypeForTypeInfo(i + 1));
2473        metaData[i][5] = columnNames[i];
2474        metaData[i][6] = new Integer JavaDoc(Utilities.getPrecision(
2475            getColumnTypeForTypeInfo(i + 1)));
2476        metaData[i][7] = null;
2477        metaData[i][8] = new Integer JavaDoc(columnNames[i].length());
2478        metaData[i][9] = getColumnTypeForTypeInfo(i + 1) == Types.SMALLINT ?
2479            "java.lang.String" : "short";
2480        metaData[i][10] = Utilities.getCorrespondingJavaClassesOfSqlTypes(
2481            getColumnTypeForTypeInfo(i + 1));
2482        metaData[i][11] = Utilities.getBooleanValue(false);
2483        metaData[i][12] = Utilities.getBooleanValue(false);
2484        metaData[i][13] = Utilities.getBooleanValue(false);
2485        metaData[i][14] = getColumnTypeForTypeInfo(i + 1) == Types.SMALLINT ?
2486             Utilities.getBooleanValue(true) : Utilities.getBooleanValue(false);
2487        metaData[i][15] = Utilities.getBooleanValue(false);
2488        metaData[i][16] = Utilities.getBooleanValue(true);
2489        metaData[i][17] = Utilities.getBooleanValue(true);
2490        metaData[i][18] = Utilities.getBooleanValue(true);
2491        metaData[i][19] = new Integer JavaDoc(ResultSetMetaData.columnNullableUnknown);
2492      }
2493      TempResultSetMetaData tempMetaData = new TempResultSetMetaData(metaData);
2494      TempResultSet resultSet = new TempResultSet(typeInfo, columnNames);
2495      resultSet.setConnection(systemConnection);
2496      resultSet.setMetaData(tempMetaData);
2497      return resultSet;
2498    }
2499    catch (DException dse) {
2500      throw dse.getSqlException(systemConnection.getLocale());
2501    }
2502  }
2503
2504  private int getColumnTypeForTypeInfo(int index) throws SQLException {
2505    switch (index) {
2506      case 1:
2507        return Types.VARCHAR;
2508      case 2:
2509        return Types.SMALLINT;
2510      case 3:
2511        return Types.INTEGER;
2512      case 4:
2513        return Types.VARCHAR;
2514      case 5:
2515        return Types.VARCHAR;
2516      case 6:
2517        return Types.VARCHAR;
2518      case 7:
2519        return Types.SMALLINT;
2520      case 8:
2521        return 16; //Types.BOOLEAN;
2522
case 9:
2523        return Types.SMALLINT;
2524      case 10:
2525        return 16; //Types.BOOLEAN;
2526
case 11:
2527        return 16; //Types.BOOLEAN;
2528
case 12:
2529        return 16; //Types.BOOLEAN;
2530
case 13:
2531        return Types.VARCHAR;
2532      case 14:
2533        return Types.SMALLINT;
2534      case 15:
2535        return Types.SMALLINT;
2536      case 16:
2537        return Types.INTEGER;
2538      case 17:
2539        return Types.INTEGER;
2540      case 18:
2541        return Types.INTEGER;
2542      default:
2543        DException dex = new DException("DSE504", null);
2544        throw dex.getSqlException(systemConnection.getLocale());
2545    }
2546  }
2547
2548  /**
2549   * A possible value for column <code>NULLABLE</code> in the
2550   * <code>ResultSet</code> object returned by the method
2551   * <code>getTypeInfo</code>.
2552   * <p>Indicates that a <code>NULL</code> value is NOT allowed for this
2553   * data type.
2554   *
2555       int typeNoNulls = 0;
2556       /**
2557    * A possible value for column <code>NULLABLE</code> in the
2558    * <code>ResultSet</code> object returned by the method
2559    * <code>getTypeInfo</code>.
2560    * <p>Indicates that a <code>NULL</code> value is allowed for this
2561    * data type.
2562    *
2563        int typeNullable = 1;
2564        /**
2565     * A possible value for column <code>NULLABLE</code> in the
2566     * <code>ResultSet</code> object returned by the method
2567     * <code>getTypeInfo</code>.
2568     * <p>Indicates that it is not known whether a <code>NULL</code> value
2569     * is allowed for this data type.
2570     *
2571         int typeNullableUnknown = 2;
2572         /**
2573      * A possible value for column <code>SEARCHABLE</code> in the
2574      * <code>ResultSet</code> object returned by the method
2575      * <code>getTypeInfo</code>.
2576      * <p>Indicates that <code>WHERE</code> search clauses are not supported
2577      * for this type.
2578      *
2579         int typePredNone = 0;
2580          /**
2581       * A possible value for column <code>SEARCHABLE</code> in the
2582       * <code>ResultSet</code> object returned by the method
2583       * <code>getTypeInfo</code>.
2584       * <p>Indicates that the only <code>WHERE</code> search clause that can
2585       * be based on this type is <code>WHERE . . .LIKE</code>.
2586       *
2587          int typePredChar = 1;
2588           /**
2589        * A possible value for column <code>SEARCHABLE</code> in the
2590        * <code>ResultSet</code> object returned by the method
2591        * <code>getTypeInfo</code>.
2592        * <p>Indicates that one can base all <code>WHERE</code> search clauses
2593        * except <code>WHERE . . .LIKE</code> on this data type.
2594        *
2595           int typePredBasic = 2;
2596            /**
2597         * A possible value for column <code>SEARCHABLE</code> in the
2598         * <code>ResultSet</code> object returned by the method
2599         * <code>getTypeInfo</code>.
2600         * <p>Indicates that all <code>WHERE</code> search clauses can be
2601         * based on this type.
2602         *
2603            int typeSearchable = 3;
2604             /**
2605          * Gets a description of a table's indices and statistics. They are
2606          * ordered by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION.
2607          *
2608          * <P>Each index column description has the following columns:
2609          * <OL>
2610          * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
2611          * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
2612          * <LI><B>TABLE_NAME</B> String => table name
2613          * <LI><B>NON_UNIQUE</B> boolean => Can index values be non-unique?
2614          * false when TYPE is tableIndexStatistic
2615          * <LI><B>INDEX_QUALIFIER</B> String => index catalog (may be null);
2616          * null when TYPE is tableIndexStatistic
2617          * <LI><B>INDEX_NAME</B> String => index name; null when TYPE is
2618          * tableIndexStatistic
2619          * <LI><B>TYPE</B> short => index type:
2620          * <UL>
2621              * <LI> tableIndexStatistic - this identifies table statistics that are
2622          * returned in conjuction with a table's index descriptions
2623          * <LI> tableIndexClustered - this is a clustered index
2624          * <LI> tableIndexHashed - this is a hashed index
2625          * <LI> tableIndexOther - this is some other style of index
2626          * </UL>
2627          * <LI><B>ORDINAL_POSITION</B> short => column sequence number
2628          * within index; zero when TYPE is tableIndexStatistic
2629          * <LI><B>COLUMN_NAME</B> String => column name; null when TYPE is
2630          * tableIndexStatistic
2631              * <LI><B>ASC_OR_DESC</B> String => column sort sequence, "A" => ascending,
2632              * "D" => descending, may be null if sort sequence is not supported;
2633          * null when TYPE is tableIndexStatistic
2634              * <LI><B>CARDINALITY</B> int => When TYPE is tableIndexStatistic, then
2635          * this is the number of rows in the table; otherwise, it is the
2636          * number of unique values in the index.
2637          * <LI><B>PAGES</B> int => When TYPE is tableIndexStatisic then
2638          * this is the number of pages used for the table, otherwise it
2639          * is the number of pages used for the current index.
2640          * <LI><B>FILTER_CONDITION</B> String => Filter condition, if any.
2641          * (may be null)
2642          * </OL>
2643          *
2644          * @param catalog a catalog name; "" retrieves those without a
2645          * catalog; null means drop catalog name from the selection criteria
2646          * @param schema a schema name; "" retrieves those without a schema
2647          * @param table a table name
2648          * @param unique when true, return only indices for unique values;
2649          * when false, return indices regardless of whether unique or not
2650              * @param approximate when true, result is allowed to reflect approximate
2651          * or out of data values; when false, results are requested to be
2652          * accurate
2653              * @return <code>ResultSet</code> - each row is an index column description
2654          * @exception SQLException if a database access error occurs
2655          * @todo indexInfo
2656          */

2657
2658         public ResultSet getIndexInfo(String JavaDoc catalog, String JavaDoc schema,
2659                                       String JavaDoc table, boolean unique,
2660                                       boolean approximate) throws SQLException {
2661           String JavaDoc query = DatabaseProperties.getIndexInfoQuery(catalog, schema,
2662               table, unique, approximate);
2663           if (query == null) {
2664             DException dex = new DException("DSE16",
2665                                             new Object JavaDoc[] {"getIndexInfo"});
2666           }
2667           return getTempResultSetForIndexInfo(query);
2668         }
2669
2670  /**
2671   * A possible value for column <code>TYPE</code> in the
2672   * <code>ResultSet</code> object returned by the method
2673   * <code>getIndexInfo</code>.
2674   * <P>Indicates that this column contains table statistics that
2675   * are returned in conjunction with a table's index descriptions.
2676   *
2677      short tableIndexStatistic = 0;
2678       /**
2679    * A possible value for column <code>TYPE</code> in the
2680    * <code>ResultSet</code> object returned by the method
2681    * <code>getIndexInfo</code>.
2682    * <P>Indicates that this table index is a clustered index.
2683    *
2684       short tableIndexClustered = 1;
2685        /**
2686     * A possible value for column <code>TYPE</code> in the
2687     * <code>ResultSet</code> object returned by the method
2688     * <code>getIndexInfo</code>.
2689     * <P>Indicates that this table index is a hashed index.
2690     *
2691        short tableIndexHashed = 2;
2692         /**
2693      * A possible value for column <code>TYPE</code> in the
2694      * <code>ResultSet</code> object returned by the method
2695      * <code>getIndexInfo</code>.
2696      * <P>Indicates that this table index is not a clustered
2697      * index, a hashed index, or table statistics;
2698      * it is something other than these.
2699      *
2700         short tableIndexOther = 3;
2701          /**
2702       * Does the database support the given result set type?
2703       *
2704       * @param type defined in <code>java.sql.ResultSet</code>
2705       * @return <code>true</code> if so; <code>false</code> otherwise
2706       * @exception SQLException if a database access error occurs
2707       * @see Connection
2708       * @since 1.2
2709           * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
2710       */

2711      public boolean supportsResultSetType(int type) throws SQLException {
2712        return DatabaseProperties.supportsResultSetType(type);
2713      }
2714
2715  /**
2716   * Does the database support the concurrency type in combination
2717   * with the given result set type?
2718   *
2719   * @param type defined in <code>java.sql.ResultSet</code>
2720   * @param concurrency type defined in <code>java.sql.ResultSet</code>
2721   * @return <code>true</code> if so; <code>false</code> otherwise
2722   * @exception SQLException if a database access error occurs
2723   * @see Connection
2724   * @since 1.2
2725       * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
2726   */

2727  public boolean supportsResultSetConcurrency(int type, int concurrency) throws
2728      SQLException {
2729    return DatabaseProperties.supportsResultSetConcurrency(type, concurrency);
2730  }
2731
2732  /**
2733   *
2734   * Indicates whether a result set's own updates are visible.
2735   *
2736   * @param result set type, i.e. ResultSet.TYPE_XXX
2737   * @return <code>true</code> if updates are visible for the result set type;
2738   * <code>false</code> otherwise
2739   * @exception SQLException if a database access error occurs
2740   * @since 1.2
2741       * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
2742   */

2743  public boolean ownUpdatesAreVisible(int type) throws SQLException {
2744    return DatabaseProperties.ownUpdatesAreVisible(type);
2745  }
2746
2747  /**
2748   *
2749   * Indicates whether a result set's own deletes are visible.
2750   *
2751   * @param result set type, i.e. ResultSet.TYPE_XXX
2752   * @return <code>true</code> if deletes are visible for the result set type;
2753   * <code>false</code> otherwise
2754   * @exception SQLException if a database access error occurs
2755   * @since 1.2
2756       * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
2757   */

2758  public boolean ownDeletesAreVisible(int type) throws SQLException {
2759    return DatabaseProperties.ownDeletesAreVisible(type);
2760  }
2761
2762  /**
2763   *
2764   * Indicates whether a result set's own inserts are visible.
2765   *
2766   * @param result set type, i.e. ResultSet.TYPE_XXX
2767   * @return <code>true</code> if inserts are visible for the result set type;
2768   * <code>false</code> otherwise
2769   * @exception SQLException if a database access error occurs
2770   * @since 1.2
2771       * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
2772   */

2773  public boolean ownInsertsAreVisible(int type) throws SQLException {
2774    return DatabaseProperties.ownInsertsAreVisible(type);
2775  }
2776
2777  /**
2778   *
2779   * Indicates whether updates made by others are visible.
2780   *
2781   * @param result set type, i.e. ResultSet.TYPE_XXX
2782   * @return <code>true</code> if updates made by others
2783   * are visible for the result set type;
2784   * <code>false</code> otherwise
2785   * @exception SQLException if a database access error occurs
2786   * @since 1.2
2787       * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
2788   */

2789  public boolean othersUpdatesAreVisible(int type) throws SQLException {
2790    return DatabaseProperties.othersUpdatesAreVisible(type);
2791  }
2792
2793  /**
2794   *
2795   * Indicates whether deletes made by others are visible.
2796   *
2797   * @param result set type, i.e. ResultSet.TYPE_XXX
2798   * @return <code>true</code> if deletes made by others
2799   * are visible for the result set type;
2800   * <code>false</code> otherwise
2801   * @exception SQLException if a database access error occurs
2802   * @since 1.2
2803       * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
2804   */

2805  public boolean othersDeletesAreVisible(int type) throws SQLException {
2806    return DatabaseProperties.othersDeletesAreVisible(type);
2807  }
2808
2809  /**
2810   *
2811   * Indicates whether inserts made by others are visible.
2812   *
2813   * @param result set type, i.e. ResultSet.TYPE_XXX
2814   * @return true if updates are visible for the result set type
2815   * @return <code>true</code> if inserts made by others
2816   * are visible for the result set type;
2817   * <code>false</code> otherwise
2818   * @exception SQLException if a database access error occurs
2819   * @since 1.2
2820       * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
2821   */

2822  public boolean othersInsertsAreVisible(int type) throws SQLException {
2823    return DatabaseProperties.othersInsertsAreVisible(type);
2824  }
2825
2826  /**
2827   *
2828   * Indicates whether or not a visible row update can be detected by
2829   * calling the method <code>ResultSet.rowUpdated</code>.
2830   *
2831   * @param result set type, i.e. ResultSet.TYPE_XXX
2832   * @return <code>true</code> if changes are detected by the result set type;
2833   * <code>false</code> otherwise
2834   * @exception SQLException if a database access error occurs
2835   * @since 1.2
2836       * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
2837   */

2838  public boolean updatesAreDetected(int type) throws SQLException {
2839    return DatabaseProperties.updatesAreDetected(type);
2840  }
2841
2842  /**
2843   *
2844   * Indicates whether or not a visible row delete can be detected by
2845   * calling ResultSet.rowDeleted(). If deletesAreDetected()
2846   * returns false, then deleted rows are removed from the result set.
2847   *
2848   * @param result set type, i.e. ResultSet.TYPE_XXX
2849   * @return true if changes are detected by the resultset type
2850   * @exception SQLException if a database access error occurs
2851   * @since 1.2
2852       * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
2853   */

2854  public boolean deletesAreDetected(int type) throws SQLException {
2855    return DatabaseProperties.deletesAreDetected(type);
2856  }
2857
2858  /**
2859   *
2860   * Indicates whether or not a visible row insert can be detected
2861   * by calling ResultSet.rowInserted().
2862   *
2863   * @param result set type, i.e. ResultSet.TYPE_XXX
2864   * @return true if changes are detected by the resultset type
2865   * @exception SQLException if a database access error occurs
2866   * @since 1.2
2867       * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
2868   */

2869  public boolean insertsAreDetected(int type) throws SQLException {
2870    return DatabaseProperties.insertsAreDetected(type);
2871  }
2872
2873  /**
2874   *
2875   * Indicates whether the driver supports batch updates.
2876   * @return true if the driver supports batch updates; false otherwise
2877   * @since 1.2
2878       * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
2879   */

2880  public boolean supportsBatchUpdates() throws SQLException {
2881    return DatabaseProperties.supportsBatchUpdates;
2882  }
2883
2884  /**
2885   *
2886   * Gets a description of the user-defined types defined in a particular
2887   * schema. Schema-specific UDTs may have type JAVA_OBJECT, STRUCT,
2888   * or DISTINCT.
2889   *
2890   * <P>Only types matching the catalog, schema, type name and type
2891   * criteria are returned. They are ordered by DATA_TYPE, TYPE_SCHEM
2892   * and TYPE_NAME. The type name parameter may be a fully-qualified
2893   * name. In this case, the catalog and schemaPattern parameters are
2894   * ignored.
2895   *
2896   * <P>Each type description has the following columns:
2897   * <OL>
2898   * <LI><B>TYPE_CAT</B> String => the type's catalog (may be null)
2899   * <LI><B>TYPE_SCHEM</B> String => type's schema (may be null)
2900   * <LI><B>TYPE_NAME</B> String => type name
2901   * <LI><B>CLASS_NAME</B> String => Java class name
2902   * <LI><B>DATA_TYPE</B> String => type value defined in java.sql.Types.
2903   * One of JAVA_OBJECT, STRUCT, or DISTINCT
2904   * <LI><B>REMARKS</B> String => explanatory comment on the type
2905   * </OL>
2906   *
2907   * <P><B>Note:</B> If the driver does not support UDTs, an empty
2908   * result set is returned.
2909   *
2910   * @param catalog a catalog name; "" retrieves those without a
2911   * catalog; null means drop catalog name from the selection criteria
2912   * @param schemaPattern a schema name pattern; "" retrieves those
2913   * without a schema
2914   * @param typeNamePattern a type name pattern; may be a fully-qualified
2915   * name
2916   * @param types a list of user-named types to include (JAVA_OBJECT,
2917   * STRUCT, or DISTINCT); null returns all types
2918   * @return <code>ResultSet</code> - each row is a type description
2919   * @exception SQLException if a database access error occurs
2920   * @since 1.2
2921       * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
2922   * @ todo
2923   */

2924  public ResultSet getUDTs(String JavaDoc catalog, String JavaDoc schemaPattern,
2925                           String JavaDoc typeNamePattern, int[] types) throws
2926      SQLException {
2927    try {
2928      String JavaDoc[] columnNames = new String JavaDoc[] {
2929          "TYPE_CAT", "TYPE_SCHEM", "TYPE_NAME", "CLASS_NAME", "DATA_TYPE",
2930          "REMARKS"};
2931      int rowCount = columnNames.length;
2932      Object JavaDoc[][] metaData = new Object JavaDoc[rowCount][20];
2933      for (int i = 0; i < columnNames.length; i++) {
2934        metaData[i][0] = null;
2935        metaData[i][1] = null;
2936        metaData[i][2] = null;
2937        metaData[i][3] = columnNames[i];
2938        metaData[i][4] = new Integer JavaDoc(Types.VARCHAR);
2939        metaData[i][5] = columnNames[i];
2940        metaData[i][6] = new Integer JavaDoc(Utilities.getPrecision(Types.VARCHAR));
2941        metaData[i][7] = null;
2942        metaData[i][8] = new Integer JavaDoc(columnNames[i].length());
2943        metaData[i][9] = "java.lang.String";
2944        metaData[i][10] = "java.lang.String";
2945        metaData[i][11] = Utilities.getBooleanValue(false);
2946        metaData[i][12] = Utilities.getBooleanValue(false);
2947        metaData[i][13] = Utilities.getBooleanValue(false);
2948        metaData[i][14] = Utilities.getBooleanValue(false);
2949        metaData[i][15] = Utilities.getBooleanValue(false);
2950        metaData[i][16] = Utilities.getBooleanValue(true);
2951        metaData[i][17] = Utilities.getBooleanValue(true);
2952        metaData[i][18] = Utilities.getBooleanValue(true);
2953        metaData[i][19] = new Integer JavaDoc(ResultSetMetaData.columnNullableUnknown);
2954      }
2955      TempResultSetMetaData tempMetaData = new TempResultSetMetaData(metaData);
2956      TempResultSet resultSet = new TempResultSet(new Object JavaDoc[0][0], columnNames);
2957      resultSet.setConnection(systemConnection);
2958      resultSet.setMetaData(tempMetaData);
2959      return resultSet;
2960    }
2961    catch (DException dxe) {
2962      throw dxe.getSqlException(systemConnection.getLocale());
2963    }
2964  }
2965
2966
2967  /**
2968   * Retrieves whether this database supports savepoints.
2969   *
2970   * @return <code>true</code> if savepoints are supported;
2971   * <code>false</code> otherwise
2972   * @exception SQLException if a database access error occurs
2973   * @since 1.4
2974   */

2975  public boolean supportsSavepoints() throws SQLException {
2976    DException dex = new DException("DSE16", new Object JavaDoc[] {"supportsSavepoints"});
2977    throw dex.getSqlException(systemConnection.getLocale());
2978  }
2979
2980  /**
2981   * Retrieves whether this database supports named parameters to callable
2982   * statements.
2983   * @return <code>true</code> if named parameters are supported;
2984   * <code>false</code> otherwise
2985   * @exception SQLException if a database access error occurs
2986   * @since 1.4
2987   */

2988
2989  public boolean supportsNamedParameters() throws SQLException {
2990    DException dex = new DException("DSE16",
2991                                    new Object JavaDoc[] {"supportsNamedParameters"});
2992    throw dex.getSqlException(systemConnection.getLocale());
2993  }
2994
2995  /**
2996   * Retrieves whether it is possible to have multiple <code>ResultSet</code> objects
2997   * returned from a <code>CallableStatement</code> object
2998   * simultaneously.
2999   *
3000   * @return <code>true</code> if a <code>CallableStatement</code> object
3001   * can return multiple <code>ResultSet</code> objects
3002   * simultaneously; <code>false</code> otherwise
3003   * @exception SQLException if a datanase access error occurs
3004   * @since 1.4
3005   */

3006  public boolean supportsMultipleOpenResults() throws SQLException {
3007    DException dex = new DException("DSE16",
3008                                    new Object JavaDoc[] {"supportsMultipleOpenResults"});
3009    throw dex.getSqlException(systemConnection.getLocale());
3010  }
3011
3012  /**
3013   * Retrieves whether auto-generated keys can be retrieved after
3014   * a statement has been executed.
3015   *
3016   * @return <code>true</code> if auto-generated keys can be retrieved
3017   * after a statement has executed; <code>false</code> otherwise
3018   * @exception SQLException if a database access error occurs
3019   * @since 1.4
3020   */

3021  public boolean supportsGetGeneratedKeys() throws SQLException {
3022    DException dex = new DException("DSE16",
3023                                    new Object JavaDoc[] {"supportsGetGeneratedKeys"});
3024    throw dex.getSqlException(systemConnection.getLocale());
3025  }
3026
3027  /**
3028   * Retrieves a description of the user-defined type (UDT) hierarchies defined in a
3029   * particular schema in this database. Only the immediate super type/
3030   * sub type relationship is modeled.
3031   * <P>
3032   * Only supertype information for UDTs matching the catalog,
3033   * schema, and type name is returned. The type name parameter
3034   * may be a fully-qualified name. When the UDT name supplied is a
3035   * fully-qualified name, the catalog and schemaPattern parameters are
3036   * ignored.
3037   * <P>
3038   * If a UDT does not have a direct super type, it is not listed here.
3039   * A row of the <code>ResultSet</code> object returned by this method
3040       * describes the designated UDT and a direct supertype. A row has the following
3041   * columns:
3042   * <OL>
3043       * <LI><B>TYPE_CAT</B> String => the UDT's catalog (may be <code>null</code>)
3044   * <LI><B>TYPE_SCHEM</B> String => UDT's schema (may be <code>null</code>)
3045   * <LI><B>TYPE_NAME</B> String => type name of the UDT
3046   * <LI><B>SUPERTYPE_CAT</B> String => the direct super type's catalog
3047   * (may be <code>null</code>)
3048   * <LI><B>SUPERTYPE_SCHEM</B> String => the direct super type's schema
3049   * (may be <code>null</code>)
3050   * <LI><B>SUPERTYPE_NAME</B> String => the direct super type's name
3051   * </OL>
3052   *
3053   * <P><B>Note:</B> If the driver does not support type hierarchies, an
3054   * empty result set is returned.
3055   *
3056   * @param catalog a catalog name; "" retrieves those without a catalog;
3057       * <code>null</code> means drop catalog name from the selection criteria
3058   * @param schemaPattern a schema name pattern; "" retrieves those
3059   * without a schema
3060   * @param typeNamePattern a UDT name pattern; may be a fully-qualified
3061   * name
3062   * @return a <code>ResultSet</code> object in which a row gives information
3063   * about the designated UDT
3064   * @throws SQLException if a database access error occurs
3065   * @since 1.4
3066   *@ todo
3067   */

3068  public ResultSet getSuperTypes(String JavaDoc catalog, String JavaDoc schemaPattern,
3069                                 String JavaDoc typeNamePattern) throws SQLException {
3070    DException dex = new DException("DSE16", new Object JavaDoc[] {"getSuperTypes"});
3071    throw dex.getSqlException(systemConnection.getLocale());
3072  }
3073
3074  /**
3075   * Retrieves a description of the table hierarchies defined in a particular
3076   * schema in this database.
3077   *
3078   * <P>Only supertable information for tables matching the catalog, schema
3079   * and table name are returned. The table name parameter may be a fully-
3080   * qualified name, in which case, the catalog and schemaPattern parameters
3081       * are ignored. If a table does not have a super table, it is not listed here.
3082   * Supertables have to be defined in the same catalog and schema as the
3083   * sub tables. Therefore, the type description does not need to include
3084   * this information for the supertable.
3085   *
3086   * <P>Each type description has the following columns:
3087   * <OL>
3088       * <LI><B>TABLE_CAT</B> String => the type's catalog (may be <code>null</code>)
3089   * <LI><B>TABLE_SCHEM</B> String => type's schema (may be <code>null</code>)
3090   * <LI><B>TABLE_NAME</B> String => type name
3091   * <LI><B>SUPERTABLE_NAME</B> String => the direct super type's name
3092   * </OL>
3093   *
3094   * <P><B>Note:</B> If the driver does not support type hierarchies, an
3095   * empty result set is returned.
3096   *
3097   * @param catalog a catalog name; "" retrieves those without a catalog;
3098       * <code>null</code> means drop catalog name from the selection criteria
3099   * @param schemaPattern a schema name pattern; "" retrieves those
3100   * without a schema
3101   * @param tableNamePattern a table name pattern; may be a fully-qualified
3102   * name
3103   * @return a <code>ResultSet</code> object in which each row is a type description
3104   * @throws SQLException if a database access error occurs
3105   * @since 1.4
3106   * @ todo
3107   */

3108
3109  public ResultSet getSuperTables(String JavaDoc catalog, String JavaDoc schemaPattern,
3110                                  String JavaDoc tableNamePattern) throws SQLException {
3111    DException dex = new DException("DSE16", new Object JavaDoc[] {"getSuperTables"});
3112    throw dex.getSqlException(systemConnection.getLocale());
3113  }
3114
3115  /**
3116   * Indicates that <code>NULL</code> values might not be allowed.
3117   * <P>
3118   * A possible value for the column
3119   * <code>NULLABLE</code> in the <code>ResultSet</code> object
3120   * returned by the method <code>getAttributes</code>.
3121   */

3122  short attributeNoNulls = 0;
3123
3124  /**
3125   * Indicates that <code>NULL</code> values are definitely allowed.
3126   * <P>
3127   * A possible value for the column <code>NULLABLE</code>
3128   * in the <code>ResultSet</code> object
3129   * returned by the method <code>getAttributes</code>.
3130   */

3131  short attributeNullable = 1;
3132
3133  /**
3134   * Indicates that whether <code>NULL</code> values are allowed is not
3135   * known.
3136   * <P>
3137   * A possible value for the column <code>NULLABLE</code>
3138   * in the <code>ResultSet</code> object
3139   * returned by the method <code>getAttributes</code>.
3140   */

3141  short attributeNullableUnknown = 2;
3142
3143  /**
3144   * Retrieves a description of the given attribute of the given type
3145   * for a user-defined type (UDT) that is available in the given schema
3146   * and catalog.
3147   * <P>
3148   * Descriptions are returned only for attributes of UDTs matching the
3149   * catalog, schema, type, and attribute name criteria. They are ordered by
3150   * TYPE_SCHEM, TYPE_NAME and ORDINAL_POSITION. This description
3151   * does not contain inherited attributes.
3152   * <P>
3153   * The <code>ResultSet</code> object that is returned has the following
3154   * columns:
3155   * <OL>
3156   * <LI><B>TYPE_CAT</B> String => type catalog (may be <code>null</code>)
3157   * <LI><B>TYPE_SCHEM</B> String => type schema (may be <code>null</code>)
3158   * <LI><B>TYPE_NAME</B> String => type name
3159   * <LI><B>ATTR_NAME</B> String => attribute name
3160   * <LI><B>DATA_TYPE</B> short => attribute type SQL type from java.sql.Types
3161   * <LI><B>ATTR_TYPE_NAME</B> String => Data source dependent type name.
3162   * For a UDT, the type name is fully qualified. For a REF, the type name is
3163   * fully qualified and represents the target type of the reference type.
3164   * <LI><B>ATTR_SIZE</B> int => column size. For char or date
3165   * types this is the maximum number of characters; for numeric or
3166   * decimal types this is precision.
3167   * <LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits
3168   * <LI><B>NUM_PREC_RADIX</B> int => Radix (typically either 10 or 2)
3169   * <LI><B>NULLABLE</B> int => whether NULL is allowed
3170   * <UL>
3171   * <LI> attributeNoNulls - might not allow NULL values
3172   * <LI> attributeNullable - definitely allows NULL values
3173   * <LI> attributeNullableUnknown - nullability unknown
3174   * </UL>
3175   * <LI><B>REMARKS</B> String => comment describing column (may be <code>null</code>)
3176   * <LI><B>ATTR_DEF</B> String => default value (may be <code>null</code>)
3177   * <LI><B>SQL_DATA_TYPE</B> int => unused
3178   * <LI><B>SQL_DATETIME_SUB</B> int => unused
3179   * <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the
3180   * maximum number of bytes in the column
3181   * <LI><B>ORDINAL_POSITION</B> int => index of column in table
3182   * (starting at 1)
3183   * <LI><B>IS_NULLABLE</B> String => "NO" means column definitely
3184   * does not allow NULL values; "YES" means the column might
3185   * allow NULL values. An empty string means unknown.
3186   * <LI><B>SCOPE_CATALOG</B> String => catalog of table that is the
3187       * scope of a reference attribute (<code>null</code> if DATA_TYPE isn't REF)
3188   * <LI><B>SCOPE_SCHEMA</B> String => schema of table that is the
3189       * scope of a reference attribute (<code>null</code> if DATA_TYPE isn't REF)
3190   * <LI><B>SCOPE_TABLE</B> String => table name that is the scope of a
3191   * reference attribute (<code>null</code> if the DATA_TYPE isn't REF)
3192   * <LI><B>SOURCE_DATA_TYPE</B> short => source type of a distinct type or user-generated
3193   * Ref type,SQL type from java.sql.Types (<code>null</code> if DATA_TYPE
3194   * isn't DISTINCT or user-generated REF)
3195   * </OL>
3196   * @param catalog a catalog name; must match the catalog name as it
3197   * is stored in the database; "" retrieves those without a catalog;
3198   * <code>null</code> means that the catalog name should not be used to narrow
3199   * the search
3200   * @param schemaPattern a schema name pattern; must match the schema name
3201       * as it is stored in the database; "" retrieves those without a schema;
3202   * <code>null</code> means that the schema name should not be used to narrow
3203   * the search
3204   * @param typeNamePattern a type name pattern; must match the
3205   * type name as it is stored in the database
3206   * @param attributeNamePattern an attribute name pattern; must match the attribute
3207   * name as it is declared in the database
3208   * @return a <code>ResultSet</code> object in which each row is an
3209   * attribute description
3210   * @exception SQLException if a database access error occurs
3211   * @since 1.4
3212   */

3213
3214  public ResultSet getAttributes(String JavaDoc catalog, String JavaDoc schemaPattern,
3215                                 String JavaDoc typeNamePattern,
3216                                 String JavaDoc attributeNamePattern) throws
3217      SQLException {
3218    DException dex = new DException("DSE16", new Object JavaDoc[] {"getAttributes"});
3219    throw dex.getSqlException(systemConnection.getLocale());
3220  }
3221
3222  /**
3223   * Retrieves whether this database supports the given result set holdability.
3224   *
3225   * @param holdability one of the following constants:
3226   * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
3227   * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT<code>
3228   * @return <code>true</code> if so; <code>false</code> otherwise
3229   * @exception SQLException if a database access error occurs
3230   * @see Connection
3231   * @since 1.4
3232   */

3233  public boolean supportResultSetHoldability(int holdability) throws
3234      SQLException {
3235    return false;
3236  }
3237
3238  public boolean supportsResultSetHoldability(int holdability) throws SQLException{
3239      return false;
3240  }
3241
3242  /**
3243   * Retrieves the default holdability of this <code>ResultSet</code>
3244   * object.
3245   *
3246   * @return the default holdability; either
3247   * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
3248   * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
3249   * @exception SQLException if a database access error occurs
3250   * @since 1.4
3251   */

3252  public int getResultSetHoldability() throws SQLException {
3253     return ResultSet.CLOSE_CURSORS_AT_COMMIT;
3254  }
3255
3256  /**
3257   * Retrieves the major version number of the underlying database.
3258   *
3259   * @return the underlying database's major version
3260   * @exception SQLException if a database access error occurs
3261   * @since 1.4
3262   */

3263  public int getDatabaseMajorVersion() throws SQLException {
3264     return DatabaseProperties.databaseMajorVersion;
3265  }
3266
3267  /**
3268   * Retrieves the minor version number of the underlying database.
3269   *
3270   * @return underlying database's minor version
3271   * @exception SQLException if a database access error occurs
3272   * @since 1.4
3273   */

3274  public int getDatabaseMinorVersion() throws SQLException {
3275     return DatabaseProperties.databaseMinorVersion;
3276  }
3277
3278  /**
3279   * Retrieves the major JDBC version number for this
3280   * driver.
3281   *
3282   * @return JDBC version major number
3283   * @exception SQLException if a database access error occurs
3284   * @since 1.4
3285   */

3286  public int getJDBCMajorVersion() throws SQLException {
3287     return DatabaseProperties.JDBCMajorVersion;
3288  }
3289
3290  /**
3291   * Retrieves the minor JDBC version number for this
3292   * driver.
3293   *
3294   * @return JDBC version minor number
3295   * @exception SQLException if a database access error occurs
3296   * @since 1.4
3297   */

3298  public int getJDBCMinorVersion() throws SQLException {
3299     return DatabaseProperties.JDBCMinorVersion;
3300  }
3301
3302  /**
3303   * Indicates that the value is an
3304   * X/Open (now know as Open Group) SQL CLI SQLSTATE value.
3305   * <P>
3306   * A possible return value for the method
3307   * <code>SQLException.getSQLState</code>.
3308   * @since 1.4
3309   */

3310  int sqlStateXOpen = 1;
3311
3312  /**
3313   * Indicates that the value is an SQL99 SQLSTATE value.
3314   * <P>
3315   * A possible return value for the method
3316   * <code>SQLException.getSQLState</code>.
3317   * @since 1.4
3318   */

3319  int sqlStateSQL99 = 2;
3320
3321  /**
3322   * Indicates whether the SQLSTATEs returned by <code>SQLException.getSQLState</code>
3323   * is X/Open (now known as Open Group) SQL CLI or SQL99.
3324   * @return the type of SQLSTATEs, one of:
3325   * sqlStateXOpen or
3326   * sqlStateSQL99
3327   * @throws SQLException if a database access error occurs
3328   * @since 1.4
3329   */

3330  public int getSQLStateType() throws SQLException {
3331    return sqlStateSQL99;
3332  }
3333
3334
3335  /**
3336   * * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
3337   * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
3338   * <LI><B>TABLE_NAME</B> String => table name
3339   * <LI><B>COLUMN_NAME</B> String => column name
3340   * <LI><B>DATA_TYPE</B> short => SQL type from java.sql.Types
3341   * <LI><B>TYPE_NAME</B> String => Data source dependent type name,
3342   * for a UDT the type name is fully qualified
3343   * <LI><B>COLUMN_SIZE</B> int => column size. For char or date
3344   * types this is the maximum number of characters, for numeric or
3345   * decimal types this is precision.
3346   * <LI><B>BUFFER_LENGTH</B> is not used.
3347   * <LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits
3348   * <LI><B>NUM_PREC_RADIX</B> int => Radix (typically either 10 or 2)
3349   * <LI><B>NULLABLE</B> int => is NULL allowed?
3350   * <UL>
3351   * <LI> columnNoNulls - might not allow NULL values
3352   * <LI> columnNullable - definitely allows NULL values
3353   * <LI> columnNullableUnknown - nullability unknown
3354   * </UL>
3355   * <LI><B>REMARKS</B> String => comment describing column (may be null)
3356   * <LI><B>COLUMN_DEF</B> String => default value (may be null)
3357   * <LI><B>SQL_DATA_TYPE</B> int => unused
3358   * <LI><B>SQL_DATETIME_SUB</B> int => unused
3359   * <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the
3360   * maximum number of bytes in the column
3361   * <LI><B>ORDINAL_POSITION</B> int => index of column in table
3362   * (starting at 1)
3363   * <LI><B>IS_NULLABLE</B> String => "NO" means column definitely
3364   * <LI><B>SCOPE_CATLOG</B> String => catalog of table that is the scope
3365   * of a reference attribute (<code>null</code> if DATA_TYPE isn't REF)
3366   * <LI><B>SCOPE_SCHEMA</B> String => schema of table that is the scope
3367       * of a reference attribute (<code>null</code> if the DATA_TYPE isn't REF)
3368   * <LI><B>SCOPE_TABLE</B> String => table name that this the scope
3369       * of a reference attribure (<code>null</code> if the DATA_TYPE isn't REF)
3370   * <LI><B>SOURCE_DATA_TYPE</B> short => source type of a distinct type or user-generated
3371       * Ref type, SQL type from java.sql.Types (<code>null</code> if DATA_TYPE
3372   * isn't DISTINCT or user-generated REF)
3373   * </OL>
3374   * /**
3375    * 1.TABLE_CAT
3376    * 2.TABLE_SCHEM
3377    * 3.TABLE_NAME
3378    * 4.COLUMN_NAME
3379    * 5.DATA_TYPE
3380    * 6.TYPE_NAME
3381    * 7.COLUMN_SIZE
3382    * 8.BUFFER_LENGTH//Check
3383    * 9.DECIMAL_DIGITS
3384    * 10.NUM_PREC_RADIX
3385    * 11.NULLABLE
3386    * 12.REMARKS
3387    * 13.COLUMN_DEF
3388    * 14.SQL_DATA_TYPE
3389    * 15.SQL_DATETIME_SUB
3390    * 16.CHAR_OCTET_LENGTH
3391    * 17.ORDINAL_POSITION
3392    * 18.IS_NULLABLE
3393    * 19.SCOPE_SCHEMA
3394    * 20.SCOPE_TABLE
3395    * 21.SOURCE_DATA_TYPE
3396    *
3397    */

3398
3399   private ResultSet getTempResultSetForColumns(String JavaDoc query) throws
3400       SQLException {
3401     try {
3402       String JavaDoc[] columnNames = {
3403           "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME",
3404           "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH",
3405           "DECIMAL_DIGITS", "NUM_PREC_RADIX",
3406           "NULLABLE", "REMARKS", "COLUMN_DEF", "SQL_DATA_TYPE",
3407           "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH",
3408           "ORDINAL_POSITION", "IS_NULLABLE"};
3409       _RecordSetBuffer recordSetBuffer = (_RecordSetBuffer) getRecordSetBuffer(
3410           query);
3411       _RecordSetBufferIterator iterator = recordSetBuffer.getIterator();
3412       ArrayList arr = new ArrayList();
3413       if (iterator.top()) {
3414         do {
3415           Object JavaDoc[] objs = new Object JavaDoc[columnNames.length];
3416           _Record record = iterator.getRecord();
3417           int j = 0;
3418           for (; j < 4; j++)
3419             objs[j] = record.getColumnValue(COLUMN_OFFSET + j);
3420           objs[5] = record.getColumnValue(COLUMN_OFFSET + 4);
3421           objs[4] = new Short JavaDoc( (short) Utilities.
3422                               getCorrespondingSqlTypeOfDatabaseType(Utilities.
3423               getDataBaseType( (String JavaDoc) objs[5])));
3424           Object JavaDoc characterLengthObj = record.getColumnValue(COLUMN_OFFSET + 8);
3425           int characterLength = characterLengthObj == null ? 0 :
3426               characterLengthObj.hashCode();
3427           Integer JavaDoc i12 = (Integer JavaDoc) record.getColumnValue(COLUMN_OFFSET + 12);
3428           Integer JavaDoc i13 = (Integer JavaDoc) record.getColumnValue(COLUMN_OFFSET + 13);
3429           Integer JavaDoc i14 = (Integer JavaDoc) record.getColumnValue(COLUMN_OFFSET + 14);
3430           objs[6] = new Integer JavaDoc(getColumnSize(characterLength,
3431                                               i12 == null ? 0 : i12.intValue(),
3432                                               i13 == null ? 0 : i13.intValue(),
3433                                               i14 == null ? 0 : i14.intValue()));
3434           objs[7] = null; //buffer length
3435
objs[8] = record.getColumnValue(COLUMN_OFFSET + 5); //decimal digits
3436
objs[9] = record.getColumnValue(COLUMN_OFFSET + 6); //decimal precision
3437
objs[12] = record.getColumnValue(COLUMN_OFFSET + 7);
3438           objs[13] = new Integer JavaDoc( ( (Short JavaDoc) objs[4]).intValue()); //sqldatatype
3439
objs[14] = new Integer JavaDoc(0); //record.getColumnValue(13);//sqlDatatimesub
3440
objs[15] = record.getColumnValue(COLUMN_OFFSET + 9); //char octet length
3441
objs[11] = "null"; //remarks
3442
objs[16] = record.getColumnValue(COLUMN_OFFSET + 10); //ordinal Position
3443
objs[17] = record.getColumnValue(COLUMN_OFFSET + 11); //nullability
3444
objs[10] = new Integer JavaDoc(getNullablility( (String JavaDoc) objs[17])); //isnullable
3445
arr.add(objs);
3446         }
3447         while (iterator.next());
3448       }
3449       Object JavaDoc[][] objs = (Object JavaDoc[][]) arr.toArray(new Object JavaDoc[arr.size()][]);
3450       int count = columnNames.length;
3451       Object JavaDoc[][] metaData = new Object JavaDoc[count][20];
3452       for (int i = 0; i < columnNames.length; i++) {
3453         metaData[i][0] = null;
3454         metaData[i][1] = null;
3455         metaData[i][2] = null;
3456         metaData[i][3] = columnNames[i];
3457         metaData[i][4] = new Integer JavaDoc(getColumnTypeForColumns(i + 1));
3458         metaData[i][5] = columnNames[i];
3459         metaData[i][6] = new Integer JavaDoc(Utilities.getPrecision(
3460             getColumnTypeForColumns(i + 1)));
3461         metaData[i][7] = null;
3462         metaData[i][8] = new Integer JavaDoc(columnNames[i].length());
3463         metaData[i][9] = getColumnTypeForColumns(i + 1) == Types.SMALLINT ?
3464             "java.lang.String" : "short";
3465         metaData[i][10] = Utilities.getCorrespondingJavaClassesOfSqlTypes(
3466             getColumnTypeForColumns(i + 1));
3467         metaData[i][11] = Utilities.getBooleanValue(false);
3468         metaData[i][12] = Utilities.getBooleanValue(false);
3469         metaData[i][13] = Utilities.getBooleanValue(false);
3470         metaData[i][14] = getColumnTypeForColumns(i + 1) == Types.SMALLINT ?
3471              Utilities.getBooleanValue(true) : Utilities.getBooleanValue(false);
3472         metaData[i][15] = Utilities.getBooleanValue(false);
3473         metaData[i][16] = Utilities.getBooleanValue(true);
3474         metaData[i][17] = Utilities.getBooleanValue(true);
3475         metaData[i][18] = Utilities.getBooleanValue(true);
3476         metaData[i][19] = new Integer JavaDoc(ResultSetMetaData.columnNullableUnknown);
3477       }
3478       TempResultSetMetaData tempMetaData = new TempResultSetMetaData(metaData);
3479       TempResultSet resultSet = new TempResultSet(objs, columnNames);
3480       resultSet.setConnection(systemConnection);
3481       resultSet.setMetaData(tempMetaData);
3482       return resultSet;
3483     }
3484     catch (DException e) {
3485       throw e.getSqlException(systemConnection.getLocale());
3486     }
3487   }
3488
3489
3490  private int getNullablility(String JavaDoc nullable) {
3491    if (nullable.equalsIgnoreCase("yes"))
3492      return columnNullable;
3493    if (nullable.equalsIgnoreCase("no"))
3494      return columnNoNulls;
3495    return columnNullableUnknown;
3496  }
3497
3498  private int getColumnTypeForColumns(int index) throws SQLException {
3499    switch (index) {
3500      case 1:
3501        return Types.VARCHAR;
3502      case 2:
3503        return Types.VARCHAR;
3504      case 3:
3505        return Types.VARCHAR;
3506      case 4:
3507        return Types.VARCHAR;
3508      case 5:
3509        return Types.SMALLINT;
3510      case 6:
3511        return Types.VARCHAR;
3512      case 7:
3513        return Types.INTEGER;
3514      case 8:
3515        return Types.NULL;
3516      case 9:
3517        return Types.INTEGER;
3518      case 10:
3519        return Types.INTEGER;
3520      case 11:
3521        return Types.INTEGER;
3522      case 12:
3523        return Types.VARCHAR;
3524      case 13:
3525        return Types.VARCHAR;
3526      case 14:
3527        return Types.INTEGER;
3528      case 15:
3529        return Types.INTEGER;
3530      case 16:
3531        return Types.INTEGER;
3532      case 17:
3533        return Types.INTEGER;
3534      case 18:
3535        return Types.VARCHAR;
3536      default:
3537        DException dex = new DException("DSE504", null);
3538        throw dex.getSqlException(systemConnection.getLocale());
3539    }
3540  }
3541
3542  private int getColumnSize(int charLength, int numPrecision,
3543                            int datePrecision, int intervalPrecision) {
3544    return charLength != 0 ? charLength
3545        : numPrecision != 0 ? numPrecision
3546        : datePrecision != 0 ? datePrecision
3547        : intervalPrecision;
3548  }
3549
3550  /**
3551   * * <OL>
3552   * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
3553   * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
3554   * <LI><B>TABLE_NAME</B> String => table name
3555   * <LI><B>TABLE_TYPE</B> String => table type. Typical types are "TABLE",
3556   * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
3557   * "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
3558   * <LI><B>REMARKS</B> String => explanatory comment on the table
3559   * </OL>
3560   * 1.TABLE_CAT
3561   * 2.TABLE_SCHEM
3562   * 3.TABLE_NAME
3563   * 4.TABLE_TYPE
3564   * 5.REMARKS
3565   */

3566  private ResultSet getTempResultSetForTables(String JavaDoc query) throws SQLException {
3567    Statement statement = systemConnection.createStatement();
3568    return statement.executeQuery(query);
3569  }
3570
3571  /**
3572   * <OL>
3573   * <LI><B>TABLE_SCHEM</B> String => schema name
3574   * </OL>
3575   * 1.TABLE_SCHEM
3576   */

3577
3578  private ResultSet getTempResultSetForSchemas(String JavaDoc query) throws
3579      SQLException {
3580    Statement statement = systemConnection.createStatement();
3581    return statement.executeQuery(query);
3582  }
3583
3584  /**
3585   * <OL>
3586   * <LI><B>TABLE_CAT</B> String => schema name
3587   * </OL>
3588   * 1.TABLE_CAT
3589   */

3590
3591  private ResultSet getTempResultSetForCatalogs(String JavaDoc query) throws
3592      SQLException {
3593    Statement statement = systemConnection.createStatement();
3594    return statement.executeQuery(query);
3595  }
3596
3597  /**
3598   * <OL>
3599   * <LI><B>PROCEDURE_CAT</B> String => procedure catalog (may be null)
3600   * <LI><B>PROCEDURE_SCHEM</B> String => procedure schema (may be null)
3601   * <LI><B>PROCEDURE_NAME</B> String => procedure name
3602   * <LI> reserved for future use
3603   * <LI> reserved for future use
3604   * <LI> reserved for future use
3605   * <LI><B>REMARKS</B> String => explanatory comment on the procedure
3606   * <LI><B>PROCEDURE_TYPE</B> short => kind of procedure:
3607   * <UL>
3608   * <LI> procedureResultUnknown - May return a result
3609   * <LI> procedureNoResult - Does not return a result
3610   * <LI> procedureReturnsResult - Returns a result
3611   * </UL>
3612   * </OL>
3613   * 1.PROCEDURE_CAT
3614   * 2.PROCEDURE_SCHEM
3615   * 3.PROCEDURE_NAME
3616   * 4.REMARKS
3617   * 5.PROCEDURE_TYPE
3618   */

3619  private ResultSet getTempResultSetForProcedures(String JavaDoc query) throws
3620      SQLException {
3621    Statement statement = systemConnection.createStatement();
3622    return statement.executeQuery(query);
3623  }
3624
3625  /**
3626   * <OL>
3627   * <LI><B>PROCEDURE_CAT</B> String => procedure catalog (may be null)
3628   * <LI><B>PROCEDURE_SCHEM</B> String => procedure schema (may be null)
3629   * <LI><B>PROCEDURE_NAME</B> String => procedure name
3630   * <LI><B>COLUMN_NAME</B> String => column/parameter name
3631   * <LI><B>COLUMN_TYPE</B> Short => kind of column/parameter:
3632   * <UL>
3633   * <LI> procedureColumnUnknown - nobody knows
3634   * <LI> procedureColumnIn - IN parameter
3635   * <LI> procedureColumnInOut - INOUT parameter
3636   * <LI> procedureColumnOut - OUT parameter
3637   * <LI> procedureColumnReturn - procedure return value
3638   * <LI> procedureColumnResult - result column in <code>ResultSet</code>
3639   * </UL>
3640   * <LI><B>DATA_TYPE</B> short => SQL type from java.sql.Types
3641   * <LI><B>TYPE_NAME</B> String => SQL type name, for a UDT type the
3642   * type name is fully qualified
3643   * <LI><B>PRECISION</B> int => precision
3644   * <LI><B>LENGTH</B> int => length in bytes of data
3645   * <LI><B>SCALE</B> short => scale
3646   * <LI><B>RADIX</B> short => radix
3647   * <LI><B>NULLABLE</B> short => can it contain NULL?
3648   * <UL>
3649   * <LI> procedureNoNulls - does not allow NULL values
3650   * <LI> procedureNullable - allows NULL values
3651   * <LI> procedureNullableUnknown - nullability unknown
3652   * </UL>
3653   * <LI><B>REMARKS</B> String => comment describing parameter/column
3654   * </OL>
3655   * 1.PROCEDURE_CAT
3656   * 2.PROCEDURE_SCHEM
3657   * 3.PROCEDURE_NAME
3658   * 4.COLUMN_NAME
3659   * 5.COLUMN_TYPE
3660   * 6.DATA_TYPE
3661   * 7.TYPE_NAME
3662   * 8.PRECISION
3663   * 9.LENGTH
3664   * 10.SCALE
3665   * 11.RADIX
3666   * 12.NULLABLE
3667   * 13.REMARKS
3668   */

3669  private ResultSet getTempResultSetForProcedureColumns(String JavaDoc query) throws
3670      SQLException {
3671    String JavaDoc[] columnNames = new String JavaDoc[] {
3672        "PROCEDURE_CAT", "PROCEDURE_SCHEM", "PROCEDURE_NAME", "COLUMN_NAME",
3673        "COLUMN_TYPE", "DATA_TYPE", "TYPE_NAME", "PRECISION", "LENGTH",
3674        "SCALE", "RADIX", "NULLABLE", "REMARKS"};
3675    TempResultSet resultSet = null;
3676    ArrayList arr = new ArrayList();
3677    /*if(iterator.top()){
3678      do{
3679          _Record record = iterator.getRecord();
3680          Object[] objs1 = new Object[14];
3681          int j = 0;
3682          for(; j < 9 ; j++)
3683             objs1[j] = iterator.getColumnValue(COLUMN_OFFSET + j);
3684          objs1[j++] = new Short((short)getUpdateDeleteRule((String)iterator.getColumnValue(COLUMN_OFFSET + 9)));
3685          objs1[j++] = new Short((short)getUpdateDeleteRule((String)iterator.getColumnValue(COLUMN_OFFSET + 10)));
3686          objs1[j++] = iterator.getColumnValue(COLUMN_OFFSET + 11);
3687          objs1[j++] = iterator.getColumnValue(COLUMN_OFFSET + 12);
3688          objs1[j++] = new Short((short)getDeferrability((String)iterator.getColumnValue(COLUMN_OFFSET + 13),(String)iterator.getColumnValue(COLUMN_OFFSET + 14)));
3689          arr.add(objs1);
3690       }while(iterator.next());
3691              }*/

3692    Object JavaDoc[][] objs = (Object JavaDoc[][]) arr.toArray(new Object JavaDoc[arr.size()][]);
3693    int rowCount = columnNames.length;
3694    Object JavaDoc[][] metaData = new Object JavaDoc[rowCount][20];
3695    try {
3696      for (int i = 0; i < columnNames.length; i++) {
3697        metaData[i][0] = null;
3698        metaData[i][1] = null;
3699        metaData[i][2] = null;
3700        metaData[i][3] = columnNames[i];
3701        metaData[i][4] = new Integer JavaDoc(getColumnTypeForProcedureColumns(i + 1));
3702        metaData[i][5] = columnNames[i];
3703        metaData[i][6] = new Integer JavaDoc(Utilities.getPrecision(
3704            getColumnTypeForProcedureColumns(i + 1)));
3705        metaData[i][7] = null;
3706        metaData[i][8] = new Integer JavaDoc(columnNames[i].length());
3707        metaData[i][9] = getColumnTypeForProcedureColumns(i + 1) ==
3708            Types.SMALLINT ? "short" : "java.lang.String"; // Changes according to Manoj dated 20/05/04 by Harvinder
3709
metaData[i][10] = Utilities.getCorrespondingJavaClassesOfSqlTypes(
3710            getColumnTypeForProcedureColumns(i + 1));
3711        metaData[i][11] = Utilities.getBooleanValue(false);
3712        metaData[i][12] = Utilities.getBooleanValue(false);
3713        metaData[i][13] = Utilities.getBooleanValue(false);
3714        metaData[i][14] = getColumnTypeForProcedureColumns(i + 1) ==
3715            Types.SMALLINT ? Utilities.getBooleanValue(true) : Utilities.getBooleanValue(false);
3716        metaData[i][15] = Utilities.getBooleanValue(false);
3717        metaData[i][16] = Utilities.getBooleanValue(true);
3718        metaData[i][17] = Utilities.getBooleanValue(true);
3719        metaData[i][18] = Utilities.getBooleanValue(true);
3720        metaData[i][19] = new Integer JavaDoc(ResultSetMetaData.columnNullableUnknown);
3721      }
3722      TempResultSetMetaData tempMetaData = new TempResultSetMetaData(metaData);
3723      resultSet = new TempResultSet(objs, columnNames);
3724      resultSet.setConnection(systemConnection);
3725      resultSet.setMetaData(tempMetaData);
3726      return resultSet;
3727    }
3728    catch (DException des) {
3729      throw des.getSqlException(systemConnection.getLocale());
3730    }
3731  }
3732
3733  private int getColumnTypeForProcedureColumns(int index) throws SQLException {
3734    switch (index) {
3735      case 1:
3736        return Types.VARCHAR;
3737      case 2:
3738        return Types.VARCHAR;
3739      case 3:
3740        return Types.VARCHAR;
3741      case 4:
3742        return Types.VARCHAR;
3743      case 5:
3744        return Types.SMALLINT;
3745      case 6:
3746        return Types.SMALLINT;
3747      case 7:
3748        return Types.VARCHAR;
3749      case 8:
3750        return Types.INTEGER;
3751      case 9:
3752        return Types.INTEGER;
3753      case 10:
3754        return Types.SMALLINT;
3755      case 11:
3756        return Types.SMALLINT;
3757      case 12:
3758        return Types.SMALLINT;
3759      case 13:
3760        return Types.VARCHAR;
3761      default:
3762        DException dex = new DException("DSE504", null);
3763        throw dex.getSqlException(systemConnection.getLocale());
3764    }
3765  }
3766
3767  /**
3768   * <OL>
3769   * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
3770   * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
3771   * <LI><B>TABLE_NAME</B> String => table name
3772   * <LI><B>NON_UNIQUE</B> boolean => Can index values be non-unique?
3773   * false when TYPE is tableIndexStatistic
3774   * <LI><B>INDEX_QUALIFIER</B> String => index catalog (may be null);
3775   * null when TYPE is tableIndexStatistic
3776   * <LI><B>INDEX_NAME</B> String => index name; null when TYPE is
3777   * tableIndexStatistic
3778   * <LI><B>TYPE</B> short => index type:
3779   * <UL>
3780   * <LI> tableIndexStatistic - this identifies table statistics that are
3781   * returned in conjuction with a table's index descriptions
3782   * <LI> tableIndexClustered - this is a clustered index
3783   * <LI> tableIndexHashed - this is a hashed index
3784   * <LI> tableIndexOther - this is some other style of index
3785   * </UL>
3786   * <LI><B>ORDINAL_POSITION</B> short => column sequence number
3787   * within index; zero when TYPE is tableIndexStatistic
3788   * <LI><B>COLUMN_NAME</B> String => column name; null when TYPE is
3789   * tableIndexStatistic
3790   * <LI><B>ASC_OR_DESC</B> String => column sort sequence, "A" => ascending,
3791   * "D" => descending, may be null if sort sequence is not supported;
3792   * null when TYPE is tableIndexStatistic
3793   * <LI><B>CARDINALITY</B> int => When TYPE is tableIndexStatistic, then
3794   * this is the number of rows in the table; otherwise, it is the
3795   * number of unique values in the index.
3796   * <LI><B>PAGES</B> int => When TYPE is tableIndexStatisic then
3797   * this is the number of pages used for the table, otherwise it
3798   * is the number of pages used for the current index.
3799   * <LI><B>FILTER_CONDITION</B> String => Filter condition, if any.
3800   * (may be null)
3801   * </OL>
3802   * 1.TABLE_CAT
3803   * 2.TABLE_SCHEM
3804   * 3.TABLE_NAME
3805   * 4.NON_UNIQUE
3806   * 5.INDEX_QUALIFIER
3807   * 6.INDEX_NAME
3808   * 7.TYPE
3809   * 8.ORDINAL_POSITION
3810   * 9.COLUMN_NAME
3811   * 10.ASC_OR_DESC
3812   * 11.CARDINALITY
3813   * 12.PAGES
3814   * 13.FILTER_CONDITION
3815   */

3816  private ResultSet getTempResultSetForIndexInfo(String JavaDoc query) throws
3817      SQLException {
3818    String JavaDoc[] columnNames = new String JavaDoc[] {
3819        "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "NON_UNIQUE",
3820        "INDEX_QUALIFIER", "INDEX_NAME", "TYPE", "ORDINAL_POSITION",
3821        "COLUMN_NAME",
3822        "ASC_OR_DESC", "CARDINALITY", "PAGES", "FILTER_CONDITION"};
3823    TempResultSet resultSet = null;
3824    _RecordSetBuffer recordSetBuffer = getRecordSetBuffer(query);
3825    _RecordSetBufferIterator iterator = recordSetBuffer.getIterator();
3826    ArrayList arr = new ArrayList();
3827    if (iterator.top()) {
3828      do {
3829        _Record record = iterator.getRecord();
3830        Object JavaDoc[] objs1 = new Object JavaDoc[13];
3831        int j = 0;
3832        for (; j < 3; j++)
3833          objs1[j] = iterator.getColumnValue(COLUMN_OFFSET + j);
3834        objs1[j++] = Boolean.TRUE;
3835        objs1[j++] = null;
3836        objs1[j++] = iterator.getColumnValue(COLUMN_OFFSET + 3);
3837        objs1[j++] = new Short JavaDoc(tableIndexOther);
3838        objs1[j++] = new Short JavaDoc( ( (Integer JavaDoc) iterator.getColumnValue(
3839            COLUMN_OFFSET + 4)).shortValue());
3840        objs1[j++] = iterator.getColumnValue(COLUMN_OFFSET + 5);
3841        objs1[j++] = iterator.getColumnValue(COLUMN_OFFSET +
3842            6).equals(Boolean.TRUE) ? "A" : "D";
3843        objs1[j++] = null;
3844        objs1[j++] = null;
3845        objs1[j++] = null;
3846        arr.add(objs1);
3847      }
3848      while (iterator.next());
3849    }
3850    Object JavaDoc[][] objs = (Object JavaDoc[][]) arr.toArray(new Object JavaDoc[arr.size()][]);
3851    int rowCount = columnNames.length;
3852    Object JavaDoc[][] metaData = new Object JavaDoc[rowCount][20];
3853    try {
3854      for (int i = 0; i < columnNames.length; i++) {
3855        metaData[i][0] = null;
3856        metaData[i][1] = null;
3857        metaData[i][2] = null;
3858        metaData[i][3] = columnNames[i];
3859        metaData[i][4] = new Integer JavaDoc(getColumnTypeForIndexInfo(i + 1));
3860        metaData[i][5] = columnNames[i];
3861        metaData[i][6] = new Integer JavaDoc(Utilities.getPrecision(
3862            getColumnTypeForProcedureColumns(i + 1)));
3863        metaData[i][7] = null;
3864        metaData[i][8] = new Integer JavaDoc(columnNames[i].length());
3865        metaData[i][9] = getColumnTypeForIndexInfo(i + 1) == Types.SMALLINT ?
3866            "java.lang.String" : "short";
3867        metaData[i][10] = Utilities.getCorrespondingJavaClassesOfSqlTypes(
3868            getColumnTypeForIndexInfo(i + 1));
3869        metaData[i][11] = Utilities.getBooleanValue(false);
3870        metaData[i][12] = Utilities.getBooleanValue(false);
3871        metaData[i][13] = Utilities.getBooleanValue(false);
3872        metaData[i][14] = getColumnTypeForIndexInfo(i + 1) == Types.SMALLINT ?
3873             Utilities.getBooleanValue(true) : Utilities.getBooleanValue(false);
3874        metaData[i][15] = Utilities.getBooleanValue(false);
3875        metaData[i][16] = Utilities.getBooleanValue(true);
3876        metaData[i][17] = Utilities.getBooleanValue(true);
3877        metaData[i][18] = Utilities.getBooleanValue(true);
3878        metaData[i][19] = new Integer JavaDoc(ResultSetMetaData.columnNullableUnknown);
3879      }
3880      TempResultSetMetaData tempMetaData = new TempResultSetMetaData(metaData);
3881      resultSet = new TempResultSet(objs, columnNames);
3882      resultSet.setConnection(systemConnection);
3883      resultSet.setMetaData(tempMetaData);
3884      return resultSet;
3885    }
3886    catch (DException dse) {
3887      throw dse.getSqlException(systemConnection.getLocale());
3888    }
3889  }
3890
3891  private int getColumnTypeForIndexInfo(int index) throws SQLException {
3892    switch (index) {
3893      case 1:
3894        return Types.VARCHAR;
3895      case 2:
3896        return Types.VARCHAR;
3897      case 3:
3898        return Types.VARCHAR;
3899      case 4:
3900        return Types.BIT;
3901      case 5:
3902        return Types.VARCHAR;
3903      case 6:
3904        return Types.VARCHAR;
3905      case 7:
3906        return Types.SMALLINT;
3907      case 8:
3908        return Types.SMALLINT;
3909      case 9:
3910        return Types.VARCHAR;
3911      case 10:
3912        return Types.VARCHAR;
3913      case 11:
3914        return Types.INTEGER;
3915      case 12:
3916        return Types.INTEGER;
3917      case 13:
3918        return Types.VARCHAR;
3919      default:
3920        DException dex = new DException("DSE504", null);
3921        throw dex.getSqlException(systemConnection.getLocale());
3922    }
3923  }
3924
3925  /**
3926   * <OL>
3927   * <LI><B>SCOPE</B> short => actual scope of result
3928   * <UL>
3929   * <LI> bestRowTemporary - very temporary, while using row
3930   * <LI> bestRowTransaction - valid for remainder of current transaction
3931   * <LI> bestRowSession - valid for remainder of current session
3932   * </UL>
3933   * <LI><B>COLUMN_NAME</B> String => column name
3934   * <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
3935   * <LI><B>TYPE_NAME</B> String => Data source dependent type name,
3936   * for a UDT the type name is fully qualified
3937   * <LI><B>COLUMN_SIZE</B> int => precision
3938   * <LI><B>BUFFER_LENGTH</B> int => not used
3939   * <LI><B>DECIMAL_DIGITS</B> short => scale
3940   * <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column
3941   * like an Oracle ROWID
3942   * <UL>
3943   * <LI> bestRowUnknown - may or may not be pseudo column
3944   * <LI> bestRowNotPseudo - is NOT a pseudo column
3945   * <LI> bestRowPseudo - is a pseudo column
3946   * </UL>
3947   * </OL>
3948   * 1.SCOPE
3949   * 2.COLUMN_NAME
3950   * 3.DATA_TYPE
3951   * 4.TYPE_NAME
3952   * 5.COLUMN_SIZE
3953   * 6.BUFFER_LENGTH
3954   * 7.DECIMAL_DIGITS
3955   * 8.PSEUDO_COLUMN
3956   */

3957  private ResultSet getTempResultSetForBestRowIdentifier(String JavaDoc query) throws
3958      SQLException {
3959    String JavaDoc[] columnNames = new String JavaDoc[] {
3960        "SCOPE", "COLUMN_NAME", "DATA_TYPE",
3961        "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH", "DECIMAL_DIGITS",
3962        "PSEUDO_COLUMN"};
3963    TempResultSet resultSet = null;
3964    ArrayList arr = new ArrayList();
3965    /*if(iterator.top()){
3966       do{
3967          Object[] objs1 = new Object[14];
3968          _Record record = iterator.getRecord();
3969          int j = 0;
3970          for(; j < 9 ; j++)
3971             objs1[j] = iterator.getColumnValue(COLUMN_OFFSET + j);
3972          objs1[j++] = new Short((short)getUpdateDeleteRule((String)iterator.getColumnValue(COLUMN_OFFSET + 9)));
3973          objs1[j++] = new Short((short)getUpdateDeleteRule((String)iterator.getColumnValue(COLUMN_OFFSET + 10)));
3974          objs1[j++] = iterator.getColumnValue(COLUMN_OFFSET + 11);
3975          objs1[j++] = iterator.getColumnValue(COLUMN_OFFSET + 12);
3976          objs1[j++] = new Short((short)getDeferrability((String)iterator.getColumnValue(13),(String)iterator.getColumnValue(COLUMN_OFFSET + 14)));
3977          arr.add(objs1);
3978       }while(iterator.next());
3979           }*/

3980    Object JavaDoc[][] objs = (Object JavaDoc[][]) arr.toArray(new Object JavaDoc[arr.size()][]);
3981    resultSet = new TempResultSet(objs, columnNames);
3982    resultSet.setConnection(systemConnection);
3983    int rowCount = columnNames.length;
3984    Object JavaDoc[][] metaData = new Object JavaDoc[rowCount][20];
3985    try {
3986      for (int i = 0; i < columnNames.length; i++) {
3987        metaData[i][0] = null;
3988        metaData[i][1] = null;
3989        metaData[i][2] = null;
3990        metaData[i][3] = columnNames[i];
3991        metaData[i][4] = new Integer JavaDoc(getColumnTypeForBestRowIdentifier(i + 1));
3992        metaData[i][5] = columnNames[i];
3993        metaData[i][6] = new Integer JavaDoc(Utilities.getPrecision(
3994            getColumnTypeForBestRowIdentifier(i + 1)));
3995        metaData[i][7] = null;
3996        metaData[i][8] = new Integer JavaDoc(columnNames[i].length());
3997        metaData[i][9] = getColumnTypeForBestRowIdentifier(i + 1) ==
3998            Types.SMALLINT ? "java.lang.String" : "short";
3999        metaData[i][10] = Utilities.getCorrespondingJavaClassesOfSqlTypes(
4000            getColumnTypeForBestRowIdentifier(i + 1));
4001        metaData[i][11] = Utilities.getBooleanValue(false);
4002        metaData[i][12] = Utilities.getBooleanValue(false);
4003        metaData[i][13] = Utilities.getBooleanValue(false);
4004        metaData[i][14] = getColumnTypeForBestRowIdentifier(i + 1) ==
4005            Types.SMALLINT ? Utilities.getBooleanValue(true) : Utilities.getBooleanValue(false);
4006        metaData[i][15] = Utilities.getBooleanValue(false);
4007        metaData[i][16] = Utilities.getBooleanValue(true);
4008        metaData[i][17] = Utilities.getBooleanValue(true);
4009        metaData[i][18] = Utilities.getBooleanValue(true);
4010        metaData[i][19] = new Integer JavaDoc(ResultSetMetaData.columnNullableUnknown);
4011      }
4012      TempResultSetMetaData tempMetaData = new TempResultSetMetaData(metaData);
4013      resultSet.setMetaData(tempMetaData);
4014      resultSet.setConnection(systemConnection);
4015      return resultSet;
4016    }
4017    catch (DException dse) {
4018      throw dse.getSqlException(systemConnection.getLocale());
4019    }
4020  }
4021
4022  private int getColumnTypeForBestRowIdentifier(int index) throws SQLException {
4023    switch (index) {
4024      case 1:
4025        return Types.SMALLINT;
4026      case 2:
4027        return Types.VARCHAR;
4028      case 3:
4029        return Types.SMALLINT;
4030      case 4:
4031        return Types.VARCHAR;
4032      case 5:
4033        return Types.INTEGER;
4034      case 6:
4035        return Types.INTEGER;
4036      case 7:
4037        return Types.SMALLINT;
4038      case 8:
4039        return Types.SMALLINT;
4040      default:
4041        DException dex = new DException("DSE504", null);
4042        throw dex.getSqlException(systemConnection.getLocale());
4043    }
4044  }
4045
4046  private ResultSet getTempResultSetForUDTs(String JavaDoc query) throws SQLException {
4047    DException dex = new DException("DSE16",
4048                                    new Object JavaDoc[] {"getTempResultSetForUDTs"});
4049    throw dex.getSqlException(systemConnection.getLocale());
4050  }
4051
4052  /**
4053   * <OL>
4054   * <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
4055   * <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
4056   * <LI><B>PKTABLE_NAME</B> String => primary key table name
4057   * <LI><B>PKCOLUMN_NAME</B> String => primary key column name
4058   * <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
4059   * being exported (may be null)
4060   * <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
4061   * being exported (may be null)
4062   * <LI><B>FKTABLE_NAME</B> String => foreign key table name
4063   * being exported
4064   * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
4065   * being exported
4066   * <LI><B>KEY_SEQ</B> short => sequence number within foreign key
4067   * <LI><B>UPDATE_RULE</B> short => What happens to
4068   * foreign key when primary is updated:
4069   * <UL>
4070   * <LI> importedNoAction - do not allow update of primary
4071   * key if it has been imported
4072   * <LI> importedKeyCascade - change imported key to agree
4073   * with primary key update
4074   * <LI> importedKeySetNull - change imported key to NULL if
4075   * its primary key has been updated
4076   * <LI> importedKeySetDefault - change imported key to default values
4077   * if its primary key has been updated
4078   * <LI> importedKeyRestrict - same as importedKeyNoAction
4079   * (for ODBC 2.x compatibility)
4080   * </UL>
4081   * <LI><B>DELETE_RULE</B> short => What happens to
4082   * the foreign key when primary is deleted.
4083   * <UL>
4084   * <LI> importedKeyNoAction - do not allow delete of primary
4085   * key if it has been imported
4086   * <LI> importedKeyCascade - delete rows that import a deleted key
4087   * <LI> importedKeySetNull - change imported key to NULL if
4088   * its primary key has been deleted
4089   * <LI> importedKeyRestrict - same as importedKeyNoAction
4090   * (for ODBC 2.x compatibility)
4091   * <LI> importedKeySetDefault - change imported key to default if
4092   * its primary key has been deleted
4093   * </UL>
4094   * <LI><B>FK_NAME</B> String => foreign key name (may be null)
4095   * <LI><B>PK_NAME</B> String => primary key name (may be null)
4096   * <LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key
4097   * constraints be deferred until commit
4098   * <UL>
4099   * <LI> importedKeyInitiallyDeferred - see SQL92 for definition
4100   * <LI> importedKeyInitiallyImmediate - see SQL92 for definition
4101   * <LI> importedKeyNotDeferrable - see SQL92 for definition
4102   * </UL>
4103   * </OL>
4104   * 1.PKTABLE_CAT
4105   * 2.PKTABLE_SCHEM
4106   * 3.PKTABLE_NAME
4107   * 4.PKCOLUMN_NAME
4108   * 5.FKTABLE_CAT
4109   * 6.FKTABLE_SCHEM
4110   * 7.FKTABLE_NAME
4111   * 8.FKCOLUMN_NAME
4112   * 9.KEY_SEQ
4113   * 10.UPDATE_RULE
4114   * 11.DELETE_RULE
4115   * 12.FK_NAME
4116   * 13.PK_NAME
4117   * 14.DEFERRABILITY
4118   */

4119
4120  private ResultSet getTempResultSetForCrossReference(String JavaDoc query) throws
4121      SQLException {
4122    String JavaDoc[] columnNames = new String JavaDoc[] {
4123        "PKTABLE_CAT", "PKTABLE_SCHEM", "PKTABLE_NAME",
4124        "PKCOLUMN_NAME", "FKTABLE_CAT", "FKTABLE_SCHEM", "FKTABLE_NAME",
4125        "FKCOLUMN_NAME",
4126        "KEY_SEQ", "UPDATE_RULE", "DELETE_RULE", "FK_NAME", "PK_NAME",
4127        "DEFERRABILITY"};
4128    _RecordSetBuffer recordSetBuffer = getRecordSetBuffer(query);
4129    _RecordSetBufferIterator iterator = recordSetBuffer.getIterator();
4130    ArrayList arr = new ArrayList();
4131    if (iterator.top()) {
4132      do {
4133        Object JavaDoc[] objs = new Object JavaDoc[14];
4134        _Record record = iterator.getRecord();
4135        int j = 0;
4136        for (; j < 9; j++)
4137          objs[j] = iterator.getColumnValue(COLUMN_OFFSET + j);
4138        objs[j++] = new Short JavaDoc( (short) getUpdateDeleteRule( (String JavaDoc) iterator.
4139            getColumnValue(COLUMN_OFFSET + 9)));
4140        objs[j++] = new Short JavaDoc( (short) getUpdateDeleteRule( (String JavaDoc) iterator.
4141            getColumnValue(COLUMN_OFFSET + 10)));
4142        objs[j++] = iterator.getColumnValue(COLUMN_OFFSET + 11);
4143        objs[j++] = iterator.getColumnValue(COLUMN_OFFSET + 12);
4144        objs[j++] = new Short JavaDoc( (short) getDeferrability( (String JavaDoc) iterator.
4145            getColumnValue(COLUMN_OFFSET + 13),
4146                              (String JavaDoc) iterator.getColumnValue(14)));
4147        arr.add(objs);
4148      }
4149      while (iterator.next());
4150    }
4151    Object JavaDoc[][] objs = (Object JavaDoc[][]) arr.toArray(new Object JavaDoc[arr.size()][]);
4152    int rowCount = columnNames.length;
4153    Object JavaDoc[][] metaData = new Object JavaDoc[rowCount][20];
4154    try {
4155      for (int i = 0; i < rowCount; i++) {
4156        metaData[i][0] = null;
4157        metaData[i][1] = null;
4158        metaData[i][2] = null;
4159        metaData[i][3] = columnNames[i];
4160        metaData[i][4] = new Integer JavaDoc(getColumnTypeForCrossReference(i + 1));
4161        metaData[i][5] = columnNames[i];
4162        metaData[i][6] = new Integer JavaDoc(Utilities.getPrecision(
4163            getColumnTypeForCrossReference(i + 1)));
4164        metaData[i][7] = null;
4165        metaData[i][8] = new Integer JavaDoc(columnNames[i].length());
4166        metaData[i][9] = getColumnTypeForCrossReference(i + 1) ==
4167            Types.SMALLINT ? "java.lang.String" : "short";
4168        metaData[i][10] = Utilities.getCorrespondingJavaClassesOfSqlTypes(
4169            getColumnTypeForCrossReference(i + 1));
4170        metaData[i][11] = Utilities.getBooleanValue(false);
4171        metaData[i][12] = Utilities.getBooleanValue(false);
4172        metaData[i][13] = Utilities.getBooleanValue(false);
4173        metaData[i][14] = getColumnTypeForCrossReference(i + 1) ==
4174            Types.SMALLINT ? Utilities.getBooleanValue(true) : Utilities.getBooleanValue(false);
4175        metaData[i][15] = Utilities.getBooleanValue(false);
4176        metaData[i][16] = Utilities.getBooleanValue(true);
4177        metaData[i][17] = Utilities.getBooleanValue(true);
4178        metaData[i][18] = Utilities.getBooleanValue(true);
4179        metaData[i][19] = new Integer JavaDoc(ResultSetMetaData.columnNullableUnknown);
4180      }
4181      TempResultSetMetaData tempMetaData = new TempResultSetMetaData(metaData);
4182      TempResultSet resultSet = new TempResultSet(objs, columnNames);
4183      resultSet.setConnection(systemConnection);
4184      resultSet.setMetaData(tempMetaData);
4185      return resultSet;
4186    }
4187    catch (DException dse) {
4188      throw dse.getSqlException(systemConnection.getLocale());
4189    }
4190  }
4191
4192  private int getColumnTypeForCrossReference(int index) throws SQLException {
4193    switch (index) {
4194      case 1:
4195        return Types.VARCHAR;
4196      case 2:
4197        return Types.VARCHAR;
4198      case 3:
4199        return Types.VARCHAR;
4200      case 4:
4201        return Types.VARCHAR;
4202      case 5:
4203        return Types.VARCHAR;
4204      case 6:
4205        return Types.VARCHAR;
4206      case 7:
4207        return Types.VARCHAR;
4208      case 8:
4209        return Types.VARCHAR;
4210      case 9:
4211        return Types.SMALLINT;
4212      case 10:
4213        return Types.SMALLINT;
4214      case 11:
4215        return Types.SMALLINT;
4216      case 12:
4217        return Types.VARCHAR;
4218      case 13:
4219        return Types.VARCHAR;
4220      case 14:
4221        return Types.SMALLINT;
4222      default:
4223        DException dex = new DException("DSE504", null);
4224        throw dex.getSqlException(systemConnection.getLocale());
4225    }
4226  }
4227
4228  public int getDeferrability(String JavaDoc deferrability, String JavaDoc initiallyDeferrable) {
4229    if (deferrability.equalsIgnoreCase("no"))
4230      return importedKeyNotDeferrable;
4231    return initiallyDeferrable.equalsIgnoreCase("yes") ?
4232        importedKeyInitiallyDeferred
4233        : importedKeyInitiallyImmediate;
4234  }
4235
4236  private int getUpdateDeleteRule(String JavaDoc OnUpdateDelete) {
4237    if (OnUpdateDelete.equalsIgnoreCase("no action"))
4238      return importedKeyNoAction;
4239    if (OnUpdateDelete.equalsIgnoreCase("cascade"))
4240      return importedKeyCascade;
4241    if (OnUpdateDelete.equalsIgnoreCase("set null"))
4242      return importedKeySetDefault;
4243    if (OnUpdateDelete.equalsIgnoreCase("restrict"))
4244      return importedKeyRestrict;
4245    return importedKeySetDefault;
4246  }
4247
4248  /**
4249   * Same As Cross Reference
4250   */

4251
4252  private ResultSet getTempResultSetForImportedKeys(String JavaDoc query) throws
4253      SQLException {
4254    return getTempResultSetForCrossReference(query);
4255  }
4256
4257  /**
4258   * Same As Cross Reference
4259   */

4260
4261  private ResultSet getTempResultSetForExportedKeys(String JavaDoc query) throws
4262      SQLException {
4263    return getTempResultSetForCrossReference(query);
4264  }
4265
4266  /**
4267   * <OL>
4268   * <LI><B>TABLE_CAT</B> String => table catalog (may be null)
4269   * <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
4270   * <LI><B>TABLE_NAME</B> String => table name
4271   * <LI><B>COLUMN_NAME</B> String => column name
4272   * <LI><B>KEY_SEQ</B> short => sequence number within primary key
4273   * <LI><B>PK_NAME</B> String => primary key name (may be null)
4274   * </OL>
4275   * 1.TABLE_CAT
4276   * 2.TABLE_SCHEM
4277   * 3.TABLE_NAME
4278   * 4.COLUMN_NAME
4279   * 5.KEY_SEQ
4280   * 6.PK_NAME
4281   */

4282  private ResultSet getTempResultSetForPrimaryKeys(String JavaDoc query) throws
4283      SQLException {
4284    Statement statement = systemConnection.createStatement();
4285    return statement.executeQuery(query);
4286  }
4287
4288  /**
4289   * <OL>
4290   * <LI><B>SCOPE</B> short => is not used
4291   * <LI><B>COLUMN_NAME</B> String => column name
4292   * <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
4293   * <LI><B>TYPE_NAME</B> String => Data source dependent type name
4294   * <LI><B>COLUMN_SIZE</B> int => precision
4295   * <LI><B>BUFFER_LENGTH</B> int => length of column value in bytes
4296   * <LI><B>DECIMAL_DIGITS</B> short => scale
4297   * <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column
4298   * like an Oracle ROWID
4299   * <UL>
4300   * <LI> versionColumnUnknown - may or may not be pseudo column
4301   * <LI> versionColumnNotPseudo - is NOT a pseudo column
4302   * <LI> versionColumnPseudo - is a pseudo column
4303   * </UL>
4304   * </OL>
4305   * 1.SCOPE
4306   * 2.COLUMN_NAME
4307   * 3.DATA_TYPE
4308   * 4.TYPE_NAME
4309   * 5.COLUMN_SIZE
4310   * 6.BUFFER_LENGTH
4311   * 7.DECIMAL_DIGITS
4312   * 8.PSEUDO_COLUMN
4313   */

4314  private ResultSet getTempResultSetForVersionColumns(String JavaDoc query) throws
4315      SQLException {
4316    String JavaDoc[] columnNames = new String JavaDoc[] {
4317        "SCOPE", "COLUMN_NAME", "DATA_TYPE", "TYPE_NAME",
4318        "COLUMN_SIZE", "BUFFER_LENGTH", "DECIMAL_DIGITS", "PSEUDO_COLUMN"};
4319    TempResultSet resultSet = null;
4320    ArrayList arr = new ArrayList();
4321    /*if(iterator.top()){
4322       do{
4323          _Record record = iterator.getRecord();
4324          Object[] objs = new Object[14];
4325          int j = 0;
4326          for(; j < 9 ; j++)
4327             objs[j] = iterator.getColumnValue(COLUMN_OFFSET + j);
4328          objs[j++] = new Short((short)getUpdateDeleteRule((String)iterator.getColumnValue(COLUMN_OFFSET + 9)));
4329          objs[j++] = new Short((short)getUpdateDeleteRule((String)iterator.getColumnValue(COLUMN_OFFSET + 10)));
4330          objs[j++] = iterator.getColumnValue(COLUMN_OFFSET + 11);
4331          objs[j++] = iterator.getColumnValue(COLUMN_OFFSET + 12);
4332          objs[j++] = new Short((short)getDeferrability((String)iterator.getColumnValue(COLUMN_OFFSET + 13),(String)iterator.getColumnValue(COLUMN_OFFSET + 14)));
4333          arr.add(objs);
4334      }while(iterator.next());
4335           }*/

4336    Object JavaDoc[][] objs = (Object JavaDoc[][]) arr.toArray(new Object JavaDoc[arr.size()][]);
4337    int rowCount = columnNames.length;
4338    Object JavaDoc[][] metaData = new Object JavaDoc[rowCount][20];
4339    try {
4340      for (int i = 0; i < columnNames.length; i++) {
4341        metaData[i][0] = null;
4342        metaData[i][1] = null;
4343        metaData[i][2] = null;
4344        metaData[i][3] = columnNames[i];
4345        metaData[i][4] = new Integer JavaDoc(getColumnTypeForVersionColumns(i + 1));
4346        metaData[i][5] = columnNames[i];
4347        metaData[i][6] = new Integer JavaDoc(Utilities.getPrecision(
4348            getColumnTypeForVersionColumns(i + 1)));
4349        metaData[i][7] = null;
4350        metaData[i][8] = new Integer JavaDoc(columnNames[i].length());
4351        metaData[i][9] = getColumnTypeForVersionColumns(i + 1) ==
4352            Types.SMALLINT ? "java.lang.String" : "short";
4353        metaData[i][10] = Utilities.getCorrespondingJavaClassesOfSqlTypes(
4354            getColumnTypeForVersionColumns(i + 1));
4355        metaData[i][11] = Utilities.getBooleanValue(false);
4356        metaData[i][12] = Utilities.getBooleanValue(false);
4357        metaData[i][13] = Utilities.getBooleanValue(false);
4358        metaData[i][14] = getColumnTypeForVersionColumns(i + 1) ==
4359            Types.SMALLINT ? Utilities.getBooleanValue(true) : Utilities.getBooleanValue(false);
4360        metaData[i][15] = Utilities.getBooleanValue(false);
4361        metaData[i][16] = Utilities.getBooleanValue(true);
4362        metaData[i][17] = Utilities.getBooleanValue(true);
4363        metaData[i][18] = Utilities.getBooleanValue(true);
4364        metaData[i][19] = new Integer JavaDoc(ResultSetMetaData.columnNullableUnknown);
4365      }
4366      TempResultSetMetaData tempMetaData = new TempResultSetMetaData(metaData);
4367      resultSet = new TempResultSet(objs, columnNames);
4368      resultSet.setConnection(systemConnection);
4369      resultSet.setMetaData(tempMetaData);
4370      return resultSet;
4371    }
4372    catch (DException e) {
4373      throw e.getSqlException(systemConnection.getLocale());
4374    }
4375  }
4376
4377  private int getColumnTypeForVersionColumns(int index) throws SQLException {
4378    switch (index) {
4379      case 1:
4380        return Types.SMALLINT;
4381      case 2:
4382        return Types.VARCHAR;
4383      case 3:
4384        return Types.SMALLINT;
4385      case 4:
4386        return Types.VARCHAR;
4387      case 5:
4388        return Types.INTEGER;
4389      case 6:
4390        return Types.INTEGER;
4391      case 7:
4392        return Types.SMALLINT;
4393      case 8:
4394        return Types.SMALLINT;
4395      default:
4396        DException dex = new DException("DSE504", null);
4397        throw dex.getSqlException(systemConnection.getLocale());
4398    }
4399  }
4400
4401  private _RecordSetBuffer getRecordSetBuffer(String JavaDoc query) throws SQLException {
4402    try {
4403      Object JavaDoc obj = DaffodilDBStatement.getRequiredObjectOfexecute(systemConnection.
4404          getServerConnection().executeQuery(query, 0,IteratorConstants.UPDATABLE),
4405          ResultSet.CONCUR_READ_ONLY,0)[0];
4406      if (! (obj instanceof _RecordSetBuffer)) {
4407        DException dex = new DException("DSE531", null);
4408        throw dex.getSqlException(systemConnection.getLocale());
4409      }
4410      return (_RecordSetBuffer) obj;
4411    }
4412    catch (NullPointerException JavaDoc npe) {
4413      throw npe;
4414    }
4415    catch (DException e) {
4416      throw e.getSqlException(systemConnection.getLocale());
4417    }
4418  }
4419
4420  public boolean locatorsUpdateCopy() throws SQLException {
4421    /**@todo Implement this java.sql.DatabaseMetaData method*/
4422    throw new java.lang.UnsupportedOperationException JavaDoc(
4423        "Method locatorsUpdateCopy() not yet implemented.");
4424  }
4425
4426  public boolean supportsStatementPooling() throws SQLException {
4427    /**@todo Implement this java.sql.DatabaseMetaData method*/
4428    throw new java.lang.UnsupportedOperationException JavaDoc(
4429        "Method supportsStatementPooling() not yet implemented.");
4430  }
4431}
4432
Popular Tags