001 /* ResultSetMetaData.java -- Returns information about the ResultSet
002 Copyright (C) 1999, 2000, 2002, 2006 Free Software Foundation, Inc.
003
004 This file is part of GNU Classpath.
005
006 GNU Classpath is free software; you can redistribute it and/or modify
007 it under the terms of the GNU General Public License as published by
008 the Free Software Foundation; either version 2, or (at your option)
009 any later version.
010
011 GNU Classpath is distributed in the hope that it will be useful, but
012 WITHOUT ANY WARRANTY; without even the implied warranty of
013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 General Public License for more details.
015
016 You should have received a copy of the GNU General Public License
017 along with GNU Classpath; see the file COPYING. If not, write to the
018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019 02110-1301 USA.
020
021 Linking this library statically or dynamically with other modules is
022 making a combined work based on this library. Thus, the terms and
023 conditions of the GNU General Public License cover the whole
024 combination.
025
026 As a special exception, the copyright holders of this library give you
027 permission to link this library with independent modules to produce an
028 executable, regardless of the license terms of these independent
029 modules, and to copy and distribute the resulting executable under
030 terms of your choice, provided that you also meet, for each linked
031 independent module, the terms and conditions of the license of that
032 module. An independent module is a module which is not derived from
033 or based on this library. If you modify this library, you may extend
034 this exception to your version of the library, but you are not
035 obligated to do so. If you do not wish to do so, delete this
036 exception statement from your version. */
037
038
039 package java.sql;
040
041 /**
042 * This interface provides a mechanism for obtaining information about
043 * the columns that are present in a <code>ResultSet</code>.
044 *
045 * <p> Note that in this class column indices start at 1, not 0.</p>
046 *
047 * @author Aaron M. Renn (arenn@urbanophile.com)
048 */
049 public interface ResultSetMetaData
050 {
051 /**
052 * The column does not allow NULL's.
053 */
054 int columnNoNulls = 0;
055
056 /**
057 * The column allows NULL's.
058 */
059 int columnNullable = 1;
060
061 /**
062 * It is unknown whether or not the column allows NULL's.
063 */
064 int columnNullableUnknown = 2;
065
066 /**
067 * This method returns the number of columns in the result set.
068 *
069 * @return The number of columns in the result set.
070 * @exception SQLException If an error occurs.
071 */
072 int getColumnCount() throws SQLException;
073
074 /**
075 * This method test whether or not the column is an auto-increment column.
076 * Auto-increment columns are read-only.
077 *
078 * @param columnIndex The index of the column to test.
079 * @return <code>true</code> if the column is auto-increment, <code>false</code>
080 * otherwise.
081 * @exception SQLException If an error occurs.
082 */
083 boolean isAutoIncrement(int columnIndex) throws SQLException;
084
085 /**
086 * This method tests whether or not a column is case sensitive in its values.
087 *
088 * @param columnIndex The index of the column to test.
089 * @return <code>true</code> if the column value is case sensitive,
090 * <code>false</code> otherwise.
091 * @exception SQLException If an error occurs.
092 */
093 boolean isCaseSensitive(int columnIndex) throws SQLException;
094
095 /**
096 * This method tests whether not the specified column can be used in
097 * a WHERE clause.
098 *
099 * @param columnIndex The index of the column to test.
100 * @return <code>true</code> if the column may be used in a WHERE clause,
101 * <code>false</code> otherwise.
102 * @exception SQLException If an error occurs.
103 */
104 boolean isSearchable(int columnIndex) throws SQLException;
105
106 /**
107 * This method tests whether or not the column stores a monetary value.
108 *
109 * @param columnIndex The index of the column to test.
110 * @return <code>true</code> if the column contains a monetary value,
111 * <code>false</code> otherwise.
112 * @exception SQLException If an error occurs.
113 */
114 boolean isCurrency(int columnIndex) throws SQLException;
115
116 /**
117 * This method returns a value indicating whether or not the specified
118 * column may contain a NULL value.
119 *
120 * @param columnIndex The index of the column to test.
121 * @return A constant indicating whether or not the column can contain NULL,
122 * which will be one of <code>columnNoNulls</code>,
123 * <code>columnNullable</code>, or <code>columnNullableUnknown</code>.
124 * @exception SQLException If an error occurs.
125 */
126 int isNullable(int columnIndex) throws SQLException;
127
128 /**
129 * This method tests whether or not the value of the specified column
130 * is signed or unsigned.
131 *
132 * @param columnIndex The index of the column to test.
133 * @return <code>true</code> if the column value is signed, <code>false</code>
134 * otherwise.
135 * @exception SQLException If an error occurs.
136 */
137 boolean isSigned(int columnIndex) throws SQLException;
138
139 /**
140 * This method returns the maximum number of characters that can be used
141 * to display a value in this column.
142 *
143 * @param columnIndex The index of the column to check.
144 * @return The maximum number of characters that can be used to display a
145 * value for this column.
146 * @exception SQLException If an error occurs.
147 */
148 int getColumnDisplaySize(int columnIndex) throws SQLException;
149
150 /**
151 * This method returns a string that should be used as a caption for this
152 * column for user display purposes.
153 *
154 * @param columnIndex The index of the column to check.
155 * @return A display string for the column.
156 * @exception SQLException If an error occurs.
157 */
158 String getColumnLabel(int columnIndex) throws SQLException;
159
160 /**
161 * This method returns the name of the specified column.
162 *
163 * @param columnIndex The index of the column to return the name of.
164 * @return The name of the column.
165 * @exception SQLException If an error occurs.
166 */
167 String getColumnName(int columnIndex) throws SQLException;
168
169 /**
170 * This method returns the name of the schema that contains the specified
171 * column.
172 *
173 * @param columnIndex The index of the column to check the schema name for.
174 * @return The name of the schema that contains the column.
175 * @exception SQLException If an error occurs.
176 */
177 String getSchemaName(int columnIndex) throws SQLException;
178
179 /**
180 * This method returns the precision of the specified column, which is the
181 * number of decimal digits it contains.
182 *
183 * @param columnIndex The index of the column to check the precision on.
184 * @return The precision of the specified column.
185 * @exception SQLException If an error occurs.
186 */
187 int getPrecision(int columnIndex) throws SQLException;
188
189 /**
190 * This method returns the scale of the specified column, which is the
191 * number of digits to the right of the decimal point.
192 *
193 * @param columnIndex The index column to check the scale of.
194 * @return The scale of the column.
195 * @exception SQLException If an error occurs.
196 */
197 int getScale(int columnIndex) throws SQLException;
198
199 /**
200 * This method returns the name of the table containing the specified
201 * column.
202 *
203 * @param columnIndex The index of the column to check the table name for.
204 * @return The name of the table containing the column.
205 * @exception SQLException If an error occurs.
206 */
207 String getTableName(int columnIndex) throws SQLException;
208
209 /**
210 * This method returns the name of the catalog containing the specified
211 * column.
212 *
213 * @param columnIndex The index of the column to check the catalog name for.
214 * @return The name of the catalog containing the column.
215 * @exception SQLException If an error occurs.
216 */
217 String getCatalogName(int columnIndex) throws SQLException;
218
219 /**
220 * This method returns the SQL type of the specified column. This will
221 * be one of the constants from <code>Types</code>.
222 *
223 * @param columnIndex The index of the column to check the SQL type of.
224 * @return The SQL type for this column.
225 * @exception SQLException If an error occurs.
226 * @see Types
227 */
228 int getColumnType(int columnIndex) throws SQLException;
229
230 /**
231 * This method returns the name of the SQL type for this column.
232 *
233 * @param columnIndex The index of the column to check the SQL type name for.
234 * @return The name of the SQL type for this column.
235 * @exception SQLException If an error occurs.
236 */
237 String getColumnTypeName(int columnIndex) throws SQLException;
238
239 /**
240 * This method tests whether or not the specified column is read only.
241 *
242 * @param columnIndex The index of the column to check.
243 * @return <code>true</code> if the column is read only, <code>false</code>
244 * otherwise.
245 * @exception SQLException If an error occurs.
246 */
247 boolean isReadOnly(int columnIndex) throws SQLException;
248
249 /**
250 * This method tests whether or not the column may be writable. This
251 * does not guarantee that a write will be successful.
252 *
253 * @param columnIndex The index of the column to check for writability.
254 * @return <code>true</code> if the column may be writable,
255 * <code>false</code> otherwise.
256 * @exception SQLException If an error occurs.
257 */
258 boolean isWritable(int columnIndex) throws SQLException;
259
260 /**
261 * This method tests whether or not the column is writable. This
262 * does guarantee that a write will be successful.
263 *
264 * @param columnIndex The index of the column to check for writability.
265 * @return <code>true</code> if the column is writable,
266 * <code>false</code> otherwise.
267 * @exception SQLException If an error occurs.
268 */
269 boolean isDefinitelyWritable(int columnIndex) throws SQLException;
270
271 /**
272 * This method returns the name of the Java class which will be used to
273 * create objects representing the data in this column.
274 *
275 * @param columnIndex The index of the column to check.
276 * @return The name of the Java class that will be used for values in
277 * this column.
278 * @exception SQLException If an error occurs.
279 */
280 String getColumnClassName(int columnIndex) throws SQLException;
281 }