FSF GCC merge 02/23/03
[official-gcc.git] / libjava / java / sql / Statement.java
blobfd8a99950d2f5adbf7cdb03d981a05d3fe137779
1 /* Statement.java -- Interface for executing SQL statements.
2 Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package java.sql;
41 /**
42 * This interface provides a mechanism for executing SQL statements.
44 * @author Aaron M. Renn (arenn@urbanophile.com)
46 public interface Statement
48 public static final int CLOSE_CURRENT_RESULT = 1;
49 public static final int KEEP_CURRENT_RESULT = 2;
50 public static final int CLOSE_ALL_RESULTS = 3;
51 public static final int SUCCESS_NO_INFO = -2;
52 public static final int EXECUTE_FAILED = -3;
53 public static final int RETURN_GENERATED_KEYS = 1;
54 public static final int NO_GENERATED_KEYS = 2;
56 /**
57 * This method executes the specified SQL SELECT statement and returns a
58 * (possibly empty) <code>ResultSet</code> with the results of the query.
60 * @param sql The SQL statement to execute.
61 * @return The result set of the SQL statement.
62 * @exception SQLException If an error occurs.
64 public ResultSet executeQuery(String sql) throws SQLException;
66 /**
67 * This method executes the specified SQL INSERT, UPDATE, or DELETE statement
68 * and returns the number of rows affected, which may be 0.
70 * @param sql The SQL statement to execute.
71 * @return The number of rows affected by the SQL statement.
72 * @exception SQLException If an error occurs.
74 public int executeUpdate(String sql) throws SQLException;
76 /**
77 * This method closes the statement and frees any associated resources.
79 * @exception SQLException If an error occurs.
81 public void close() throws SQLException;
83 /**
84 * This method returns the maximum length of any column value in bytes.
86 * @return The maximum length of any column value in bytes.
87 * @exception SQLException If an error occurs.
89 public int getMaxFieldSize() throws SQLException;
91 /**
92 * This method sets the limit for the maximum length of any column in bytes.
94 * @param maxsize The new maximum length of any column in bytes.
95 * @exception SQLException If an error occurs.
97 public void setMaxFieldSize(int max) throws SQLException;
99 /**
100 * This method returns the maximum possible number of rows in a result set.
102 * @return The maximum possible number of rows in a result set.
103 * @exception SQLException If an error occurs.
105 public int getMaxRows() throws SQLException;
108 * This method sets the maximum number of rows that can be present in a
109 * result set.
111 * @param maxrows The maximum possible number of rows in a result set.
112 * @exception SQLException If an error occurs.
114 public void setMaxRows(int max) throws SQLException;
117 * This method sets the local escape processing mode on or off. The
118 * default value is on.
120 * @param escape <code>true</code> to enable local escape processing,
121 * <code>false</code> to disable it.
122 * @exception SQLException If an error occurs.
124 public void setEscapeProcessing(boolean enable) throws SQLException;
127 * The method returns the number of seconds a statement may be in process
128 * before timing out. A value of 0 means there is no timeout.
130 * @return The SQL statement timeout in seconds.
131 * @exception SQLException If an error occurs.
133 public int getQueryTimeout() throws SQLException;
136 * This method sets the number of seconds a statement may be in process
137 * before timing out. A value of 0 means there is no timeout.
139 * @param timeout The new SQL statement timeout value.
140 * @exception SQLException If an error occurs.
142 public void setQueryTimeout(int seconds) throws SQLException;
145 * This method cancels an outstanding statement, if the database supports
146 * that operation.
148 * @exception SQLException If an error occurs.
150 public void cancel() throws SQLException;
153 * This method returns the first SQL warning attached to this statement.
154 * Subsequent warnings will be chained to this one.
156 * @return The first SQL warning for this statement.
157 * @exception SQLException If an error occurs.
159 public SQLWarning getWarnings() throws SQLException;
162 * This method clears any SQL warnings that have been attached to this
163 * statement.
165 * @exception SQLException If an error occurs.
167 public void clearWarnings() throws SQLException;
170 * This method sets the cursor name that will be used by the result set.
172 * @param name The cursor name to use for this statement.
173 * @exception SQLException If an error occurs.
175 public void setCursorName(String name) throws SQLException;
178 * This method executes an arbitrary SQL statement of any time. The
179 * methods <code>getResultSet</code>, <code>getMoreResults</code> and
180 * <code>getUpdateCount</code> retrieve the results.
182 * @return <code>true</code> if a result set was returned, <code>false</code>
183 * if an update count was returned.
184 * @exception SQLException If an error occurs.
186 public boolean execute(String sql) throws SQLException;
189 * This method returns the result set of the SQL statement that was
190 * executed. This should be called only once per result set returned.
192 * @return The result set of the query, or <code>null</code> if there was
193 * no result set (for example, if the statement was an UPDATE).
194 * @exception SQLException If an error occurs.
195 * @see execute
197 public ResultSet getResultSet() throws SQLException;
200 * This method returns the update count of the SQL statement that was
201 * executed. This should be called only once per executed SQL statement.
203 * @return The update count of the query, or -1 if there was no update
204 * count (for example, if the statement was a SELECT).
205 * @exception SQLException If an error occurs.
206 * @see execute
208 public int getUpdateCount() throws SQLException;
211 * This method advances the result set pointer to the next result set,
212 * which can then be retrieved using <code>getResultSet</code>
214 * @return <code>true</code> if there is another result set,
215 * <code>false</code> otherwise (for example, the next result is an
216 * update count).
217 * @exception SQLException If an error occurs.
218 * @see execute
220 public boolean getMoreResults() throws SQLException;
223 * This method informs the driver which direction the result set will
224 * be accessed in.
226 * @param direction The direction the result set will be accessed in (?????)
227 * @exception SQLException If an error occurs.
229 public void setFetchDirection(int direction) throws SQLException;
232 * This method returns the current direction that the driver thinks the
233 * result set will be accessed int.
235 * @return The direction the result set will be accessed in (????)
236 * @exception SQLException If an error occurs.
238 public int getFetchDirection() throws SQLException;
241 * This method informs the driver how many rows it should fetch from the
242 * database at a time.
244 * @param numrows The number of rows the driver should fetch at a time
245 * to populate the result set.
246 * @exception SQLException If an error occurs.
248 public void setFetchSize(int rows) throws SQLException;
251 * This method returns the number of rows the driver believes should be
252 * fetched from the database at a time.
254 * @return The number of rows that will be fetched from the database at a time.
255 * @exception SQLException If an error occurs.
257 public int getFetchSize() throws SQLException;
260 * This method returns the concurrency type of the result set for this
261 * statement. This will be one of the concurrency types defined in
262 * <code>ResultSet</code>.
264 * @return The concurrency type of the result set for this statement.
265 * @exception SQLException If an error occurs.
266 * @see ResultSet
268 public int getResultSetConcurrency() throws SQLException;
271 * This method returns the result set type for this statement. This will
272 * be one of the result set types defined in <code>ResultSet</code>.
274 * @return The result set type for this statement.
275 * @exception SQLException If an error occurs.
276 * @see ResultSet
278 public int getResultSetType() throws SQLException;
281 * This method adds a SQL statement to a SQL batch. A driver is not
282 * required to implement this method.
284 * @param sql The sql statement to add to the batch.
285 * @exception SQLException If an error occurs.
287 public void addBatch(String sql) throws SQLException;
290 * This method clears out any SQL statements that have been populated in
291 * the current batch. A driver is not required to implement this method.
293 * @exception SQLException If an error occurs.
295 public void clearBatch() throws SQLException;
298 * This method executes the SQL batch and returns an array of update
299 * counts - one for each SQL statement in the batch - ordered in the same
300 * order the statements were added to the batch. A driver is not required
301 * to implement this method.
303 * @return An array of update counts for this batch.
304 * @exception SQLException If an error occurs.
306 public int[] executeBatch() throws SQLException;
309 * This method returns the <code>Connection</code> instance that was
310 * used to create this object.
312 * @return The connection used to create this object.
313 * @exception SQLException If an error occurs.
315 public Connection getConnection() throws SQLException;
318 * @since 1.4
320 public boolean getMoreResults(int current) throws SQLException;
323 * @since 1.4
325 public ResultSet getGeneratedKeys() throws SQLException;
328 * @since 1.4
330 public int executeUpdate(String sql, int autoGeneratedKeys)
331 throws SQLException;
334 * @since 1.4
336 public int executeUpdate(String sql, int[] columnIndexes)
337 throws SQLException;
340 * @since 1.4
342 public int executeUpdate(String sql, String[] columnNames)
343 throws SQLException;
346 * @since 1.4
348 public boolean execute(String sql, int autoGeneratedKeys)
349 throws SQLException;
352 * @since 1.4
354 public boolean execute(String sql, int[] columnIndexes) throws SQLException;
357 * @since 1.4
359 public boolean execute(String sql, String[] columnNames)
360 throws SQLException;
363 * @since 1.4
365 public int getResultSetHoldability() throws SQLException;