KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > genimen > djeneric > jdbc > DjDatabaseMetaData


1 /*
2  * Copyright (c) 2001-2005 by Genimen BV (www.genimen.com) All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, is permitted provided that the following conditions are met: -
6  * Redistributions of source code must retain the above copyright notice, this
7  * list of conditions and the following disclaimer. - Redistributions in binary
8  * form must reproduce the above copyright notice, this list of conditions and
9  * the following disclaimer in the documentation and/or other materials
10  * provided with the distribution. - All advertising materials mentioning
11  * features or use of this software must display the following acknowledgment:
12  * "This product includes Djeneric." - Products derived from this software may
13  * not be called "Djeneric" nor may "Djeneric" appear in their names without
14  * prior written permission of Genimen BV. - Redistributions of any form
15  * whatsoever must retain the following acknowledgment: "This product includes
16  * Djeneric."
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL GENIMEN BV, DJENERIC.ORG, OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  */

30 package com.genimen.djeneric.jdbc;
31
32 import java.math.BigDecimal JavaDoc;
33 import java.sql.Connection JavaDoc;
34 import java.sql.DatabaseMetaData JavaDoc;
35 import java.sql.ResultSet JavaDoc;
36 import java.sql.SQLException JavaDoc;
37
38 import com.genimen.djeneric.repository.DjDomain;
39 import com.genimen.djeneric.repository.DjExtent;
40 import com.genimen.djeneric.repository.DjProperty;
41 import com.genimen.djeneric.repository.DjPropertyType;
42 import com.genimen.djeneric.repository.exceptions.ObjectNotDefinedException;
43 import com.genimen.djeneric.repository.rdbms.RdbmsPersistenceManager;
44 import com.genimen.djeneric.util.DjLogger;
45
46 /**
47  * @author Gert Rijs
48  * @version 1.0
49  */

