KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > sql > ResultSetMetaData


1 /*
2  * @(#)ResultSetMetaData.java 1.27 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.sql;
9
10 /**
11  * An object that can be used to get information about the types
12  * and properties of the columns in a <code>ResultSet</code> object.
13  * The following code fragment creates the <code>ResultSet</code> object rs,
14  * creates the <code>ResultSetMetaData</code> object rsmd, and uses rsmd
15  * to find out how many columns rs has and whether the first column in rs
16  * can be used in a <code>WHERE</code> clause.
17  * <PRE>
18  *
19  * ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM TABLE2");
20  * ResultSetMetaData rsmd = rs.getMetaData();
21  * int numberOfColumns = rsmd.getColumnCount();
22  * boolean b = rsmd.isSearchable(1);
23  *
24  * </PRE>
25  */

26
27 public interface ResultSetMetaData {
28
29     /**
30      * Returns the number of columns in this <code>ResultSet</code> object.
31      *
32      * @return the number of columns
33      * @exception SQLException if a database access error occurs
34      */

35     int getColumnCount() throws SQLException JavaDoc;
36
37     /**
38      * Indicates whether the designated column is automatically numbered, thus read-only.
39      *
40      * @param column the first column is 1, the second is 2, ...
41      * @return <code>true</code> if so; <code>false</code> otherwise
42      * @exception SQLException if a database access error occurs
43      */

44     boolean isAutoIncrement(int column) throws SQLException JavaDoc;
45
46     /**
47      * Indicates whether a column's case matters.
48      *
49      * @param column the first column is 1, the second is 2, ...
50      * @return <code>true</code> if so; <code>false</code> otherwise
51      * @exception SQLException if a database access error occurs
52      */

53     boolean isCaseSensitive(int column) throws SQLException JavaDoc;
54
55     /**
56      * Indicates whether the designated column can be used in a where clause.
57      *
58      * @param column the first column is 1, the second is 2, ...
59      * @return <code>true</code> if so; <code>false</code> otherwise
60      * @exception SQLException if a database access error occurs
61      */

62     boolean isSearchable(int column) throws SQLException JavaDoc;
63
64     /**
65      * Indicates whether the designated column is a cash value.
66      *
67      * @param column the first column is 1, the second is 2, ...
68      * @return <code>true</code> if so; <code>false</code> otherwise
69      * @exception SQLException if a database access error occurs
70      */

71     boolean isCurrency(int column) throws SQLException JavaDoc;
72
73     /**
74      * Indicates the nullability of values in the designated column.
75      *
76      * @param column the first column is 1, the second is 2, ...
77      * @return the nullability status of the given column; one of <code>columnNoNulls</code>,
78      * <code>columnNullable</code> or <code>columnNullableUnknown</code>
79      * @exception SQLException if a database access error occurs
80      */

81     int isNullable(int column) throws SQLException JavaDoc;
82
83     /**
84      * The constant indicating that a
85      * column does not allow <code>NULL</code> values.
86      */

87     int columnNoNulls = 0;
88
89     /**
90      * The constant indicating that a
91      * column allows <code>NULL</code> values.
92      */

93     int columnNullable = 1;
94
95     /**
96      * The constant indicating that the
97      * nullability of a column's values is unknown.
98      */

99     int columnNullableUnknown = 2;
100
101     /**
102      * Indicates whether values in the designated column are signed numbers.
103      *
104      * @param column the first column is 1, the second is 2, ...
105      * @return <code>true</code> if so; <code>false</code> otherwise
106      * @exception SQLException if a database access error occurs
107      */

108     boolean isSigned(int column) throws SQLException JavaDoc;
109
110     /**
111      * Indicates the designated column's normal maximum width in characters.
112      *
113      * @param column the first column is 1, the second is 2, ...
114      * @return the normal maximum number of characters allowed as the width
115      * of the designated column
116      * @exception SQLException if a database access error occurs
117      */

118     int getColumnDisplaySize(int column) throws SQLException JavaDoc;
119
120     /**
121      * Gets the designated column's suggested title for use in printouts and
122      * displays.
123      *
124      * @param column the first column is 1, the second is 2, ...
125      * @return the suggested column title
126      * @exception SQLException if a database access error occurs
127      */

128     String JavaDoc getColumnLabel(int column) throws SQLException JavaDoc;
129
130     /**
131      * Get the designated column's name.
132      *
133      * @param column the first column is 1, the second is 2, ...
134      * @return column name
135      * @exception SQLException if a database access error occurs
136      */

137     String JavaDoc getColumnName(int column) throws SQLException JavaDoc;
138
139     /**
140      * Get the designated column's table's schema.
141      *
142      * @param column the first column is 1, the second is 2, ...
143      * @return schema name or "" if not applicable
144      * @exception SQLException if a database access error occurs
145      */

146     String JavaDoc getSchemaName(int column) throws SQLException JavaDoc;
147
148     /**
149      * Get the designated column's number of decimal digits.
150      *
151      * @param column the first column is 1, the second is 2, ...
152      * @return precision
153      * @exception SQLException if a database access error occurs
154      */

155     int getPrecision(int column) throws SQLException JavaDoc;
156
157     /**
158      * Gets the designated column's number of digits to right of the decimal point.
159      *
160      * @param column the first column is 1, the second is 2, ...
161      * @return scale
162      * @exception SQLException if a database access error occurs
163      */

164     int getScale(int column) throws SQLException JavaDoc;
165
166     /**
167      * Gets the designated column's table name.
168      *
169      * @param column the first column is 1, the second is 2, ...
170      * @return table name or "" if not applicable
171      * @exception SQLException if a database access error occurs
172      */

173     String JavaDoc getTableName(int column) throws SQLException JavaDoc;
174
175     /**
176      * Gets the designated column's table's catalog name.
177      *
178      * @param column the first column is 1, the second is 2, ...
179      * @return the name of the catalog for the table in which the given column
180      * appears or "" if not applicable
181      * @exception SQLException if a database access error occurs
182      */

183     String JavaDoc getCatalogName(int column) throws SQLException JavaDoc;
184
185     /**
186      * Retrieves the designated column's SQL type.
187      *
188      * @param column the first column is 1, the second is 2, ...
189      * @return SQL type from java.sql.Types
190      * @exception SQLException if a database access error occurs
191      * @see Types
192      */

193     int getColumnType(int column) throws SQLException JavaDoc;
194
195     /**
196      * Retrieves the designated column's database-specific type name.
197      *
198      * @param column the first column is 1, the second is 2, ...
199      * @return type name used by the database. If the column type is
200      * a user-defined type, then a fully-qualified type name is returned.
201      * @exception SQLException if a database access error occurs
202      */

203     String JavaDoc getColumnTypeName(int column) throws SQLException JavaDoc;
204
205     /**
206      * Indicates whether the designated column is definitely not writable.
207      *
208      * @param column the first column is 1, the second is 2, ...
209      * @return <code>true</code> if so; <code>false</code> otherwise
210      * @exception SQLException if a database access error occurs
211      */

212     boolean isReadOnly(int column) throws SQLException JavaDoc;
213
214     /**
215      * Indicates whether it is possible for a write on the designated column to succeed.
216      *
217      * @param column the first column is 1, the second is 2, ...
218      * @return <code>true</code> if so; <code>false</code> otherwise
219      * @exception SQLException if a database access error occurs
220      */

221     boolean isWritable(int column) throws SQLException JavaDoc;
222
223     /**
224      * Indicates whether a write on the designated column will definitely succeed.
225      *
226      * @param column the first column is 1, the second is 2, ...
227      * @return <code>true</code> if so; <code>false</code> otherwise
228      * @exception SQLException if a database access error occurs
229      */

230     boolean isDefinitelyWritable(int column) throws SQLException JavaDoc;
231
232     //--------------------------JDBC 2.0-----------------------------------
233

234     /**
235      * <p>Returns the fully-qualified name of the Java class whose instances
236      * are manufactured if the method <code>ResultSet.getObject</code>
237      * is called to retrieve a value
238      * from the column. <code>ResultSet.getObject</code> may return a subclass of the
239      * class returned by this method.
240      *
241      * @param column the first column is 1, the second is 2, ...
242      * @return the fully-qualified name of the class in the Java programming
243      * language that would be used by the method
244      * <code>ResultSet.getObject</code> to retrieve the value in the specified
245      * column. This is the class name used for custom mapping.
246      * @exception SQLException if a database access error occurs
247      * @since 1.2
248      */

249     String JavaDoc getColumnClassName(int column) throws SQLException JavaDoc;
250 }
251
Popular Tags