1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package java.sql;
19
20/**
21 * Provides information about the columns returned in a {@code ResultSet}.
22 */
23public interface ResultSetMetaData extends Wrapper {
24
25    /**
26     * Indicates that a column cannot contain {@code NULL} values.
27     */
28    public static final int columnNoNulls = 0;
29
30    /**
31     * Indicates that a column can contain {@code NULL} values.
32     */
33    public static final int columnNullable = 1;
34
35    /**
36     * Indicates that it is unknown whether a column can contain {@code NULL}s or not.
37     */
38    public static final int columnNullableUnknown = 2;
39
40    /**
41     * Returns the title of an indexed column's catalog.
42     *
43     * @param column
44     *            the column index, starting at 1.
45     * @return the catalog title.
46     * @throws SQLException
47     *             if there is a database error.
48     */
49    public String getCatalogName(int column) throws SQLException;
50
51    /**
52     * Returns the fully-qualified type of the class that is produced when
53     * invoking {@code ResultSet.getObject} to recover this column's value.
54     *
55     * @param column
56     *            the column index, starting at 1.
57     * @return the fully-qualified class name.
58     * @throws SQLException
59     *             if there is a database error.
60     * @see ResultSet#getObject
61     */
62    public String getColumnClassName(int column) throws SQLException;
63
64    /**
65     * Returns number of columns contained in the associated result set.
66     *
67     * @return the column count.
68     * @throws SQLException
69     *             if there is a database error.
70     */
71    public int getColumnCount() throws SQLException;
72
73    /**
74     * Returns the indexed column's standard maximum width, expressed in number
75     * of characters.
76     *
77     * @param column
78     *            the column index, starting at 1.
79     * @return the column's max width.
80     * @throws SQLException
81     *             if there is a database error.
82     */
83    public int getColumnDisplaySize(int column) throws SQLException;
84
85    /**
86     * Returns a recommended title for the indexed column, to be used when the
87     * title needs to be displayed.
88     *
89     * @param column
90     *            the column index, starting at 1.
91     * @return the column's title.
92     * @throws SQLException
93     *             if there is a database error.
94     */
95    public String getColumnLabel(int column) throws SQLException;
96
97    /**
98     * Returns the title of the indexed column.
99     *
100     * @param column
101     *            the column index, starting at 1.
102     * @return the column title.
103     * @throws SQLException
104     *             if there is a database error.
105     */
106    public String getColumnName(int column) throws SQLException;
107
108    /**
109     * Returns the type of the indexed column as SQL type code.
110     *
111     * @param column
112     *            the column index, starting at 1.
113     * @return the column type code.
114     * @throws SQLException
115     *             if there is a database error.
116     * @see Types
117     */
118    public int getColumnType(int column) throws SQLException;
119
120    /**
121     * Returns the type name of the indexed column.
122     *
123     * @param column
124     *            the column index, starting at 1.
125     * @return the type name.
126     * @throws SQLException
127     *             if there is a database error.
128     */
129    public String getColumnTypeName(int column) throws SQLException;
130
131    /**
132     * Returns the decimal precision of the indexed column.
133     *
134     * @param column
135     *            the column index, starting at 1.
136     * @return the precision.
137     * @throws SQLException
138     *             if there is a database error.
139     */
140    public int getPrecision(int column) throws SQLException;
141
142    /**
143     * Returns the number of digits to the right of the decimal point of the
144     * indexed column.
145     *
146     * @param column
147     *            the column index, starting at 1.
148     * @return number of decimal places.
149     * @throws SQLException
150     *             if there is a database error.
151     */
152    public int getScale(int column) throws SQLException;
153
154    /**
155     * Returns the name of the indexed columns schema.
156     *
157     * @param column
158     *            the column index, starting at 1.
159     * @return the name of the columns schema.
160     * @throws SQLException
161     *             if there is a database error.
162     */
163    public String getSchemaName(int column) throws SQLException;
164
165    /**
166     * Returns the title of the indexed columns table.
167     *
168     * @param column
169     *            the column index, starting at 1.
170     * @return the table title.
171     * @throws SQLException
172     *             if there is a database error.
173     */
174    public String getTableName(int column) throws SQLException;
175
176    /**
177     * Returns an indication of whether the indexed column is automatically
178     * incremented and is therefore read-only.
179     *
180     * @param column
181     *            the column index, starting at 1.
182     * @return {@code true} if it is automatically numbered, {@code false}
183     *         otherwise.
184     * @throws SQLException
185     *             if there is a database error.
186     */
187    public boolean isAutoIncrement(int column) throws SQLException;
188
189    /**
190     * Returns an indication of whether the case of the indexed column is
191     * important.
192     *
193     * @param column
194     *            the column index, starting at 1.
195     * @return {@code true} if case matters, {@code false} otherwise.
196     * @throws SQLException
197     *             if there is a database error.
198     */
199    public boolean isCaseSensitive(int column) throws SQLException;
200
201    /**
202     * Returns whether the indexed column contains a monetary amount.
203     *
204     * @param column
205     *            the column index, starting at 1.
206     * @return {@code true} if it is a monetary value, {@code false} otherwise.
207     * @throws SQLException
208     *             if there is a database error.
209     */
210    public boolean isCurrency(int column) throws SQLException;
211
212    /**
213     * Returns an indication of whether writing to the indexed column is
214     * guaranteed to be successful.
215     *
216     * @param column
217     *            the column index, starting at 1.
218     * @return {@code true} if the write is guaranteed, {@code false} otherwise.
219     * @throws SQLException
220     *             if there is a database error.
221     */
222    public boolean isDefinitelyWritable(int column) throws SQLException;
223
224    /**
225     * Returns whether the indexed column is nullable.
226     *
227     * @param column
228     *            the column index, starting at 1.
229     * @return {@code true} if it is nullable, {@code false} otherwise.
230     * @throws SQLException
231     *             if there is a database error.
232     */
233    public int isNullable(int column) throws SQLException;
234
235    /**
236     * Returns an indication of whether writing to the indexed column is
237     * guaranteed to be unsuccessful.
238     *
239     * @param column
240     *            the column index, starting at 1.
241     * @return {@code true} if the column is read-only, {@code false} otherwise.
242     * @throws SQLException
243     *             if there is a database error.
244     */
245    public boolean isReadOnly(int column) throws SQLException;
246
247    /**
248     * Returns an indication of whether the indexed column is searchable.
249     *
250     * @param column
251     *            the column index, starting at 1.
252     * @return {@code true} if the indexed column is searchable, {@code false}
253     *         otherwise.
254     * @throws SQLException
255     *             if there is a database error.
256     */
257    public boolean isSearchable(int column) throws SQLException;
258
259    /**
260     * Returns an indication of whether the values contained in the indexed
261     * column are signed.
262     *
263     * @param column
264     *            the column index, starting at 1.
265     * @return {@code true} if they are signed, {@code false} otherwise.
266     * @throws SQLException
267     *             if there is a database error.
268     */
269    public boolean isSigned(int column) throws SQLException;
270
271    /**
272     * Returns an indication of whether writing to the indexed column is
273     * possible.
274     *
275     * @param column
276     *            the column index, starting at 1.
277     * @return {@code true} if it is possible to write, {@code false} otherwise.
278     * @throws SQLException
279     *             if there is a database error.
280     */
281    public boolean isWritable(int column) throws SQLException;
282}
283