50
51 public class DjDatabaseMetaData implements DatabaseMetaData JavaDoc
52 {
53   private DjConnection _connection = null;
54   private static final DjResultSet EMPTY_RESULTSET = new DjResultSet();
55
56   private final static boolean REQUIRED = true;
57   private final static boolean OPTIONAL = false;
58   private final static DjPropertyType STRING = new DjDomain("String", DjDomain.STRING_TYPE, 10, 0, "", "",
59                                                           false);
60
61   // columns used in getTables
62
private static DjProperty GT_TCAT;
63   private static DjProperty GT_TSCHEM;
64   private static DjProperty GT_TNAME;
65   private static DjProperty GT_TTYPE;
66   private static DjProperty GT_TREMARKS;
67   static
68   {
69     try
70     {
71       /*
72        * public DjProperty( String name, String mapping, String alias, String
73        * prompt, DjPropertyType type, boolean required, int seq, String
74        * defaultValue, String description)
75        *
76        */

77       GT_TCAT = new DjProperty("TABLE_CAT", "", "", "", STRING, OPTIONAL, 1, null, "");
78       GT_TSCHEM = new DjProperty("TABLE_SCHEM", "", "", "", STRING, OPTIONAL, 2, null, "");
79       GT_TNAME = new DjProperty("TABLE_NAME", "", "", "", STRING, REQUIRED, 3, null, "");
80       GT_TTYPE = new DjProperty("TABLE_TYPE", "", "", "", STRING, REQUIRED, 4, null, "");
81       GT_TREMARKS = new DjProperty("REMARKS", "", "", "", STRING, OPTIONAL, 5, null, "");
82     }
83     catch (Exception JavaDoc ee)
84     {
85       DjLogger.log(ee);
86     }
87   }
88
89   // columns used in getTableTypes
90
private static DjProperty GTT_TTYPE;
91   static
92   {
93     try
94     {
95       GTT_TTYPE = new DjProperty("TABLE_TYPE", "", "", "", STRING, REQUIRED, 1, null, "");
96     }
97     catch (Exception JavaDoc ee)
98     {
99       DjLogger.log(ee);
100     }
101   }
102
103   // columns used in getColumns
104
private static DjProperty GC_TABLE_CAT;
105   private static DjProperty GC_TABLE_SCHEM;
106   private static DjProperty GC_TABLE_NAME;
107   private static DjProperty GC_COLUMN_NAME;
108   private static DjProperty GC_DATA_TYPE;
109   private static DjProperty GC_TYPE_NAME;
110   private static DjProperty GC_COLUMN_SIZE;
111   private static DjProperty GC_BUFFER_LENGTH;
112   private static DjProperty GC_DECIMAL_DIGITS;
113   private static DjProperty GC_NUM_PREC_RADIX;
114   private static DjProperty GC_NULLABLE;
115   private static DjProperty GC_REMARKS;
116   private static DjProperty GC_COLUMN_DEF;
117   private static DjProperty GC_SQL_DATA_TYPE;
118   private static DjProperty GC_SQL_DATATIME_SUB;
119   private static DjProperty GC_CHAR_OCTET_LENGTH;
120   private static DjProperty GC_ORDINAL_POSITION;
121   private static DjProperty GC_IS_NULLABLE = null;
122
123   static
124   {
125     try
126     {
127       GC_TABLE_CAT = new DjProperty("TABLE_CAT", "", "", "", STRING, OPTIONAL, 1, null, "");
128       GC_TABLE_SCHEM = new DjProperty("TABLE_SCHEM", "", "", "", STRING, OPTIONAL, 1, null, "");
129       GC_TABLE_NAME = new DjProperty("TABLE_NAME", "", "", "", STRING, OPTIONAL, 1, null, "");
130       GC_COLUMN_NAME = new DjProperty("COLUMN_NAME", "", "", "", STRING, OPTIONAL, 1, null, "");
131       GC_DATA_TYPE = new DjProperty("DATA_TYPE", "", "", "", STRING, OPTIONAL, 1, null, "");
132       GC_TYPE_NAME = new DjProperty("TYPE_NAME", "", "", "", STRING, OPTIONAL, 1, null, "");
133       GC_COLUMN_SIZE = new DjProperty("COLUMN_SIZE", "", "", "", STRING, OPTIONAL, 1, null, "");
134       GC_BUFFER_LENGTH = new DjProperty("BUFFER_LENGTH", "", "", "", STRING, OPTIONAL, 1, null, "");
135       GC_DECIMAL_DIGITS = new DjProperty("DECIMAL_DIGITS", "", "", "", STRING, OPTIONAL, 1, null, "");
136       GC_NUM_PREC_RADIX = new DjProperty("NUM_PREC_RADIX", "", "", "", STRING, OPTIONAL, 1, null, "");
137       GC_NULLABLE = new DjProperty("NULLABLE", "", "", "", STRING, OPTIONAL, 1, null, "");
138       GC_REMARKS = new DjProperty("REMARKS", "", "", "", STRING, OPTIONAL, 1, null, "");
139       GC_COLUMN_DEF = new DjProperty("COLUMN_DEF", "", "", "", STRING, OPTIONAL, 1, null, "");
140       GC_SQL_DATA_TYPE = new DjProperty("SQL_DATA_TYPE", "", "", "", STRING, OPTIONAL, 1, null, "");
141       GC_SQL_DATATIME_SUB = new DjProperty("SQL_DATATIME_SUB", "", "", "", STRING, OPTIONAL, 1, null, "");
142       GC_CHAR_OCTET_LENGTH = new DjProperty("CHAR_OCTET_LENGTH", "", "", "", STRING, OPTIONAL, 1, null, "");
143       GC_ORDINAL_POSITION = new DjProperty("ORDINAL_POSITION", "", "", "", STRING, OPTIONAL, 1, null, "");
144       GC_IS_NULLABLE = new DjProperty("IS_NULLABLE", "", "", "", STRING, OPTIONAL, 1, null, "");
145     }
146     catch (Exception JavaDoc ee)
147     {
148       DjLogger.log(ee);
149     }
150   }
151
152   /* package */
153   DjDatabaseMetaData(DjConnection p_con) throws SQLException JavaDoc
154   {
155     _connection = p_con;
156   }
157
158   public boolean allProceduresAreCallable() throws SQLException JavaDoc
159   {
160     return false;
161   }
162
163   public boolean allTablesAreSelectable() throws SQLException JavaDoc
164   {
165     return true;
166   }
167
168   public String JavaDoc getURL() throws SQLException JavaDoc
169   {
170     return null;
171   }
172
173   public String JavaDoc getUserName() throws SQLException JavaDoc
174   {
175     return "";
176   }
177
178   public boolean isReadOnly() throws SQLException JavaDoc
179   {
180     return true;
181   }
182
183   public boolean nullsAreSortedHigh() throws SQLException JavaDoc
184   {
185     return false;
186   }
187
188   public boolean nullsAreSortedLow() throws SQLException JavaDoc
189   {
190     return true;
191   }
192
193   public boolean nullsAreSortedAtStart() throws SQLException JavaDoc
194   {
195     return false;
196   }
197
198   public boolean nullsAreSortedAtEnd() throws SQLException JavaDoc
199   {
200     return false;
201   }
202
203   public String JavaDoc getDatabaseProductName() throws SQLException JavaDoc
204   {
205     return "djeneric";
206   }
207
208   public String JavaDoc getDatabaseProductVersion() throws SQLException JavaDoc
209   {
210     return "1/0";
211   }
212
213   public String JavaDoc getDriverName() throws SQLException JavaDoc
214   {
215     return DjDriver.CLASSNAME;
216   }
217
218   public String JavaDoc getDriverVersion() throws SQLException JavaDoc
219   {
220     return DjDriver.MAJOR_VERSION + "." + DjDriver.MINOR_VERSION;
221   }
222
223   public int getDriverMajorVersion()
224   {
225     return DjDriver.MAJOR_VERSION;
226   }
227
228   public int getDriverMinorVersion()
229   {
230     return DjDriver.MINOR_VERSION;
231   }
232
233   public boolean usesLocalFiles() throws SQLException JavaDoc
234   {
235     // actually partial: the schemafile!
236
return false;
237   }
238
239   public boolean usesLocalFilePerTable() throws SQLException JavaDoc
240   {
241     return false;
242   }
243
244   public boolean supportsMixedCaseIdentifiers() throws SQLException JavaDoc
245   {
246     return false;
247   }
248
249   public boolean storesUpperCaseIdentifiers() throws SQLException JavaDoc
250   {
251     return true;
252   }
253
254   public boolean storesLowerCaseIdentifiers() throws SQLException JavaDoc
255   {
256     return false;
257   }
258
259   public boolean storesMixedCaseIdentifiers() throws SQLException JavaDoc
260   {
261     return false;
262   }
263
264   public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException JavaDoc
265   {
266     return false;
267   }
268
269   public boolean storesUpperCaseQuotedIdentifiers() throws SQLException JavaDoc
270   {
271     return false;
272   }
273
274   public boolean storesLowerCaseQuotedIdentifiers() throws SQLException JavaDoc
275   {
276     return false;
277   }
278
279   public boolean storesMixedCaseQuotedIdentifiers() throws SQLException JavaDoc
280   {
281     return false;
282   }
283
284   public String JavaDoc getIdentifierQuoteString() throws SQLException JavaDoc
285   {
286     return "\"";
287   }
288
289   public String JavaDoc getSQLKeywords() throws SQLException JavaDoc
290   {
291     return "";
292   }
293
294   public String JavaDoc getNumericFunctions() throws SQLException JavaDoc
295   {
296     return "";
297   }
298
299   public String JavaDoc getStringFunctions() throws SQLException JavaDoc
300   {
301     return "";
302   }
303
304   public String JavaDoc getSystemFunctions() throws SQLException JavaDoc
305   {
306     return "";
307   }
308
309   public String JavaDoc getTimeDateFunctions() throws SQLException JavaDoc
310   {
311     return "";
312   }
313
314   public String JavaDoc getSearchStringEscape() throws SQLException JavaDoc
315   {
316     return "";
317   }
318
319   public String JavaDoc getExtraNameCharacters() throws SQLException JavaDoc
320   {
321     return "";
322   }
323
324   public boolean supportsAlterTableWithAddColumn() throws SQLException JavaDoc
325   {
326     return false;
327   }
328
329   public boolean supportsAlterTableWithDropColumn() throws SQLException JavaDoc
330   {
331     return false;
332   }
333
334   public boolean supportsColumnAliasing() throws SQLException JavaDoc
335   {
336     return true;
337   }
338
339   public boolean nullPlusNonNullIsNull() throws SQLException JavaDoc
340   {
341     return true;
342   }
343
344   public boolean supportsConvert() throws SQLException JavaDoc
345   {
346     return false;
347   }
348
349   public boolean supportsConvert(int fromType, int toType) throws SQLException JavaDoc
350   {
351     return false;
352   }
353
354   public boolean supportsTableCorrelationNames() throws SQLException JavaDoc
355   {
356     return true;
357   }
358
359   public boolean supportsDifferentTableCorrelationNames() throws SQLException JavaDoc
360   {
361     return true;
362   }
363
364   public boolean supportsExpressionsInOrderBy() throws SQLException JavaDoc
365   {
366     return false;
367   }
368
369   public boolean supportsOrderByUnrelated() throws SQLException JavaDoc
370   {
371     return false;
372   }
373
374   public boolean supportsGroupBy() throws SQLException JavaDoc
375   {
376     return true;
377   }
378
379   public boolean supportsGroupByUnrelated() throws SQLException JavaDoc
380   {
381     return false;
382   }
383
384   public boolean supportsGroupByBeyondSelect() throws SQLException JavaDoc
385   {
386     return false;
387   }
388
389   public boolean supportsLikeEscapeClause() throws SQLException JavaDoc
390   {
391     return true;
392   }
393
394   public boolean supportsMultipleResultSets() throws SQLException JavaDoc
395   {
396     return true;
397   }
398
399   public boolean supportsMultipleTransactions() throws SQLException JavaDoc
400   {
401     return false;
402   }
403
404   public boolean supportsNonNullableColumns() throws SQLException JavaDoc
405   {
406     return true;
407   }
408
409   public boolean supportsMinimumSQLGrammar() throws SQLException JavaDoc
410   {
411     return true;
412   }
413
414   public boolean supportsCoreSQLGrammar() throws SQLException JavaDoc
415   {
416     return true;
417   }
418
419   public boolean supportsExtendedSQLGrammar() throws SQLException JavaDoc
420   {
421     return false;
422   }
423
424   public boolean supportsANSI92EntryLevelSQL() throws SQLException JavaDoc
425   {
426     return false;
427   }
428
429   public boolean supportsANSI92IntermediateSQL() throws SQLException JavaDoc
430   {
431     return false;
432   }
433
434   public boolean supportsANSI92FullSQL() throws SQLException JavaDoc
435   {
436     return false;
437   }
438
439   public boolean supportsIntegrityEnhancementFacility() throws SQLException JavaDoc
440   {
441     return false;
442   }
443
444   public boolean supportsOuterJoins() throws SQLException JavaDoc
445   {
446     return false;
447   }
448
449   public boolean supportsFullOuterJoins() throws SQLException JavaDoc
450   {
451     return false;
452   }
453
454   public boolean supportsLimitedOuterJoins() throws SQLException JavaDoc
455   {
456     return false;
457   }
458
459   public String JavaDoc getSchemaTerm() throws SQLException JavaDoc
460   {
461     return "";
462   }
463
464   public String JavaDoc getProcedureTerm() throws SQLException JavaDoc
465   {
466     return "";
467   }
468
469   public String JavaDoc getCatalogTerm() throws SQLException JavaDoc
470   {
471     return "";
472   }
473
474   public boolean isCatalogAtStart() throws SQLException JavaDoc
475   {
476     return false;
477   }
478
479   public String JavaDoc getCatalogSeparator() throws SQLException JavaDoc
480   {
481     return "";
482   }
483
484   public boolean supportsSchemasInDataManipulation() throws SQLException JavaDoc
485   {
486     return false;
487   }
488
489   public boolean supportsSchemasInProcedureCalls() throws SQLException JavaDoc
490   {
491     return false;
492   }
493
494   public boolean supportsSchemasInTableDefinitions() throws SQLException JavaDoc
495   {
496     return false;
497   }
498
499   public boolean supportsSchemasInIndexDefinitions() throws SQLException JavaDoc
500   {
501     return false;
502   }
503
504   public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException JavaDoc
505   {
506     return false;
507   }
508
509   public boolean supportsCatalogsInDataManipulation() throws SQLException JavaDoc
510   {
511     return false;
512   }
513
514   public boolean supportsCatalogsInProcedureCalls() throws SQLException JavaDoc
515   {
516     return false;
517   }
518
519   public boolean supportsCatalogsInTableDefinitions() throws SQLException JavaDoc
520   {
521     return false;
522   }
523
524   public boolean supportsCatalogsInIndexDefinitions() throws SQLException JavaDoc
525   {
526     return false;
527   }
528
529   public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException JavaDoc
530   {
531     return false;
532   }
533
534   public boolean supportsPositionedDelete() throws SQLException JavaDoc
535   {
536     return false;
537   }
538
539   public boolean supportsPositionedUpdate() throws SQLException JavaDoc
540   {
541     return false;
542   }
543
544   public boolean supportsSelectForUpdate() throws SQLException JavaDoc
545   {
546     return false;
547   }
548
549   public boolean supportsStoredProcedures() throws SQLException JavaDoc
550   {
551     return false;
552   }
553
554   public boolean supportsSubqueriesInComparisons() throws SQLException JavaDoc
555   {
556     return false;
557   }
558
559   public boolean supportsSubqueriesInExists() throws SQLException JavaDoc
560   {
561     return true;
562   }
563
564   public boolean supportsSubqueriesInIns() throws SQLException JavaDoc
565   {
566     return false;
567   }
568
569   public boolean supportsSubqueriesInQuantifieds() throws SQLException JavaDoc
570   {
571     return false;
572   }
573
574   public boolean supportsCorrelatedSubqueries() throws SQLException JavaDoc
575   {
576     return true;
577   }
578
579   public boolean supportsUnion() throws SQLException JavaDoc
580   {
581     return true;
582   }
583
584   public boolean supportsUnionAll() throws SQLException JavaDoc
585   {
586     return true;
587   }
588
589   public boolean supportsOpenCursorsAcrossCommit() throws SQLException JavaDoc
590   {
591     return false;
592   }
593
594   public boolean supportsOpenCursorsAcrossRollback() throws SQLException JavaDoc
595   {
596     return false;
597   }
598
599   public boolean supportsOpenStatementsAcrossCommit() throws SQLException JavaDoc
600   {
601     return false;
602   }
603
604   public boolean supportsOpenStatementsAcrossRollback() throws SQLException JavaDoc
605   {
606     return false;
607   }
608
609   public int getMaxBinaryLiteralLength() throws SQLException JavaDoc
610   {
611     return 10;
612   }
613
614   public int getMaxCharLiteralLength() throws SQLException JavaDoc
615   {
616     return 2000;
617   }
618
619   public int getMaxColumnNameLength() throws SQLException JavaDoc
620   {
621     return 30;
622   }
623
624   public int getMaxColumnsInGroupBy() throws SQLException JavaDoc
625   {
626     return 30;
627   }
628
629   public int getMaxColumnsInIndex() throws SQLException JavaDoc
630   {
631     return 30;
632   }
633
634   public int getMaxColumnsInOrderBy() throws SQLException JavaDoc
635   {
636     return 30;
637   }
638
639   public int getMaxColumnsInSelect() throws SQLException JavaDoc
640   {
641     return 300;
642   }
643
644   public int getMaxColumnsInTable() throws SQLException JavaDoc
645   {
646     return 300;
647   }
648
649   public int getMaxConnections() throws SQLException JavaDoc
650   {
651     return 300;
652   }
653
654   public int getMaxCursorNameLength() throws SQLException JavaDoc
655   {
656     return 0;
657   }
658
659   public int getMaxIndexLength() throws SQLException JavaDoc
660   {
661     return 30;
662   }
663
664   public int getMaxSchemaNameLength() throws SQLException JavaDoc
665   {
666     return 0;
667   }
668
669   public int getMaxProcedureNameLength() throws SQLException JavaDoc
670   {
671     return 0;
672   }
673
674   public int getMaxCatalogNameLength() throws SQLException JavaDoc
675   {
676     return 0;
677   }
678
679   public int getMaxRowSize() throws SQLException JavaDoc
680   {
681     return 300000;
682   }
683
684   public boolean doesMaxRowSizeIncludeBlobs() throws SQLException JavaDoc
685   {
686     return false;
687   }
688
689   public int getMaxStatementLength() throws SQLException JavaDoc
690   {
691     return 30000;
692   }
693
694   public int getMaxStatements() throws SQLException JavaDoc
695   {
696     return 30;
697   }
698
699   public int getMaxTableNameLength() throws SQLException JavaDoc
700   {
701     return 30;
702   }
703
704   public int getMaxTablesInSelect() throws SQLException JavaDoc
705   {
706     return 30;
707   }
708
709   public int getMaxUserNameLength() throws SQLException JavaDoc
710   {
711     return 30;
712   }
713
714   public int getDefaultTransactionIsolation() throws SQLException JavaDoc
715   {
716     return 0;
717   }
718
719   public boolean supportsTransactions() throws SQLException JavaDoc
720   {
721     return true;
722   }
723
724   public boolean supportsTransactionIsolationLevel(int level) throws SQLException JavaDoc
725   {
726     return false;
727   }
728
729   public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException JavaDoc
730   {
731     return false;
732   }
733
734   public boolean supportsDataManipulationTransactionsOnly() throws SQLException JavaDoc
735   {
736     return false;
737   }
738
739   public boolean dataDefinitionCausesTransactionCommit() throws SQLException JavaDoc
740   {
741     return true;
742   }
743
744   public boolean dataDefinitionIgnoredInTransactions() throws SQLException JavaDoc
745   {
746     return false;
747   }
748
749   public ResultSet JavaDoc getProcedures(String JavaDoc catalog, String JavaDoc schemaPattern, String JavaDoc procedureNamePattern) throws SQLException JavaDoc
750   {
751     return EMPTY_RESULTSET;
752   }
753
754   public ResultSet JavaDoc getProcedureColumns(String JavaDoc catalog, String JavaDoc schemaPattern, String JavaDoc procedureNamePattern,
755                                        String JavaDoc columnNamePattern) throws SQLException JavaDoc
756   {
757     return EMPTY_RESULTSET;
758   }
759
760   public ResultSet JavaDoc getTables(String JavaDoc catalog, String JavaDoc schemaPattern, String JavaDoc tableNamePattern, String JavaDoc[] types)
761       throws SQLException JavaDoc
762   {
763     DjResultSet result = new DjResultSet();
764     RdbmsPersistenceManager pman = _connection.getPersistenceManager();
765     DjExtent[] extents = pman.getExtents();
766     result.defineColumn(GT_TCAT);
767     result.defineColumn(GT_TSCHEM);
768     result.defineColumn(GT_TNAME);
769     result.defineColumn(GT_TTYPE);
770     result.defineColumn(GT_TREMARKS);
771     for (int i = 0; i < extents.length; i++)
772     {
773       Object JavaDoc row = result.newRow();
774       result.addColumn(row, GT_TCAT, null);
775       result.addColumn(row, GT_TSCHEM, null);
776       result.addColumn(row, GT_TNAME, extents[i].getName());
777       result.addColumn(row, GT_TTYPE, "TABLE");
778       if (extents[i].getDescription() != null) result.addColumn(row, GT_TREMARKS, extents[i].getDescription());
779       else result.addColumn(row, GT_TREMARKS, extents[i].getTitle());
780     }
781     return result;
782   }
783
784   public ResultSet JavaDoc getSchemas() throws SQLException JavaDoc
785   {
786     return EMPTY_RESULTSET;
787   }
788
789   public ResultSet JavaDoc getCatalogs() throws SQLException JavaDoc
790   {
791     return EMPTY_RESULTSET;
792   }
793
794   public ResultSet JavaDoc getTableTypes() throws SQLException JavaDoc
795   {
796     DjResultSet result = new DjResultSet();
797     result.defineColumn(GTT_TTYPE);
798     result.addColumn(result.newRow(), GTT_TTYPE, "TABLE");
799     return result;
800   }
801
802   public ResultSet JavaDoc getColumns(String JavaDoc catalog, String JavaDoc schemaPattern, String JavaDoc tableNamePattern, String JavaDoc columnNamePattern)
803       throws SQLException JavaDoc
804   {
805     DjResultSet result = new DjResultSet();
806     RdbmsPersistenceManager pman = _connection.getPersistenceManager();
807     result.defineColumn(GC_TABLE_CAT);
808     result.defineColumn(GC_TABLE_SCHEM);
809     result.defineColumn(GC_TABLE_NAME);
810     result.defineColumn(GC_COLUMN_NAME);
811     result.defineColumn(GC_DATA_TYPE);
812     result.defineColumn(GC_TYPE_NAME);
813     result.defineColumn(GC_COLUMN_SIZE);
814     result.defineColumn(GC_BUFFER_LENGTH);
815     result.defineColumn(GC_DECIMAL_DIGITS);
816     result.defineColumn(GC_NUM_PREC_RADIX);
817     result.defineColumn(GC_NULLABLE);
818     result.defineColumn(GC_REMARKS);
819     result.defineColumn(GC_COLUMN_DEF);
820     result.defineColumn(GC_SQL_DATA_TYPE);
821     result.defineColumn(GC_SQL_DATATIME_SUB);
822     result.defineColumn(GC_CHAR_OCTET_LENGTH);
823     result.defineColumn(GC_ORDINAL_POSITION);
824     result.defineColumn(GC_IS_NULLABLE);
825     try
826     {
827       DjExtent tab = pman.getExtent(tableNamePattern);
828       DjProperty[] cols = tab.getProperties();
829       for (int i = 0; i < cols.length; i++)
830       {
831         Object JavaDoc row = result.newRow();
832         result.addColumn(row, GC_TABLE_CAT, null);
833         result.addColumn(row, GC_TABLE_SCHEM, null);
834         result.addColumn(row, GC_TABLE_NAME, tab.getName());
835         result.addColumn(row, GC_COLUMN_NAME, cols[i].getName());
836         result.addColumn(row, GC_DATA_TYPE, new BigDecimal JavaDoc(cols[i].getTypeCode()));
837         result.addColumn(row, GC_TYPE_NAME, cols[i].getTypeName());
838         result.addColumn(row, GC_COLUMN_SIZE, new BigDecimal JavaDoc(cols[i].getLength()));
839         result.addColumn(row, GC_BUFFER_LENGTH, null);
840         result.addColumn(row, GC_DECIMAL_DIGITS, new BigDecimal JavaDoc(cols[i].getDecimals()));
841         result.addColumn(row, GC_NUM_PREC_RADIX, new BigDecimal JavaDoc(10));
842         result.addColumn(row, GC_NULLABLE, new BigDecimal JavaDoc(cols[i].isRequired() ? columnNoNulls : columnNullable));
843         result.addColumn(row, GC_REMARKS, cols[i].getDescription());
844         result.addColumn(row, GC_COLUMN_DEF, null);
845         result.addColumn(row, GC_SQL_DATA_TYPE, null);
846         result.addColumn(row, GC_SQL_DATATIME_SUB, null);
847         result.addColumn(row, GC_CHAR_OCTET_LENGTH, new BigDecimal JavaDoc(cols[i].getLength()));
848         result.addColumn(row, GC_ORDINAL_POSITION, new BigDecimal JavaDoc(i + 1));
849         result.addColumn(row, GC_IS_NULLABLE, cols[i].isRequired() ? "NO" : "YES");
850       }
851     }
852     catch (ObjectNotDefinedException ond)
853     {
854       throw new SQLException JavaDoc("Table " + tableNamePattern + " is not defined: " + ond);
855     }
856     return result;
857   }
858
859   public ResultSet JavaDoc getColumnPrivileges(String JavaDoc catalog, String JavaDoc schema, String JavaDoc table, String JavaDoc columnNamePattern)
860       throws SQLException JavaDoc
861   {
862     return /** @todo: check this */
863     EMPTY_RESULTSET;
864   }
865
866   public ResultSet JavaDoc getTablePrivileges(String JavaDoc catalog, String JavaDoc schemaPattern, String JavaDoc tableNamePattern)
867       throws SQLException JavaDoc
868   {
869     return /** @todo: check this */
870     EMPTY_RESULTSET;
871   }
872
873   public ResultSet JavaDoc getBestRowIdentifier(String JavaDoc catalog, String JavaDoc schema, String JavaDoc table, int scope, boolean nullable)
874       throws SQLException JavaDoc
875   {
876     return /** @todo: check this */
877     EMPTY_RESULTSET;
878   }
879
880   public ResultSet JavaDoc getVersionColumns(String JavaDoc catalog, String JavaDoc schema, String JavaDoc table) throws SQLException JavaDoc
881   {
882     return /** @todo: check this */
883     EMPTY_RESULTSET;
884   }
885
886   public ResultSet JavaDoc getPrimaryKeys(String JavaDoc catalog, String JavaDoc schema, String JavaDoc table) throws SQLException JavaDoc
887   {
888     return /** @todo: check this */
889     EMPTY_RESULTSET;
890   }
891
892   public ResultSet JavaDoc getImportedKeys(String JavaDoc catalog, String JavaDoc schema, String JavaDoc table) throws SQLException JavaDoc
893   {
894     return /** @todo: check this */
895     EMPTY_RESULTSET;
896   }
897
898   public ResultSet JavaDoc getExportedKeys(String JavaDoc catalog, String JavaDoc schema, String JavaDoc table) throws SQLException JavaDoc
899   {
900     return /** @todo: check this */
901     EMPTY_RESULTSET;
902   }
903
904   public ResultSet JavaDoc getCrossReference(String JavaDoc primaryCatalog, String JavaDoc primarySchema, String JavaDoc primaryTable,
905                                      String JavaDoc foreignCatalog, String JavaDoc foreignSchema, String JavaDoc foreignTable)
906       throws SQLException JavaDoc
907   {
908     return /** @todo: check this */
909     EMPTY_RESULTSET;
910   }
911
912   public ResultSet JavaDoc getTypeInfo() throws SQLException JavaDoc
913   {
914     return /** @todo: check this */
915     EMPTY_RESULTSET;
916   }
917
918   public ResultSet JavaDoc getIndexInfo(String JavaDoc catalog, String JavaDoc schema, String JavaDoc table, boolean unique, boolean approximate)
919       throws SQLException JavaDoc
920   {
921     return /** @todo: check this */
922     EMPTY_RESULTSET;
923   }
924
925   public boolean supportsResultSetType(int type) throws SQLException JavaDoc
926   {
927     return true;
928   }
929
930   public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException JavaDoc
931   {
932     return false;
933   }
934
935   public boolean ownUpdatesAreVisible(int type) throws SQLException JavaDoc
936   {
937     return true;
938   }
939
940   public boolean ownDeletesAreVisible(int type) throws SQLException JavaDoc
941   {
942     return true;
943   }
944
945   public boolean ownInsertsAreVisible(int type) throws SQLException JavaDoc
946   {
947     return true;
948   }
949
950   public boolean othersUpdatesAreVisible(int type) throws SQLException JavaDoc
951   {
952     return true;
953   }
954
955   public boolean othersDeletesAreVisible(int type) throws SQLException JavaDoc
956   {
957     return true;
958   }
959
960   public boolean othersInsertsAreVisible(int type) throws SQLException JavaDoc
961   {
962     return true;
963   }
964
965   public boolean updatesAreDetected(int type) throws SQLException JavaDoc
966   {
967     return true;
968   }
969
970   public boolean deletesAreDetected(int type) throws SQLException JavaDoc
971   {
972     return true;
973   }
974
975   public boolean insertsAreDetected(int type) throws SQLException JavaDoc
976   {
977     return true;
978   }
979
980   public boolean supportsBatchUpdates() throws SQLException JavaDoc
981   {
982     return false;
983   }
984
985   public ResultSet JavaDoc getUDTs(String JavaDoc catalog, String JavaDoc schemaPattern, String JavaDoc typeNamePattern, int[] types)
986       throws SQLException JavaDoc
987   {
988     return EMPTY_RESULTSET;
989   }
990
991   public Connection JavaDoc getConnection() throws SQLException JavaDoc
992   {
993     return _connection;
994   }
995
996   /*
997    * (non-Javadoc)
998    *
999    * @see java.sql.DatabaseMetaData#getAttributes(java.lang.String,
1000   * java.lang.String, java.lang.String, java.lang.String)
1001   */

1002  public ResultSet JavaDoc getAttributes(String JavaDoc arg0, String JavaDoc arg1, String JavaDoc arg2, String JavaDoc arg3) throws SQLException JavaDoc
1003  {
1004    // Only UDTs, they are not supported.
1005
return EMPTY_RESULTSET;
1006  }
1007
1008  /*
1009   * (non-Javadoc)
1010   *
1011   * @see java.sql.DatabaseMetaData#getDatabaseMajorVersion()
1012   */

1013  public int getDatabaseMajorVersion() throws SQLException JavaDoc
1014  {
1015    return _connection.getDriver().getMajorVersion();
1016  }
1017
1018  /*
1019   * (non-Javadoc)
1020   *
1021   * @see java.sql.DatabaseMetaData#getDatabaseMinorVersion()
1022   */

1023  public int getDatabaseMinorVersion() throws SQLException JavaDoc
1024  {
1025    return _connection.getDriver().getMinorVersion();
1026  }
1027
1028  /*
1029   * (non-Javadoc)
1030   *
1031   * @see java.sql.DatabaseMetaData#getJDBCMajorVersion()
1032   */

1033  public int getJDBCMajorVersion() throws SQLException JavaDoc
1034  {
1035    return _connection.getDriver().getMajorVersion();
1036  }
1037
1038  /*
1039   * (non-Javadoc)
1040   *
1041   * @see java.sql.DatabaseMetaData#getJDBCMinorVersion()
1042   */

1043  public int getJDBCMinorVersion() throws SQLException JavaDoc
1044  {
1045    return _connection.getDriver().getMinorVersion();
1046  }
1047
1048  /*
1049   * (non-Javadoc)
1050   *
1051   * @see java.sql.DatabaseMetaData#getResultSetHoldability()
1052   */

1053  public int getResultSetHoldability() throws SQLException JavaDoc
1054  {
1055    return ResultSet.CLOSE_CURSORS_AT_COMMIT;
1056  }
1057
1058  /*
1059   * (non-Javadoc)
1060   *
1061   * @see java.sql.DatabaseMetaData#getSQLStateType()
1062   */

1063  public int getSQLStateType() throws SQLException JavaDoc
1064  {
1065    return sqlStateXOpen;
1066  }
1067
1068  /*
1069   * (non-Javadoc)
1070   *
1071   * @see java.sql.DatabaseMetaData#getSuperTables(java.lang.String,
1072   * java.lang.String, java.lang.String)
1073   */

1074  public ResultSet JavaDoc getSuperTables(String JavaDoc arg0, String JavaDoc arg1, String JavaDoc arg2) throws SQLException JavaDoc
1075  {
1076    return EMPTY_RESULTSET;
1077  }
1078
1079  /*
1080   * (non-Javadoc)
1081   *
1082   * @see java.sql.DatabaseMetaData#getSuperTypes(java.lang.String,
1083   * java.lang.String, java.lang.String)
1084   */

1085  public ResultSet JavaDoc getSuperTypes(String JavaDoc arg0, String JavaDoc arg1, String JavaDoc arg2) throws SQLException JavaDoc
1086  {
1087    return EMPTY_RESULTSET;
1088  }
1089
1090  /*
1091   * (non-Javadoc)
1092   *
1093   * @see java.sql.DatabaseMetaData#locatorsUpdateCopy()
1094   */

1095  public boolean locatorsUpdateCopy() throws SQLException JavaDoc
1096  {
1097    return false;
1098  }
1099
1100  /*
1101   * (non-Javadoc)
1102   *
1103   * @see java.sql.DatabaseMetaData#supportsGetGeneratedKeys()
1104   */

1105  public boolean supportsGetGeneratedKeys() throws SQLException JavaDoc
1106  {
1107    return false;
1108  }
1109
1110  /*
1111   * (non-Javadoc)
1112   *
1113   * @see java.sql.DatabaseMetaData#supportsMultipleOpenResults()
1114   */

1115  public boolean supportsMultipleOpenResults() throws SQLException JavaDoc
1116  {
1117    return true;
1118  }
1119
1120  /*
1121   * (non-Javadoc)
1122   *
1123   * @see java.sql.DatabaseMetaData#supportsNamedParameters()
1124   */

1125  public boolean supportsNamedParameters() throws SQLException JavaDoc
1126  {
1127    return false;
1128  }
1129
1130  /*
1131   * (non-Javadoc)
1132   *
1133   * @see java.sql.DatabaseMetaData#supportsResultSetHoldability(int)
1134   */

1135  public boolean supportsResultSetHoldability(int arg0) throws SQLException JavaDoc
1136  {
1137    return false;
1138  }
1139
1140  /*
1141   * (non-Javadoc)
1142   *
1143   * @see java.sql.DatabaseMetaData#supportsSavepoints()
1144   */

1145  public boolean supportsSavepoints() throws SQLException JavaDoc
1146  {
1147    return false;
1148  }
1149
1150  /*
1151   * (non-Javadoc)
1152   *
1153   * @see java.sql.DatabaseMetaData#supportsStatementPooling()
1154   */

1155  public boolean supportsStatementPooling() throws SQLException JavaDoc
1156  {
1157    return false;
1158  }
1159
1160}
Popular Tags