-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDatabaseMetaData.java
More file actions
3237 lines (3002 loc) · 131 KB
/
Copy pathDatabaseMetaData.java
File metadata and controls
3237 lines (3002 loc) · 131 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package java.sql;
/**
* An interface which provides comprehensive information about the database
* management system and its supported features.
* <p>
* This interface is implemented by JDBC driver vendors in order to provide
* information about the underlying database capabilities in association with
* the JDBC driver.
* <p>
* Some of the methods in this interface take string parameters which are
* patterns. Within these string patterns, {@code '%'} and {@code '_'}
* characters have special meanings. {@code '%'} means
* "match any substring of 0 or more characters". {@code '_'} means
* "match any character". Only metadata entries that match the pattern are
* returned. If such a search pattern string is set to {@code null}, that
* argument's criteria are dropped from the search.
*/
public interface DatabaseMetaData extends Wrapper {
/**
* States that it may not be permitted to store {@code NULL} values.
*/
public static final short attributeNoNulls = 0;
/**
* States that {@code NULL} values are definitely permitted.
*/
public static final short attributeNullable = 1;
/**
* States that whether {@code NULL} values are permitted is unknown.
*/
public static final short attributeNullableUnknown = 2;
/**
* States the best row identifier is <em>NOT</em> a pseudo column.
*/
public static final int bestRowNotPseudo = 1;
/**
* States that the best row identifier is a pseudo column.
*/
public static final int bestRowPseudo = 2;
/**
* States that the remainder of the current session is used as the scope for
* the best row identifier.
*/
public static final int bestRowSession = 2;
/**
* States that best row identifier scope lasts only while the row is being
* used.
*/
public static final int bestRowTemporary = 0;
/**
* States that the remainder of the current transaction is used as the scope
* for the best row identifier.
*/
public static final int bestRowTransaction = 1;
/**
* States that the best row identifier may or may not be a pseudo column.
*/
public static final int bestRowUnknown = 0;
/**
* States that the column must not allow {@code NULL} values.
*/
public static final int columnNoNulls = 0;
/**
* States that the column definitely allows {@code NULL} values.
*/
public static final int columnNullable = 1;
/**
* States that it is unknown whether the columns may be nulled.
*/
public static final int columnNullableUnknown = 2;
/**
* For the column {@code UPDATE_RULE}, states that when the primary key is
* updated, the foreign key (imported key) is changed accordingly.
*/
public static final int importedKeyCascade = 0;
/**
* States that the evaluation of foreign key constraints is deferred (delayed
* until commit).
*/
public static final int importedKeyInitiallyDeferred = 5;
/**
* States that the evaluation of foreign key constraint is {@code IMMEDIATE}
* .
*/
public static final int importedKeyInitiallyImmediate = 6;
/**
* For the columns {@code UPDATE_RULE} and {@code DELETE_RULE}, states that
* if the primary key has been imported, it cannot be updated or deleted.
*/
public static final int importedKeyNoAction = 3;
/**
* States that the evaluation of foreign key constraint must not be {@code
* DEFERRED}.
*/
public static final int importedKeyNotDeferrable = 7;
/**
* States that a primary key must not be updated when imported as a foreign
* key by some other table. Used for the column {@code UPDATE_RULE}.
*/
public static final int importedKeyRestrict = 1;
/**
* States that when the primary key is modified (updated or deleted) the
* foreign (imported) key is changed to its default value. Applies to the
* {@code UPDATE_RULE} and {@code DELETE_RULE} columns.
*/
public static final int importedKeySetDefault = 4;
/**
* States that when the primary key is modified (updated or deleted) the
* foreign (imported) key is changed to {@code NULL}. Applies to the {@code
* UPDATE_RULE} and {@code DELETE_RULE} columns.
*/
public static final int importedKeySetNull = 2;
/**
* States that the column stores {@code IN} type parameters.
*/
public static final int procedureColumnIn = 1;
/**
* States that this column stores {@code INOUT} type parameters.
*/
public static final int procedureColumnInOut = 2;
/**
* States that this column stores {@code OUT} type parameters.
*/
public static final int procedureColumnOut = 4;
/**
* States that the column stores results.
*/
public static final int procedureColumnResult = 3;
/**
* States that the column stores return values.
*/
public static final int procedureColumnReturn = 5;
/**
* States that type of the column is unknown.
*/
public static final int procedureColumnUnknown = 0;
/**
* States that {@code NULL} values are not permitted.
*/
public static final int procedureNoNulls = 0;
/**
* States that the procedure does not return a result.
*/
public static final int procedureNoResult = 1;
/**
* States that {@code NULL} values are permitted.
*/
public static final int procedureNullable = 1;
/**
* States that it is unknown whether {@code NULL} values are permitted.
*/
public static final int procedureNullableUnknown = 2;
/**
* States that it is unknown whether or not the procedure returns a result.
*/
public static final int procedureResultUnknown = 0;
/**
* States that the procedure returns a result.
*/
public static final int procedureReturnsResult = 2;
/**
* States that the value is an SQL99 {@code SQLSTATE} value.
*/
public static final int sqlStateSQL99 = 2;
/**
* States that the value is an SQL {@code CLI SQLSTATE} value as defined by
* the X/Open standard.
*/
public static final int sqlStateXOpen = 1;
/**
* States that this table index is a clustered index.
*/
public static final short tableIndexClustered = 1;
/**
* States that this table index is a hashed index.
*/
public static final short tableIndexHashed = 2;
/**
* States this table's index is neither a clustered index, not a hashed
* index, and not a table statistics index; i.e. it is something else.
*/
public static final short tableIndexOther = 3;
/**
* States this column has the table's statistics, and that it is returned in
* conjunction with the table's index description.
*/
public static final short tableIndexStatistic = 0;
/**
* States that a {@code NULL} value is <em>NOT</em> permitted for
* this data type.
*/
public static final int typeNoNulls = 0;
/**
* States that a {@code NULL} value is permitted for this data type.
*/
public static final int typeNullable = 1;
/**
* States that it is unknown if a {@code NULL} value is permitted for
* this data type.
*/
public static final int typeNullableUnknown = 2;
/**
* States that this column shall not be used for {@code WHERE} statements
* with a {@code LIKE} clause.
*/
public static final int typePredBasic = 2;
/**
* States that this column can only be used in a {@code WHERE...LIKE}
* statement.
*/
public static final int typePredChar = 1;
/**
* States that this column does not support searches.
*/
public static final int typePredNone = 0;
/**
* States that the column is searchable.
*/
public static final int typeSearchable = 3;
/**
* States that the version column is known to be not a pseudo column.
*/
public static final int versionColumnNotPseudo = 1;
/**
* States that this version column is known to be a pseudo column.
*/
public static final int versionColumnPseudo = 2;
/**
* States that the version column may be a pseudo column or not.
*/
public static final int versionColumnUnknown = 0;
/**
* States that the method DatabaseMetaData.getSQLStateType may returns an
* SQLSTATE value or not.
*/
public static final int sqlStateSQL = 2;
/**
* States that the parameter or column is an IN parameter
*/
public static final int functionColumnIn = 1;
/**
* States that the parameter or column is an INOUT parameter
*/
public static final int functionColumnInOut = 2;
/**
* States that the parameter or column is an OUT parameter
*/
public static final int functionColumnOut = 3;
/**
* States that the parameter or column is a return value
*/
public static final int functionReturn = 4;
/**
* States that the parameter of function is unknown
*/
public static final int functionColumnUnknown = 0;
/**
* States that the parameter or column is a column in a result set
*/
public static final int functionColumnResult = 5;
/**
* States that NULL values are not allowed
*/
public static final int functionNoNulls = 0;
/**
* States that NULL values are allowed
*/
public static final int functionNullable = 1;
/**
* States that whether NULL values are allowed is unknown
*/
public static final int functionNullableUnknown = 2;
/**
* States that it is not known whether the function returns a result or a
* table
*/
public static final int functionResultUnknown = 0;
/**
* States that the function does not return a table
*/
public static final int functionNoTable = 1;
/**
* States that the function returns a table.
*/
public static final int functionReturnsTable = 2;
/**
* Returns whether all procedures returned by {@link #getProcedures} can be
* called by the current user.
*
* @return {@code true} if all procedures can be called by the current user,
* {@code false} otherwise.
* @throws SQLException
* if there is a database error.
*/
public boolean allProceduresAreCallable() throws SQLException;
/**
* Returns whether all the tables returned by {@code getTables} can be used
* by the current user in a {@code SELECT} statement.
*
* @return {@code true} if all the tables can be used,{@code false}
* otherwise.
* @throws SQLException
* if there is a database error.
*/
public boolean allTablesAreSelectable() throws SQLException;
/**
* Returns whether a data definition statement in a transaction forces a {@code
* commit} of the transaction.
*
* @return {@code true} if the statement forces a commit, {@code false}
* otherwise.
* @throws SQLException
* if there is a database error.
*/
public boolean dataDefinitionCausesTransactionCommit() throws SQLException;
/**
* Returns whether the database ignores data definition statements within a
* transaction.
*
* @return {@code true} if the database ignores a data definition statement,
* {@code false} otherwise.
* @throws SQLException
* if there is a database error.
*/
public boolean dataDefinitionIgnoredInTransactions() throws SQLException;
/**
* Returns whether a visible row delete can be detected by calling
* {@link ResultSet#rowDeleted}.
*
* @param type
* the type of the {@code ResultSet} involved: {@code
* ResultSet.TYPE_FORWARD_ONLY}, {@code
* ResultSet.TYPE_SCROLL_INSENSITIVE}, or {@code
* ResultSet.TYPE_SCROLL_SENSITIVE}
* @return {@code true} if the visible row delete can be detected, {@code
* false} otherwise.
* @throws SQLException
* if there is a database error.
*/
public boolean deletesAreDetected(int type) throws SQLException;
/**
* Returns whether the return value of {@code getMaxRowSize} includes the
* SQL data types {@code LONGVARCHAR} and {@code LONGVARBINARY}.
*
* @return {@code true} if the return value includes {@code LONGVARBINARY}
* and {@code LONGVARCHAR}, otherwise {@code false}.
* @throws SQLException
* if there is a database error.
*/
public boolean doesMaxRowSizeIncludeBlobs() throws SQLException;
/**
* Returns a {@code ResultSet} describing a subset of the attributes of a
* specified SQL User Defined Type (UDT) for a specified schema and catalog.
* The subset is determined by restricting to those attributes whose
* name matches the {@code attributeNamePattern} and whose type name
* matches the {@code typeNamePattern}. Each row of the {@code ResultSet}
* describes one attribute, and the rows are ordered by the columns {@code TYPE_SCHEM},
* {@code TYPE_NAME} and {@code ORDINAL_POSITION}. Inherited attributes
* are not included.
* <p>
* The columns of the returned {@code ResultSet} object have the following
* names and meanings:
* <ol>
* <li>{@code TYPE_CAT} - String - the type catalog name (possibly {@code
* null})</li>
* <li>{@code TYPE_SCHEM} - String - the type schema name (possibly {@code
* null})</li>
* <li>{@code TYPE_NAME} - String - the type name</li>
* <li>{@code ATTR_NAME} - String - the attribute name</li>
* <li>{@code DATA_TYPE} - int - the attribute type as defined in {@code
* java.sql.Types}</li>
* <li>{@code ATTR_TYPE_NAME} - String - the attribute type name. This
* depends on the data source. For a {@code UDT} the name is fully
* qualified. For a {@code REF} it is both fully qualified and represents
* the target type of the reference.</li>
* <li>{@code ATTR_SIZE} - int - the column size. When referring to char and
* date types this value is the maximum number of characters. When referring
* to numeric types is is the precision.</li>
* <li>{@code DECIMAL_DIGITS} - int - how many fractional digits are
* supported</li>
* <li>{@code NUM_PREC_RADIX} - int - numeric values radix</li>
* <li>{@code NULLABLE} - int - whether {@code NULL} is permitted:
* <ul>
* <li>DatabaseMetaData.attributeNoNulls - {@code NULL} values not permitted</li>
* <li>DatabaseMetaData.attributeNullable - {@code NULL} values definitely
* permitted</li>
* <li>DatabaseMetaData.attributeNullableUnknown - unknown</li>
* </ul>
* </li>
* <li>{@code REMARKS} - String - a comment describing the attribute
* (possibly {@code null})</li>
* <li>ATTR_DEF - String - Default value for the attribute (possibly {@code
* null})</li>
* <li>{@code SQL_DATA_TYPE} - int - not used</li>
* <li>SQL_DATETIME_SUB - int - not used</li>
* <li>CHAR_OCTET_LENGTH - int - for {@code CHAR} types, the max number of
* bytes in the column</li>
* <li>ORDINAL_POSITION - int - The index of the column in the table (where
* the count starts from 1, not 0)</li>
* <li>IS_NULLABLE - String - {@code "NO"} = the column does not allow {@code
* NULL}s, {@code "YES"} = the column allows {@code NULL}s, "" = status unknown</li>
* <li>{@code SCOPE_CATALOG} - String - if the {@code DATA_TYPE} is {@code REF},
* this gives the catalog of the table corresponding to the attribute's scope.
* NULL if the {@code DATA_TYPE} is not REF.</li>
* <li>{@code SCOPE_SCHEMA} - String - if the {@code DATA_TYPE} is {@code REF},
* this gives the schema of the table corresponding to the attribute's scope.
* NULL if the {@code DATA_TYPE} is not REF.</li>
* <li>{@code SCOPE_TABLE} - String - if the {@code DATA_TYPE} is {@code REF},
* this gives the name of the table corresponding to the attribute's scope.
* NULL if the {@code DATA_TYPE} is not REF.</li>
* <li>{@code SOURCE_DATA_TYPE} - String - The source type for a user
* generated REF type or for a Distinct type. ({@code NULL} if {@code
* DATA_TYPE} is not DISTINCT or a user generated REF)</li>
* </ol>
*
* @param catalog
* a catalog name. {@code null} is used to imply no narrowing of
* the search by catalog name. Otherwise, the name must match a
* catalog name held in the database, with "" used to retrieve
* those without a catalog name.
* @param schemaPattern
* a schema name pattern. {@code null} is used to imply no
* narrowing of the search by a schema name. Otherwise, the name
* must match a schema name in the database, with "" used to
* retrieve those without a schema name.
* @param typeNamePattern
* a type name. This pattern must match the type name stored in
* the database.
* @param attributeNamePattern
* an Attribute name. This pattern must match the attribute name as stored in
* the database.
* @return a {@code ResultSet}, where each row is an attribute description.
* @throws SQLException
* if there is a database error.
*/
public ResultSet getAttributes(String catalog, String schemaPattern,
String typeNamePattern, String attributeNamePattern)
throws SQLException;
/**
* Returns a list of a table's optimal set of columns that uniquely
* identify the rows. The results are ordered by {@code SCOPE} (see below).
* <p>
* The results are returned as a table, with one entry for each column, as
* follows:
* <ol>
* <li>{@code SCOPE} - short - the {@code SCOPE} of the result, as follows:
* <ul>
* <li>{@code DatabaseMetaData.bestRowTemporary} - the result is very temporary,
* only valid while on the current row</li>
* <li>{@code DatabaseMetaData.bestRowTransaction} - the result is good for remainder of
* current transaction</li>
* <li>{@code DatabaseMetaData.bestRowSession} - the result is good for remainder of
* database session</li>
* </ul>
* </li>
* <li>{@code COLUMN_NAME} - String - the column name</li>
* <li>{@code DATA_TYPE} - int - the Type of the data, as defined in {@code
* java.sql.Types}</li>
* <li>{@code TYPE_NAME} - String - the Name of the type - database dependent.
* For UDT types the name is fully qualified</li>
* <li>{@code COLUMN_SIZE} - int - the precision of the data in the column</li>
* <li>{@code BUFFER_LENGTH} - int - not used</li>
* <li>{@code DECIMAL_DIGITS} - short - number of fractional digits</li>
* <li>{@code PSEUDO_COLUMN} - short - whether this is a pseudo column (e.g.
* an Oracle {@code ROWID}):
* <ul>
* <li>{@code DatabaseMetaData.bestRowUnknown} - it is not known whether this is
* a pseudo column</li>
* <li>{@code DatabaseMetaData.bestRowNotPseudo} - the column is not pseudo</li>
* <li>{@code DatabaseMetaData.bestRowPseudo} - the column is a pseudo column</li>
* </ul>
* </li>
* </ol>
*
* @param catalog
* a catalog name. {@code null} is used to imply no narrowing of
* the search by catalog name. Otherwise, the name must match a
* catalog name held in the database, with "" used to retrieve
* those without a catalog name.
* @param schema
* a schema name pattern. {@code null} is used to imply no
* narrowing of the search by schema name. Otherwise, the name
* must match a schema name in the database, with "" used to
* retrieve those without a schema name.
* @param table
* the table name. This must match the name of the table as
* declared in the database.
* @param scope
* the {@code SCOPE} of interest, values as defined above.
* @param nullable
* {@code true} = include columns that are nullable, {@code
* false} = do not include nullable columns.
* @return a {@code ResultSet} where each row is a description of a column
* and the complete set of rows is the optimal set for this table.
* @throws SQLException
* if there is a database error.
*/
public ResultSet getBestRowIdentifier(String catalog, String schema,
String table, int scope, boolean nullable) throws SQLException;
/**
* Returns the set of catalog names available in this database. The set is
* returned ordered by catalog name.
*
* @return a {@code ResultSet} containing the catalog names, with each row
* containing one catalog name (as a {@code String}) in the
* single column named {@code TABLE_CAT}.
* @throws SQLException
* if there is a database error.
*/
public ResultSet getCatalogs() throws SQLException;
/**
* Returns the separator that this database uses between a catalog name and
* table name.
*
* @return a String containing the separator.
* @throws SQLException
* if there is a database error.
*/
public String getCatalogSeparator() throws SQLException;
/**
* Returns the term that the database vendor prefers term for "catalog".
*
* @return a String with the vendor's term for "catalog".
* @throws SQLException
* if there is a database error.
*/
public String getCatalogTerm() throws SQLException;
/**
* Returns a description of access rights for a table's columns. Only access
* rights matching the criteria for the column name are returned.
* <p>
* The description is returned as a {@code ResultSet} with rows of data for
* each access right, with columns as follows:
* <ol>
* <li>{@code TABLE_CAT} - String - the catalog name (possibly {@code null})</li>
* <li>{@code TABLE_SCHEM} - String - the schema name (possibly {@code null})</li>
* <li>{@code TABLE_NAME} - String - the table name</li>
* <li>{@code COLUMN_NAME} - String - the Column name</li>
* <li>{@code GRANTOR} - String - the grantor of access (possibly {@code
* null})</li>
* <li>{@code PRIVILEGE} - String - Access right - one of SELECT, INSERT,
* UPDATE, REFERENCES,...</li>
* <li>{@code IS_GRANTABLE} - String - {@code "YES"} implies that the
* receiver can grant access to others, {@code "NO"} if the receiver cannot
* grant access to others, {@code null} if unknown.</li>
* </ol>
*
* @param catalog
* a catalog name. {@code null} is used to imply no narrowing of
* the search by catalog name. Otherwise, the name must match a
* catalog name held in the database, with "" used to retrieve
* those without a catalog name.
* @param schema
* a schema name pattern. {@code null} is used to imply no
* narrowing of the search by schema name. Otherwise, the name
* must match a schema name in the database, with "" used to
* retrieve those without a schema name.
* @param table
* the table name. This must match the name of the table as
* declared in the database.
* @param columnNamePattern
* the column name. This must match the name of a column in the
* table in the database.
* @return a {@code ResultSet} containing the access rights, one row for
* each privilege description.
* @throws SQLException
* if there is a database error.
*/
public ResultSet getColumnPrivileges(String catalog, String schema,
String table, String columnNamePattern) throws SQLException;
/**
* Returns a description of table columns available in a specified catalog.
* Only descriptions meeting the specified catalog, schema, table, and column
* names are returned.
* <p>
* The descriptions are returned as a {@code ResultSet} conforming to the
* following data layout, with one row per table column:
* <ol>
* <li>{@code TABLE_CAT} - String - the catalog name (possibly {@code null})</li>
* <li>{@code TABLE_SCHEM} - String - the schema name (possibly {@code null})</li>
* <li>{@code TABLE_NAME} - String - the table name</li>
* <li>{@code COLUMN_NAME} - String - the column name</li>
* <li>{@code DATA_TYPE} - int - the SQL type as specified in {@code
* java.sql.Types}</li>
* <li>{@code TYPE_NAME} - String - the name of the data type, (database-dependent,
* UDT names are fully qualified)</li>
* <li>{@code COLUMN_SIZE} - int - the column size (the precision for numeric
* types, max characters for {@code char} and {@code date} types)</li>
* <li>{@code BUFFER_LENGTH} - int - Not used</li>
* <li>{@code DECIMAL_DIGITS} - int - maximum number of fractional digits</li>
* <li>{@code NUM_PREC_RADIX} - int - the radix for numerical types</li>
* <li>{@code NULLABLE} - int - whether the column allows {@code null}s:
* <ul>
* <li>DatabaseMetaData.columnNoNulls = may not allow {@code NULL}s</li>
* <li>DatabaseMetaData.columnNullable = does allow {@code NULL}s</li>
* <li>DatabaseMetaData.columnNullableUnknown = unknown {@code NULL} status</li>
* </ul>
* </li>
* <li>{@code REMARKS} - String - A description of the column (possibly
* {@code null})</li>
* <li>{@code COLUMN_DEF} - String - Default value for the column (possibly
* {@code null})</li>
* <li>{@code SQL_DATA_TYPE} - int - not used</li>
* <li>{@code SQL_DATETIME_SUB} - int - not used</li>
* <li>{@code CHAR_OCTET_LENGTH} - int - maximum number of bytes in the
* {@code char} type columns</li>
* <li>{@code ORDINAL_POSITION} - int - the column index in the table (1 based)</li>
* <li>{@code IS_NULLABLE} - String - {@code "NO"} = column does not allow
* NULLs, {@code "YES"} = column allows NULLs, "" = {@code NULL} status
* unknown</li>
* <li>{@code SCOPE_CATALOG} - String - if the {@code DATA_TYPE} is {@code REF},
* this gives the catalog of the table corresponding to the attribute's scope.
* NULL if the {@code DATA_TYPE} is not REF.</li>
* <li>{@code SCOPE_SCHEMA} - String - if the {@code DATA_TYPE} is {@code REF},
* this gives the schema of the table corresponding to the attribute's scope.
* NULL if the {@code DATA_TYPE} is not REF.</li>
* <li>{@code SCOPE_TABLE} - String - if the {@code DATA_TYPE} is {@code REF},
* this gives the name of the table corresponding to the attribute's scope.
* NULL if the {@code DATA_TYPE} is not REF.</li>
* <li>{@code SOURCE_DATA_TYPE} - String - The source type for a user
* generated REF type or for a Distinct type. ({@code NULL} if {@code
* DATA_TYPE} is not DISTINCT or a user generated REF)</li>
* </ol>
*
* @param catalog
* a catalog name. {@code null} is used to imply no narrowing of
* the search by catalog name. Otherwise, the name must match a
* catalog name held in the database, with "" used to retrieve
* those without a catalog name.
* @param schemaPattern
* a schema name pattern. {@code null} is used to imply no
* narrowing of the search by schema name. Otherwise, the name
* must match a schema name in the database, with "" used to
* retrieve those without a schema name.
* @param tableNamePattern
* the table name. This must match the name of the table as
* declared in the database.
* @param columnNamePattern
* the column name. This must match the name of a column in the
* table in the database.
* @return the descriptions as a {@code ResultSet} with rows in the form
* defined above.
* @throws SQLException
* if there is a database error.
*/
public ResultSet getColumns(String catalog, String schemaPattern,
String tableNamePattern, String columnNamePattern)
throws SQLException;
/**
* Returns the database connection that created this metadata.
*
* @return the connection to the database.
* @throws SQLException
* if there is a database error.
*/
public Connection getConnection() throws SQLException;
/**
* Returns a list of foreign key columns in a given foreign key table that
* reference the primary key columns of a supplied primary key table. This
* describes how one table imports the key of another table. It would be
* expected to return a single foreign key - primary key pair in most cases.
* <p>
* The descriptions are returned as a {@code ResultSet} with one row for
* each foreign key, with the following layout:
* <ol>
* <li>{@code PKTABLE_CAT} - String - from the primary key table : Catalog
* (possibly {@code null})</li>
* <li>{@code PKTABLE_SCHEM} - String - from the primary key table : Schema
* (possibly {@code null})</li>
* <li>{@code PKTABLE_NAME} - String - from the primary key table : name</li>
* <li>{@code PKCOLUMN_NAME} - String - from the primary key column : name</li>
* <li>{@code FKTABLE_CAT} - String - from the foreign key table : the
* catalog name being exported (possibly {@code null})</li>
* <li>{@code FKTABLE_SCHEM} - String - from the foreign key table : the schema name
* being exported (possibly {@code null})</li>
* <li>{@code FKTABLE_NAME} - String - from the foreign key table : the name being
* exported</li>
* <li>{@code FKCOLUMN_NAME} - String - from the foreign key column : the name being
* exported</li>
* <li>{@code KEY_SEQ} - short - the sequence number (in the foreign key)</li>
* <li>{@code UPDATE_RULE} - short - a value giving the rule for how to treat the corresponding foreign key when a primary
* key is updated:
* <ul>
* <li>{@code DatabaseMetaData.importedKeyNoAction} - don't allow the
* primary key to be updated if it is imported as a foreign key</li>
* <li>{@code DatabaseMetaData.importedKeyCascade} - change the imported key to
* match the updated primary key</li>
* <li>{@code DatabaseMetaData.importedKeySetNull} - set the imported key to
* {@code null}</li>
* <li>{@code DatabaseMetaData.importedKeySetDefault} - set the imported key
* to its default value</li>
* <li>{@code DatabaseMetaData.importedKeyRestrict} - same as {@code
* importedKeyNoAction}</li>
* </ul>
* </li>
* <li>{@code DELETE_RULE} - short - a value giving the rule for how to treat the foreign key when the corresponding primary
* key is deleted:
* <ul>
* <li>{@code DatabaseMetaData.importedKeyNoAction} - don't allow the
* primary key to be deleted if it is imported as a foreign key</li>
* <li>{@code DatabaseMetaData.importedKeyCascade} - delete those rows that
* import a deleted key</li>
* <li>{@code DatabaseMetaData.importedKeySetNull} - set the imported key to
* {@code null}</li>
* <li>{@code DatabaseMetaData.importedKeySetDefault} - set the imported key
* to its default value</li>
* <li>{@code DatabaseMetaData.importedKeyRestrict} - same as
* importedKeyNoAction</li>
* </ul>
* </li>
* <li>{@code FK_NAME} - String - the foreign key name (possibly {@code null})</li>
* <li>{@code PK_NAME} - String - the primary key name (possibly {@code null})</li>
* <li>{@code DEFERRABILITY} - short - whether foreign key constraints can be
* deferred until commit (see the SQL92 specification for definitions):
* <ul>
* <li>{@code DatabaseMetaData.importedKeyInitiallyDeferred}</li>
* <li>{@code DatabaseMetaData.importedKeyInitiallyImmediate}</li>
* <li>{@code DatabaseMetaData.importedKeyNotDeferrable}</li>
* </ul>
* </li>
* </ol>
*
* @param primaryCatalog
* a catalog name for the primary key table. {@code null} is used to imply no narrowing of
* the search by catalog name. Otherwise, the name must match a
* catalog name held in the database, with "" used to retrieve
* those without a catalog name.
* @param primarySchema
* a schema name for the primary key table. {@code null} is used to imply no narrowing of
* the search by schema name. Otherwise, the name must match a
* schema name in the database, with "" used to retrieve those
* without a schema name.
* @param primaryTable
* the name of the table which exports the key. It must match the
* name of the table in the database.
* @param foreignCatalog
* a catalog name for the foreign key table. {@code null} is used to imply no narrowing of
* the search by catalog name. Otherwise, the name must match a
* catalog name held in the database, with "" used to retrieve
* those without a catalog name.
* @param foreignSchema
* a schema name for the foreign key table. {@code null} is used to imply no narrowing of
* the search by schema name. Otherwise, the name must match a
* schema name in the database, with "" used to retrieve those
* without a schema name.
* @param foreignTable
* the name of the table importing the key. It must match the
* name of the table in the database.
* @return a {@code ResultSet} containing rows with the descriptions of the
* foreign keys laid out according to the format defined above.
* @throws SQLException
* if there is a database error.
*/
public ResultSet getCrossReference(String primaryCatalog,
String primarySchema, String primaryTable, String foreignCatalog,
String foreignSchema, String foreignTable) throws SQLException;
/**
* Returns the major version number of the database software.
*
* @return the major version number of the database software.
* @throws SQLException
* a database error occurred.
*/
public int getDatabaseMajorVersion() throws SQLException;
/**
* Returns the minor version number of the database software.
*
* @return the minor version number of the database software.
* @throws SQLException
* a database error occurred.
*/
public int getDatabaseMinorVersion() throws SQLException;
/**
* Returns the name of the database software.
*
* @return a {@code String} with the name of the database software.
* @throws SQLException
* a database error occurred.
*/
public String getDatabaseProductName() throws SQLException;
/**
* Returns the version number of this database software.
*
* @return a {@code String} with the version number of the database
* software.
* @throws SQLException
* a database error occurred.
*/
public String getDatabaseProductVersion() throws SQLException;
/**
* Returns the default transaction isolation level for this database.
*
* @return the default transaction isolation level. One of the following values:
* <ul>
* <li>{@code TRANSACTION_NONE}</li>
* <li>{@code TRANSACTION_READ_COMMITTED}</li>
* <li>{@code TRANSACTION_READ_UNCOMMITTED}</li>
* <li>{@code TRANSACTION_REPEATABLE_READ}</li>
* <li>{@code TRANSACTION_SERIALIZABLE}</li>
* </ul>
* @throws SQLException
* a database error occurred.
*/
public int getDefaultTransactionIsolation() throws SQLException;
/**
* Returns the JDBC driver's major version number.
*
* @return the driver's major version number.
*/
public int getDriverMajorVersion();
/**
* Returns the JDBC driver's minor version number.
*
* @return the driver's minor version number.
*/
public int getDriverMinorVersion();
/**
* Returns the name of this JDBC driver.
*
* @return a {@code String} containing the name of the JDBC driver
* @throws SQLException
* a database error occurred.
*/
public String getDriverName() throws SQLException;
/**
* Returns the version number of this JDBC driver.
*
* @return a {@code String} containing the complete version number of the
* JDBC driver.
* @throws SQLException
* a database error occurred.
*/
public String getDriverVersion() throws SQLException;
/**
* Returns a list of the foreign key columns that reference the primary key
* columns of a specified table (the foreign keys exported by a table).
* <p>
* The list is returned as a {@code ResultSet} with a row for each of the
* foreign key columns, ordered by {@code FKTABLE_CAT}, {@code
* FKTABLE_SCHEM}, {@code FKTABLE_NAME}, and {@code KEY_SEQ}, with the
* format for each row being:
* <ol>
* <li>{@code PKTABLE_CAT} - String - from the primary key table : the catalog (possibly
* {@code null})</li>
* <li>{@code PKTABLE_SCHEM} - String - from the primary key table : the schema (possibly
* {@code null})</li>
* <li>{@code PKTABLE_NAME} - String - from the primary key table : the name</li>
* <li>{@code PKCOLUMN_NAME} - String - from the primary key column : the name</li>
* <li>{@code FKTABLE_CAT} - String - from the foreign key table : the catalog name being
* exported (possibly {@code null})</li>
* <li>{@code FKTABLE_SCHEM} - String - from the foreign key table : the schema name
* being exported (possibly {@code null})</li>
* <li>{@code FKTABLE_NAME} - String - from the foreign key table : the name being
* exported</li>
* <li>{@code FKCOLUMN_NAME} - String - from the foreign key column : the name being
* exported</li>
* <li>{@code KEY_SEQ} - short - the sequence number (in the foreign key)</li>
* <li>{@code UPDATE_RULE} - short - a value giving the rule for how to treat the foreign key when the corresponding primary
* key is updated:
* <ul>
* <li>{@code DatabaseMetaData.importedKeyNoAction} - don't allow the
* primary key to be updated if it is imported as a foreign key</li>
* <li>{@code DatabaseMetaData.importedKeyCascade} - change the imported key to
* match the primary key update</li>
* <li>{@code DatabaseMetaData.importedKeySetNull} - set the imported key to
* {@code null}</li>
* <li>{@code DatabaseMetaData.importedKeySetDefault} - set the imported key
* to its default value</li>
* <li>{@code DatabaseMetaData.importedKeyRestrict} - same as
* importedKeyNoAction</li>
* </ul>
* </li>
* <li>{@code DELETE_RULE} - short - how to treat the foreign key when the corresponding primary
* key is deleted:
* <ul>
* <li>{@code DatabaseMetaData.importedKeyNoAction} - don't allow the
* primary key to be deleted if it is imported as a foreign key</li>
* <li>{@code DatabaseMetaData.importedKeyCascade} - the deletion should
* also delete rows that import a deleted key</li>
* <li>{@code DatabaseMetaData.importedKeySetNull} - the deletion sets the
* imported key to {@code null}</li>
* <li>{@code DatabaseMetaData.importedKeySetDefault} - the deletion sets the
* imported key to its default value</li>
* <li>{@code DatabaseMetaData.importedKeyRestrict} - same as
* importedKeyNoAction</li>
* </ul>
* </li>
* <li>{@code FK_NAME} - String - the foreign key name (possibly {@code null})</li>
* <li>{@code PK_NAME} - String - the primary key name (possibly {@code null})</li>
* <li>{@code DEFERRABILITY} - short - defines whether the foreign key
* constraints can be deferred until commit (see the SQL92 specification for
* definitions):
* <ul>
* <li>{@code DatabaseMetaData.importedKeyInitiallyDeferred}</li>
* <li>{@code DatabaseMetaData.importedKeyInitiallyImmediate}</li>
* <li>{@code DatabaseMetaData.importedKeyNotDeferrable}</li>
* </ul>