2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
5506
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
2
|
24 |
*/
|
|
25 |
|
|
26 |
package java.sql;
|
|
27 |
|
|
28 |
/**
|
|
29 |
* An object that can be used to get information about the types
|
|
30 |
* and properties of the columns in a <code>ResultSet</code> object.
|
|
31 |
* The following code fragment creates the <code>ResultSet</code> object rs,
|
|
32 |
* creates the <code>ResultSetMetaData</code> object rsmd, and uses rsmd
|
|
33 |
* to find out how many columns rs has and whether the first column in rs
|
|
34 |
* can be used in a <code>WHERE</code> clause.
|
|
35 |
* <PRE>
|
|
36 |
*
|
|
37 |
* ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM TABLE2");
|
|
38 |
* ResultSetMetaData rsmd = rs.getMetaData();
|
|
39 |
* int numberOfColumns = rsmd.getColumnCount();
|
|
40 |
* boolean b = rsmd.isSearchable(1);
|
|
41 |
*
|
|
42 |
* </PRE>
|
44256
|
43 |
*
|
|
44 |
* @since 1.1
|
2
|
45 |
*/
|
|
46 |
|
|
47 |
public interface ResultSetMetaData extends Wrapper {
|
|
48 |
|
|
49 |
/**
|
|
50 |
* Returns the number of columns in this <code>ResultSet</code> object.
|
|
51 |
*
|
|
52 |
* @return the number of columns
|
|
53 |
* @exception SQLException if a database access error occurs
|
|
54 |
*/
|
|
55 |
int getColumnCount() throws SQLException;
|
|
56 |
|
|
57 |
/**
|
|
58 |
* Indicates whether the designated column is automatically numbered.
|
|
59 |
*
|
|
60 |
* @param column the first column is 1, the second is 2, ...
|
|
61 |
* @return <code>true</code> if so; <code>false</code> otherwise
|
|
62 |
* @exception SQLException if a database access error occurs
|
|
63 |
*/
|
|
64 |
boolean isAutoIncrement(int column) throws SQLException;
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Indicates whether a column's case matters.
|
|
68 |
*
|
|
69 |
* @param column the first column is 1, the second is 2, ...
|
|
70 |
* @return <code>true</code> if so; <code>false</code> otherwise
|
|
71 |
* @exception SQLException if a database access error occurs
|
|
72 |
*/
|
|
73 |
boolean isCaseSensitive(int column) throws SQLException;
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Indicates whether the designated column can be used in a where clause.
|
|
77 |
*
|
|
78 |
* @param column the first column is 1, the second is 2, ...
|
|
79 |
* @return <code>true</code> if so; <code>false</code> otherwise
|
|
80 |
* @exception SQLException if a database access error occurs
|
|
81 |
*/
|
|
82 |
boolean isSearchable(int column) throws SQLException;
|
|
83 |
|
|
84 |
/**
|
|
85 |
* Indicates whether the designated column is a cash value.
|
|
86 |
*
|
|
87 |
* @param column the first column is 1, the second is 2, ...
|
|
88 |
* @return <code>true</code> if so; <code>false</code> otherwise
|
|
89 |
* @exception SQLException if a database access error occurs
|
|
90 |
*/
|
|
91 |
boolean isCurrency(int column) throws SQLException;
|
|
92 |
|
|
93 |
/**
|
|
94 |
* Indicates the nullability of values in the designated column.
|
|
95 |
*
|
|
96 |
* @param column the first column is 1, the second is 2, ...
|
|
97 |
* @return the nullability status of the given column; one of <code>columnNoNulls</code>,
|
|
98 |
* <code>columnNullable</code> or <code>columnNullableUnknown</code>
|
|
99 |
* @exception SQLException if a database access error occurs
|
|
100 |
*/
|
|
101 |
int isNullable(int column) throws SQLException;
|
|
102 |
|
|
103 |
/**
|
|
104 |
* The constant indicating that a
|
|
105 |
* column does not allow <code>NULL</code> values.
|
|
106 |
*/
|
|
107 |
int columnNoNulls = 0;
|
|
108 |
|
|
109 |
/**
|
|
110 |
* The constant indicating that a
|
|
111 |
* column allows <code>NULL</code> values.
|
|
112 |
*/
|
|
113 |
int columnNullable = 1;
|
|
114 |
|
|
115 |
/**
|
|
116 |
* The constant indicating that the
|
|
117 |
* nullability of a column's values is unknown.
|
|
118 |
*/
|
|
119 |
int columnNullableUnknown = 2;
|
|
120 |
|
|
121 |
/**
|
|
122 |
* Indicates whether values in the designated column are signed numbers.
|
|
123 |
*
|
|
124 |
* @param column the first column is 1, the second is 2, ...
|
|
125 |
* @return <code>true</code> if so; <code>false</code> otherwise
|
|
126 |
* @exception SQLException if a database access error occurs
|
|
127 |
*/
|
|
128 |
boolean isSigned(int column) throws SQLException;
|
|
129 |
|
|
130 |
/**
|
|
131 |
* Indicates the designated column's normal maximum width in characters.
|
|
132 |
*
|
|
133 |
* @param column the first column is 1, the second is 2, ...
|
|
134 |
* @return the normal maximum number of characters allowed as the width
|
|
135 |
* of the designated column
|
|
136 |
* @exception SQLException if a database access error occurs
|
|
137 |
*/
|
|
138 |
int getColumnDisplaySize(int column) throws SQLException;
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Gets the designated column's suggested title for use in printouts and
|
|
142 |
* displays. The suggested title is usually specified by the SQL <code>AS</code>
|
|
143 |
* clause. If a SQL <code>AS</code> is not specified, the value returned from
|
|
144 |
* <code>getColumnLabel</code> will be the same as the value returned by the
|
|
145 |
* <code>getColumnName</code> method.
|
|
146 |
*
|
|
147 |
* @param column the first column is 1, the second is 2, ...
|
|
148 |
* @return the suggested column title
|
|
149 |
* @exception SQLException if a database access error occurs
|
|
150 |
*/
|
|
151 |
String getColumnLabel(int column) throws SQLException;
|
|
152 |
|
|
153 |
/**
|
|
154 |
* Get the designated column's name.
|
|
155 |
*
|
|
156 |
* @param column the first column is 1, the second is 2, ...
|
|
157 |
* @return column name
|
|
158 |
* @exception SQLException if a database access error occurs
|
|
159 |
*/
|
|
160 |
String getColumnName(int column) throws SQLException;
|
|
161 |
|
|
162 |
/**
|
|
163 |
* Get the designated column's table's schema.
|
|
164 |
*
|
|
165 |
* @param column the first column is 1, the second is 2, ...
|
|
166 |
* @return schema name or "" if not applicable
|
|
167 |
* @exception SQLException if a database access error occurs
|
|
168 |
*/
|
|
169 |
String getSchemaName(int column) throws SQLException;
|
|
170 |
|
|
171 |
/**
|
|
172 |
* Get the designated column's specified column size.
|
|
173 |
* For numeric data, this is the maximum precision. For character data, this is the length in characters.
|
|
174 |
* For datetime datatypes, this is the length in characters of the String representation (assuming the
|
|
175 |
* maximum allowed precision of the fractional seconds component). For binary data, this is the length in bytes. For the ROWID datatype,
|
|
176 |
* this is the length in bytes. 0 is returned for data types where the
|
|
177 |
* column size is not applicable.
|
|
178 |
*
|
|
179 |
* @param column the first column is 1, the second is 2, ...
|
|
180 |
* @return precision
|
|
181 |
* @exception SQLException if a database access error occurs
|
|
182 |
*/
|
|
183 |
int getPrecision(int column) throws SQLException;
|
|
184 |
|
|
185 |
/**
|
|
186 |
* Gets the designated column's number of digits to right of the decimal point.
|
|
187 |
* 0 is returned for data types where the scale is not applicable.
|
|
188 |
*
|
|
189 |
* @param column the first column is 1, the second is 2, ...
|
|
190 |
* @return scale
|
|
191 |
* @exception SQLException if a database access error occurs
|
|
192 |
*/
|
|
193 |
int getScale(int column) throws SQLException;
|
|
194 |
|
|
195 |
/**
|
|
196 |
* Gets the designated column's table name.
|
|
197 |
*
|
|
198 |
* @param column the first column is 1, the second is 2, ...
|
|
199 |
* @return table name or "" if not applicable
|
|
200 |
* @exception SQLException if a database access error occurs
|
|
201 |
*/
|
|
202 |
String getTableName(int column) throws SQLException;
|
|
203 |
|
|
204 |
/**
|
|
205 |
* Gets the designated column's table's catalog name.
|
|
206 |
*
|
|
207 |
* @param column the first column is 1, the second is 2, ...
|
|
208 |
* @return the name of the catalog for the table in which the given column
|
|
209 |
* appears or "" if not applicable
|
|
210 |
* @exception SQLException if a database access error occurs
|
|
211 |
*/
|
|
212 |
String getCatalogName(int column) throws SQLException;
|
|
213 |
|
|
214 |
/**
|
|
215 |
* Retrieves the designated column's SQL type.
|
|
216 |
*
|
|
217 |
* @param column the first column is 1, the second is 2, ...
|
|
218 |
* @return SQL type from java.sql.Types
|
|
219 |
* @exception SQLException if a database access error occurs
|
|
220 |
* @see Types
|
|
221 |
*/
|
|
222 |
int getColumnType(int column) throws SQLException;
|
|
223 |
|
|
224 |
/**
|
|
225 |
* Retrieves the designated column's database-specific type name.
|
|
226 |
*
|
|
227 |
* @param column the first column is 1, the second is 2, ...
|
|
228 |
* @return type name used by the database. If the column type is
|
|
229 |
* a user-defined type, then a fully-qualified type name is returned.
|
|
230 |
* @exception SQLException if a database access error occurs
|
|
231 |
*/
|
|
232 |
String getColumnTypeName(int column) throws SQLException;
|
|
233 |
|
|
234 |
/**
|
|
235 |
* Indicates whether the designated column is definitely not writable.
|
|
236 |
*
|
|
237 |
* @param column the first column is 1, the second is 2, ...
|
|
238 |
* @return <code>true</code> if so; <code>false</code> otherwise
|
|
239 |
* @exception SQLException if a database access error occurs
|
|
240 |
*/
|
|
241 |
boolean isReadOnly(int column) throws SQLException;
|
|
242 |
|
|
243 |
/**
|
|
244 |
* Indicates whether it is possible for a write on the designated column to succeed.
|
|
245 |
*
|
|
246 |
* @param column the first column is 1, the second is 2, ...
|
|
247 |
* @return <code>true</code> if so; <code>false</code> otherwise
|
|
248 |
* @exception SQLException if a database access error occurs
|
|
249 |
*/
|
|
250 |
boolean isWritable(int column) throws SQLException;
|
|
251 |
|
|
252 |
/**
|
|
253 |
* Indicates whether a write on the designated column will definitely succeed.
|
|
254 |
*
|
|
255 |
* @param column the first column is 1, the second is 2, ...
|
|
256 |
* @return <code>true</code> if so; <code>false</code> otherwise
|
|
257 |
* @exception SQLException if a database access error occurs
|
|
258 |
*/
|
|
259 |
boolean isDefinitelyWritable(int column) throws SQLException;
|
|
260 |
|
|
261 |
//--------------------------JDBC 2.0-----------------------------------
|
|
262 |
|
|
263 |
/**
|
|
264 |
* <p>Returns the fully-qualified name of the Java class whose instances
|
|
265 |
* are manufactured if the method <code>ResultSet.getObject</code>
|
|
266 |
* is called to retrieve a value
|
|
267 |
* from the column. <code>ResultSet.getObject</code> may return a subclass of the
|
|
268 |
* class returned by this method.
|
|
269 |
*
|
|
270 |
* @param column the first column is 1, the second is 2, ...
|
|
271 |
* @return the fully-qualified name of the class in the Java programming
|
|
272 |
* language that would be used by the method
|
|
273 |
* <code>ResultSet.getObject</code> to retrieve the value in the specified
|
|
274 |
* column. This is the class name used for custom mapping.
|
|
275 |
* @exception SQLException if a database access error occurs
|
|
276 |
* @since 1.2
|
|
277 |
*/
|
|
278 |
String getColumnClassName(int column) throws SQLException;
|
|
279 |
}
|