source: trunk/src/gcc/libjava/java/sql/PreparedStatement.java@ 1213

Last change on this file since 1213 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 17.7 KB
Line 
1/* PreparedStatement.java -- Interface for pre-compiled statements.
2 Copyright (C) 1999, 2000 Free Software Foundation, Inc.
3
4This file is part of GNU Classpath.
5
6GNU Classpath is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Classpath is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Classpath; see the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1902111-1307 USA.
20
21Linking this library statically or dynamically with other modules is
22making a combined work based on this library. Thus, the terms and
23conditions of the GNU General Public License cover the whole
24combination.
25
26As a special exception, the copyright holders of this library give you
27permission to link this library with independent modules to produce an
28executable, regardless of the license terms of these independent
29modules, and to copy and distribute the resulting executable under
30terms of your choice, provided that you also meet, for each linked
31independent module, the terms and conditions of the license of that
32module. An independent module is a module which is not derived from
33or based on this library. If you modify this library, you may extend
34this exception to your version of the library, but you are not
35obligated to do so. If you do not wish to do so, delete this
36exception statement from your version. */
37
38
39package java.sql;
40
41import java.io.InputStream;
42import java.io.Reader;
43import java.math.BigDecimal;
44import java.util.Calendar;
45
46/**
47 * This interface provides a mechanism for executing pre-compiled
48 * statements. This provides greater efficiency when calling the same
49 * statement multiple times. Parameters are allowed in a statement,
50 * providings for maximum reusability.
51 *
52 * @author Aaron M. Renn ([email protected])
53 */
54public interface PreparedStatement extends Statement
55{
56
57/**
58 * This method populates the specified parameter with a SQL NULL value
59 * for the specified type.
60 *
61 * @param index The index of the parameter to set.
62 * @param type The SQL type identifier of the parameter from <code>Types</code>
63 *
64 * @exception SQLException If an error occurs.
65 */
66public abstract void
67setNull(int index, int type) throws SQLException;
68
69/*************************************************************************/
70
71/**
72 * This method populates the specified parameter with a SQL NULL value
73 * for the specified type.
74 *
75 * @param index The index of the parameter to set.
76 * @param type The SQL type identifier of the parameter from <code>Types</code>
77 * @param name The name of the data type, for user defined types.
78 *
79 * @exception SQLException If an error occurs.
80 */
81public abstract void
82setNull(int index, int type, String name) throws SQLException;
83
84/*************************************************************************/
85
86/**
87 * This method sets the specified parameter from the given Java
88 * <code>boolean</code> value.
89 *
90 * @param index The index of the parameter value to set.
91 * @param value The value of the parameter.
92 *
93 * @exception SQLException If an error occurs.
94 */
95public abstract void
96setBoolean(int index, boolean value) throws SQLException;
97
98/*************************************************************************/
99
100/**
101 * This method sets the specified parameter from the given Java
102 * <code>byte</code> value.
103 *
104 * @param index The index of the parameter value to set.
105 * @param value The value of the parameter.
106 *
107 * @exception SQLException If an error occurs.
108 */
109public abstract void
110setByte(int index, byte value) throws SQLException;
111
112/*************************************************************************/
113
114/**
115 * This method sets the specified parameter from the given Java
116 * <code>short</code> value.
117 *
118 * @param index The index of the parameter value to set.
119 * @param value The value of the parameter.
120 *
121 * @exception SQLException If an error occurs.
122 */
123public abstract void
124setShort(int index, short value) throws SQLException;
125
126/*************************************************************************/
127
128/**
129 * This method sets the specified parameter from the given Java
130 * <code>int</code> value.
131 *
132 * @param index The index of the parameter value to set.
133 * @param value The value of the parameter.
134 *
135 * @exception SQLException If an error occurs.
136 */
137public abstract void
138setInt(int index, int value) throws SQLException;
139
140/*************************************************************************/
141
142/**
143 * This method sets the specified parameter from the given Java
144 * <code>long</code> value.
145 *
146 * @param index The index of the parameter value to set.
147 * @param value The value of the parameter.
148 *
149 * @exception SQLException If an error occurs.
150 */
151public abstract void
152setLong(int index, long value) throws SQLException;
153
154/*************************************************************************/
155
156/**
157 * This method sets the specified parameter from the given Java
158 * <code>float</code> value.
159 *
160 * @param index The index of the parameter value to set.
161 * @param value The value of the parameter.
162 *
163 * @exception SQLException If an error occurs.
164 */
165public abstract void
166setFloat(int index, float value) throws SQLException;
167
168/*************************************************************************/
169
170/**
171 * This method sets the specified parameter from the given Java
172 * <code>double</code> value.
173 *
174 * @param index The index of the parameter value to set.
175 * @param value The value of the parameter.
176 *
177 * @exception SQLException If an error occurs.
178 */
179public abstract void
180setDouble(int index, double value) throws SQLException;
181
182/*************************************************************************/
183
184/**
185 * This method sets the specified parameter from the given Java
186 * <code>String</code> value.
187 *
188 * @param index The index of the parameter value to set.
189 * @param value The value of the parameter.
190 *
191 * @exception SQLException If an error occurs.
192 */
193public abstract void
194setString(int index, String value) throws SQLException;
195
196/*************************************************************************/
197
198/**
199 * This method sets the specified parameter from the given Java
200 * <code>byte</code> array value.
201 *
202 * @param index The index of the parameter value to set.
203 * @param value The value of the parameter.
204 *
205 * @exception SQLException If an error occurs.
206 */
207public abstract void
208setBytes(int index, byte[] value) throws SQLException;
209
210/*************************************************************************/
211
212/**
213 * This method sets the specified parameter from the given Java
214 * <code>java.math.BigDecimal</code> value.
215 *
216 * @param index The index of the parameter value to set.
217 * @param value The value of the parameter.
218 *
219 * @exception SQLException If an error occurs.
220 */
221public abstract void
222setBigDecimal(int index, java.math.BigDecimal value) throws SQLException;
223
224/*************************************************************************/
225
226/**
227 * This method sets the specified parameter from the given Java
228 * <code>java.sql.Date</code> value.
229 *
230 * @param index The index of the parameter value to set.
231 * @param value The value of the parameter.
232 *
233 * @exception SQLException If an error occurs.
234 */
235public abstract void
236setDate(int index, java.sql.Date value) throws SQLException;
237
238/*************************************************************************/
239
240/**
241 * This method sets the specified parameter from the given Java
242 * <code>java.sql.Date</code> value.
243 *
244 * @param index The index of the parameter value to set.
245 * @param value The value of the parameter.
246 * @param calendar The <code>Calendar</code> to use for timezone and locale.
247 *
248 * @exception SQLException If an error occurs.
249 */
250public abstract void
251setDate(int index, java.sql.Date value, Calendar calendar) throws SQLException;
252
253/*************************************************************************/
254
255/**
256 * This method sets the specified parameter from the given Java
257 * <code>java.sql.Time</code> value.
258 *
259 * @param index The index of the parameter value to set.
260 * @param value The value of the parameter.
261 *
262 * @exception SQLException If an error occurs.
263 */
264public abstract void
265setTime(int index, java.sql.Time value) throws SQLException;
266
267/*************************************************************************/
268
269/**
270 * This method sets the specified parameter from the given Java
271 * <code>java.sql.Time</code> value.
272 *
273 * @param index The index of the parameter value to set.
274 * @param value The value of the parameter.
275 * @param calendar The <code>Calendar</code> to use for timezone and locale.
276 *
277 * @exception SQLException If an error occurs.
278 */
279public abstract void
280setTime(int index, java.sql.Time value, Calendar calendar) throws SQLException;
281
282/*************************************************************************/
283
284/**
285 * This method sets the specified parameter from the given Java
286 * <code>java.sql.Timestamp</code> value.
287 *
288 * @param index The index of the parameter value to set.
289 * @param value The value of the parameter.
290 *
291 * @exception SQLException If an error occurs.
292 */
293public abstract void
294setTimestamp(int index, java.sql.Timestamp value) throws SQLException;
295
296/*************************************************************************/
297
298/**
299 * This method sets the specified parameter from the given Java
300 * <code>java.sql.Timestamp</code> value.
301 *
302 * @param index The index of the parameter value to set.
303 * @param value The value of the parameter.
304 * @param calendar The <code>Calendar</code> to use for timezone and locale.
305 *
306 * @exception SQLException If an error occurs.
307 */
308public abstract void
309setTimestamp(int index, java.sql.Timestamp value, Calendar calendar)
310 throws SQLException;
311
312/*************************************************************************/
313
314/**
315 * This method sets the specified parameter from the given Java
316 * ASCII <code>InputStream</code> value.
317 *
318 * @param index The index of the parameter value to set.
319 * @param value The value of the parameter.
320 * @param length The number of bytes in the stream.
321 *
322 * @exception SQLException If an error occurs.
323 */
324public abstract void
325setAsciiStream(int index, InputStream value, int length) throws SQLException;
326
327/*************************************************************************/
328
329/**
330 * This method sets the specified parameter from the given Java
331 * Unicode UTF-8 <code>InputStream</code> value.
332 *
333 * @param index The index of the parameter value to set.
334 * @param value The value of the parameter.
335 * @param length The number of bytes in the stream.
336 *
337 * @exception SQLException If an error occurs.
338 */
339public abstract void
340setUnicodeStream(int index, InputStream value, int length) throws SQLException;
341
342/*************************************************************************/
343
344/**
345 * This method sets the specified parameter from the given Java
346 * binary <code>InputStream</code> value.
347 *
348 * @param index The index of the parameter value to set.
349 * @param value The value of the parameter.
350 * @param length The number of bytes in the stream.
351 *
352 * @exception SQLException If an error occurs.
353 */
354public abstract void
355setBinaryStream(int index, InputStream value, int length) throws SQLException;
356
357/*************************************************************************/
358
359/**
360 * This method sets the specified parameter from the given Java
361 * character <code>Reader</code> value.
362 *
363 * @param index The index of the parameter value to set.
364 * @param value The value of the parameter.
365 * @param length The number of bytes in the stream.
366 *
367 * @exception SQLException If an error occurs.
368 */
369public abstract void
370setCharacterStream(int index, Reader value, int length) throws SQLException;
371
372/*************************************************************************/
373
374/**
375 * This method sets the specified parameter from the given Java
376 * <code>Ref</code> value. The default object type to SQL type mapping
377 * will be used.
378 *
379 * @param index The index of the parameter value to set.
380 * @param value The value of the parameter.
381 *
382 * @exception SQLException If an error occurs.
383 */
384public abstract void
385setRef(int index, Ref value) throws SQLException;
386
387/*************************************************************************/
388
389/**
390 * This method sets the specified parameter from the given Java
391 * <code>Blob</code> value. The default object type to SQL type mapping
392 * will be used.
393 *
394 * @param index The index of the parameter value to set.
395 * @param value The value of the parameter.
396 *
397 * @exception SQLException If an error occurs.
398 */
399public abstract void
400setBlob(int index, Blob value) throws SQLException;
401
402/*************************************************************************/
403
404/**
405 * This method sets the specified parameter from the given Java
406 * <code>Clob</code> value. The default object type to SQL type mapping
407 * will be used.
408 *
409 * @param index The index of the parameter value to set.
410 * @param value The value of the parameter.
411 *
412 * @exception SQLException If an error occurs.
413 */
414public abstract void
415setClob(int index, Clob value) throws SQLException;
416
417/*************************************************************************/
418
419/**
420 * This method sets the specified parameter from the given Java
421 * <code>Array</code> value. The default object type to SQL type mapping
422 * will be used.
423 *
424 * @param index The index of the parameter value to set.
425 * @param value The value of the parameter.
426 *
427 * @exception SQLException If an error occurs.
428 */
429public abstract void
430setArray(int index, Array value) throws SQLException;
431
432/*************************************************************************/
433
434/**
435 * This method sets the specified parameter from the given Java
436 * <code>Object</code> value. The default object type to SQL type mapping
437 * will be used.
438 *
439 * @param index The index of the parameter value to set.
440 * @param value The value of the parameter.
441 *
442 * @exception SQLException If an error occurs.
443 */
444public abstract void
445setObject(int index, Object value) throws SQLException;
446
447/*************************************************************************/
448
449/**
450 * This method sets the specified parameter from the given Java
451 * <code>Object</code> value. The specified SQL object type will be used.
452 *
453 * @param index The index of the parameter value to set.
454 * @param value The value of the parameter.
455 * @param type The SQL type to use for the parameter, from <code>Types</code>
456 *
457 * @exception SQLException If an error occurs.
458 *
459 * @see Types
460 */
461public abstract void
462setObject(int index, Object value, int type) throws SQLException;
463
464/*************************************************************************/
465
466/**
467 * This method sets the specified parameter from the given Java
468 * <code>Object</code> value. The specified SQL object type will be used.
469 *
470 * @param index The index of the parameter value to set.
471 * @param value The value of the parameter.
472 * @param type The SQL type to use for the parameter, from <code>Types</code>
473 * @param scale The scale of the value, for numeric values only.
474 *
475 * @exception SQLException If an error occurs.
476 *
477 * @see Types
478 */
479public abstract void
480setObject(int index, Object value, int type, int scale) throws SQLException;
481
482/*************************************************************************/
483
484/**
485 * This method adds a set of parameters to the batch for JDBC 2.0.
486 *
487 * @exception SQLException If an error occurs.
488 */
489public abstract void
490addBatch() throws SQLException;
491
492/*************************************************************************/
493
494/**
495 * This method clears all of the input parameter that have been
496 * set on this statement.
497 *
498 * @exception SQLException If an error occurs.
499 */
500public abstract void
501clearParameters() throws SQLException;
502
503/*************************************************************************/
504
505/**
506 * This method returns meta data for the result set from this statement.
507 *
508 * @return Meta data for the result set from this statement.
509 *
510 * @exception SQLException If an error occurs.
511 */
512public abstract ResultSetMetaData
513getMetaData() throws SQLException;
514
515/*************************************************************************/
516
517/**
518 * This method executes a prepared SQL query.
519 * Some prepared statements return multiple results; the execute method
520 * handles these complex statements as well as the simpler form of
521 * statements handled by executeQuery and executeUpdate.
522 *
523 * @return The result of the SQL statement.
524 *
525 * @exception SQLException If an error occurs.
526 */
527public abstract boolean
528execute() throws SQLException;
529
530/*************************************************************************/
531
532/**
533 * This method executes a prepared SQL query and returns its ResultSet.
534 *
535 * @return The ResultSet of the SQL statement.
536 *
537 * @exception SQLException If an error occurs.
538 */
539public abstract ResultSet
540executeQuery() throws SQLException;
541
542/*************************************************************************/
543
544/**
545 * This method executes an SQL INSERT, UPDATE or DELETE statement. SQL
546 * statements that return nothing such as SQL DDL statements can be executed.
547 *
548 * @return The result is either the row count for INSERT, UPDATE or DELETE
549 * statements; or 0 for SQL statements that return nothing.
550 *
551 * @exception SQLException If an error occurs.
552 */
553public abstract int
554executeUpdate() throws SQLException;
555
556} // interface PreparedStatement
557
Note: See TracBrowser for help on using the repository browser.