author | alanb |
Fri, 02 Nov 2012 15:50:11 +0000 | |
changeset 14342 | 8435a30053c1 |
parent 14171 | 94eb36844bd7 |
child 15278 | e081d3f73b75 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
14171
diff
changeset
|
2 |
* Copyright (c) 1996, 2012, 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 |
import java.math.BigDecimal; |
|
29 |
import java.util.Calendar; |
|
30 |
import java.io.Reader; |
|
31 |
import java.io.InputStream; |
|
32 |
||
33 |
/** |
|
34 |
* An object that represents a precompiled SQL statement. |
|
35 |
* <P>A SQL statement is precompiled and stored in a |
|
36 |
* <code>PreparedStatement</code> object. This object can then be used to |
|
37 |
* efficiently execute this statement multiple times. |
|
38 |
* |
|
39 |
* <P><B>Note:</B> The setter methods (<code>setShort</code>, <code>setString</code>, |
|
40 |
* and so on) for setting IN parameter values |
|
41 |
* must specify types that are compatible with the defined SQL type of |
|
42 |
* the input parameter. For instance, if the IN parameter has SQL type |
|
43 |
* <code>INTEGER</code>, then the method <code>setInt</code> should be used. |
|
44 |
* |
|
45 |
* <p>If arbitrary parameter type conversions are required, the method |
|
46 |
* <code>setObject</code> should be used with a target SQL type. |
|
47 |
* <P> |
|
48 |
* In the following example of setting a parameter, <code>con</code> represents |
|
49 |
* an active connection: |
|
50 |
* <PRE> |
|
51 |
* PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES |
|
52 |
* SET SALARY = ? WHERE ID = ?"); |
|
53 |
* pstmt.setBigDecimal(1, 153833.00) |
|
54 |
* pstmt.setInt(2, 110592) |
|
55 |
* </PRE> |
|
56 |
* |
|
57 |
* @see Connection#prepareStatement |
|
58 |
* @see ResultSet |
|
59 |
*/ |
|
60 |
||
61 |
public interface PreparedStatement extends Statement { |
|
62 |
||
63 |
/** |
|
64 |
* Executes the SQL query in this <code>PreparedStatement</code> object |
|
65 |
* and returns the <code>ResultSet</code> object generated by the query. |
|
66 |
* |
|
67 |
* @return a <code>ResultSet</code> object that contains the data produced by the |
|
68 |
* query; never <code>null</code> |
|
69 |
* @exception SQLException if a database access error occurs; |
|
70 |
* this method is called on a closed <code>PreparedStatement</code> or the SQL |
|
71 |
* statement does not return a <code>ResultSet</code> object |
|
6540 | 72 |
* @throws SQLTimeoutException when the driver has determined that the |
73 |
* timeout value that was specified by the {@code setQueryTimeout} |
|
74 |
* method has been exceeded and has at least attempted to cancel |
|
75 |
* the currently running {@code Statement} |
|
2 | 76 |
*/ |
77 |
ResultSet executeQuery() throws SQLException; |
|
78 |
||
79 |
/** |
|
80 |
* Executes the SQL statement in this <code>PreparedStatement</code> object, |
|
81 |
* which must be an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or |
|
82 |
* <code>DELETE</code>; or an SQL statement that returns nothing, |
|
83 |
* such as a DDL statement. |
|
84 |
* |
|
85 |
* @return either (1) the row count for SQL Data Manipulation Language (DML) statements |
|
86 |
* or (2) 0 for SQL statements that return nothing |
|
87 |
* @exception SQLException if a database access error occurs; |
|
88 |
* this method is called on a closed <code>PreparedStatement</code> |
|
6540 | 89 |
* or the SQL statement returns a <code>ResultSet</code> object |
90 |
* @throws SQLTimeoutException when the driver has determined that the |
|
91 |
* timeout value that was specified by the {@code setQueryTimeout} |
|
92 |
* method has been exceeded and has at least attempted to cancel |
|
93 |
* the currently running {@code Statement} |
|
2 | 94 |
*/ |
95 |
int executeUpdate() throws SQLException; |
|
96 |
||
97 |
/** |
|
98 |
* Sets the designated parameter to SQL <code>NULL</code>. |
|
99 |
* |
|
100 |
* <P><B>Note:</B> You must specify the parameter's SQL type. |
|
101 |
* |
|
102 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
103 |
* @param sqlType the SQL type code defined in <code>java.sql.Types</code> |
|
104 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
105 |
* marker in the SQL statement; if a database access error occurs or |
|
106 |
* this method is called on a closed <code>PreparedStatement</code> |
|
107 |
* @exception SQLFeatureNotSupportedException if <code>sqlType</code> is |
|
108 |
* a <code>ARRAY</code>, <code>BLOB</code>, <code>CLOB</code>, |
|
109 |
* <code>DATALINK</code>, <code>JAVA_OBJECT</code>, <code>NCHAR</code>, |
|
110 |
* <code>NCLOB</code>, <code>NVARCHAR</code>, <code>LONGNVARCHAR</code>, |
|
111 |
* <code>REF</code>, <code>ROWID</code>, <code>SQLXML</code> |
|
112 |
* or <code>STRUCT</code> data type and the JDBC driver does not support |
|
113 |
* this data type |
|
114 |
*/ |
|
115 |
void setNull(int parameterIndex, int sqlType) throws SQLException; |
|
116 |
||
117 |
/** |
|
118 |
* Sets the designated parameter to the given Java <code>boolean</code> value. |
|
119 |
* The driver converts this |
|
120 |
* to an SQL <code>BIT</code> or <code>BOOLEAN</code> value when it sends it to the database. |
|
121 |
* |
|
122 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
123 |
* @param x the parameter value |
|
124 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
125 |
* marker in the SQL statement; |
|
126 |
* if a database access error occurs or |
|
127 |
* this method is called on a closed <code>PreparedStatement</code> |
|
128 |
*/ |
|
129 |
void setBoolean(int parameterIndex, boolean x) throws SQLException; |
|
130 |
||
131 |
/** |
|
132 |
* Sets the designated parameter to the given Java <code>byte</code> value. |
|
133 |
* The driver converts this |
|
134 |
* to an SQL <code>TINYINT</code> value when it sends it to the database. |
|
135 |
* |
|
136 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
137 |
* @param x the parameter value |
|
138 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
139 |
* marker in the SQL statement; if a database access error occurs or |
|
140 |
* this method is called on a closed <code>PreparedStatement</code> |
|
141 |
*/ |
|
142 |
void setByte(int parameterIndex, byte x) throws SQLException; |
|
143 |
||
144 |
/** |
|
145 |
* Sets the designated parameter to the given Java <code>short</code> value. |
|
146 |
* The driver converts this |
|
147 |
* to an SQL <code>SMALLINT</code> value when it sends it to the database. |
|
148 |
* |
|
149 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
150 |
* @param x the parameter value |
|
151 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
152 |
* marker in the SQL statement; if a database access error occurs or |
|
153 |
* this method is called on a closed <code>PreparedStatement</code> |
|
154 |
*/ |
|
155 |
void setShort(int parameterIndex, short x) throws SQLException; |
|
156 |
||
157 |
/** |
|
158 |
* Sets the designated parameter to the given Java <code>int</code> value. |
|
159 |
* The driver converts this |
|
160 |
* to an SQL <code>INTEGER</code> value when it sends it to the database. |
|
161 |
* |
|
162 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
163 |
* @param x the parameter value |
|
164 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
165 |
* marker in the SQL statement; if a database access error occurs or |
|
166 |
* this method is called on a closed <code>PreparedStatement</code> |
|
167 |
*/ |
|
168 |
void setInt(int parameterIndex, int x) throws SQLException; |
|
169 |
||
170 |
/** |
|
171 |
* Sets the designated parameter to the given Java <code>long</code> value. |
|
172 |
* The driver converts this |
|
173 |
* to an SQL <code>BIGINT</code> value when it sends it to the database. |
|
174 |
* |
|
175 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
176 |
* @param x the parameter value |
|
177 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
178 |
* marker in the SQL statement; if a database access error occurs or |
|
179 |
* this method is called on a closed <code>PreparedStatement</code> |
|
180 |
*/ |
|
181 |
void setLong(int parameterIndex, long x) throws SQLException; |
|
182 |
||
183 |
/** |
|
184 |
* Sets the designated parameter to the given Java <code>float</code> value. |
|
185 |
* The driver converts this |
|
186 |
* to an SQL <code>REAL</code> value when it sends it to the database. |
|
187 |
* |
|
188 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
189 |
* @param x the parameter value |
|
190 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
191 |
* marker in the SQL statement; if a database access error occurs or |
|
192 |
* this method is called on a closed <code>PreparedStatement</code> |
|
193 |
*/ |
|
194 |
void setFloat(int parameterIndex, float x) throws SQLException; |
|
195 |
||
196 |
/** |
|
197 |
* Sets the designated parameter to the given Java <code>double</code> value. |
|
198 |
* The driver converts this |
|
199 |
* to an SQL <code>DOUBLE</code> value when it sends it to the database. |
|
200 |
* |
|
201 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
202 |
* @param x the parameter value |
|
203 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
204 |
* marker in the SQL statement; if a database access error occurs or |
|
205 |
* this method is called on a closed <code>PreparedStatement</code> |
|
206 |
*/ |
|
207 |
void setDouble(int parameterIndex, double x) throws SQLException; |
|
208 |
||
209 |
/** |
|
210 |
* Sets the designated parameter to the given <code>java.math.BigDecimal</code> value. |
|
211 |
* The driver converts this to an SQL <code>NUMERIC</code> value when |
|
212 |
* it sends it to the database. |
|
213 |
* |
|
214 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
215 |
* @param x the parameter value |
|
216 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
217 |
* marker in the SQL statement; if a database access error occurs or |
|
218 |
* this method is called on a closed <code>PreparedStatement</code> |
|
219 |
*/ |
|
220 |
void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException; |
|
221 |
||
222 |
/** |
|
223 |
* Sets the designated parameter to the given Java <code>String</code> value. |
|
224 |
* The driver converts this |
|
225 |
* to an SQL <code>VARCHAR</code> or <code>LONGVARCHAR</code> value |
|
226 |
* (depending on the argument's |
|
227 |
* size relative to the driver's limits on <code>VARCHAR</code> values) |
|
228 |
* when it sends it to the database. |
|
229 |
* |
|
230 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
231 |
* @param x the parameter value |
|
232 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
233 |
* marker in the SQL statement; if a database access error occurs or |
|
234 |
* this method is called on a closed <code>PreparedStatement</code> |
|
235 |
*/ |
|
236 |
void setString(int parameterIndex, String x) throws SQLException; |
|
237 |
||
238 |
/** |
|
239 |
* Sets the designated parameter to the given Java array of bytes. The driver converts |
|
240 |
* this to an SQL <code>VARBINARY</code> or <code>LONGVARBINARY</code> |
|
241 |
* (depending on the argument's size relative to the driver's limits on |
|
242 |
* <code>VARBINARY</code> values) when it sends it to the database. |
|
243 |
* |
|
244 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
245 |
* @param x the parameter value |
|
246 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
247 |
* marker in the SQL statement; if a database access error occurs or |
|
248 |
* this method is called on a closed <code>PreparedStatement</code> |
|
249 |
*/ |
|
250 |
void setBytes(int parameterIndex, byte x[]) throws SQLException; |
|
251 |
||
252 |
/** |
|
253 |
* Sets the designated parameter to the given <code>java.sql.Date</code> value |
|
254 |
* using the default time zone of the virtual machine that is running |
|
255 |
* the application. |
|
256 |
* The driver converts this |
|
257 |
* to an SQL <code>DATE</code> value when it sends it to the database. |
|
258 |
* |
|
259 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
260 |
* @param x the parameter value |
|
261 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
262 |
* marker in the SQL statement; if a database access error occurs or |
|
263 |
* this method is called on a closed <code>PreparedStatement</code> |
|
264 |
*/ |
|
265 |
void setDate(int parameterIndex, java.sql.Date x) |
|
266 |
throws SQLException; |
|
267 |
||
268 |
/** |
|
269 |
* Sets the designated parameter to the given <code>java.sql.Time</code> value. |
|
270 |
* The driver converts this |
|
271 |
* to an SQL <code>TIME</code> value when it sends it to the database. |
|
272 |
* |
|
273 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
274 |
* @param x the parameter value |
|
275 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
276 |
* marker in the SQL statement; if a database access error occurs or |
|
277 |
* this method is called on a closed <code>PreparedStatement</code> |
|
278 |
*/ |
|
279 |
void setTime(int parameterIndex, java.sql.Time x) |
|
280 |
throws SQLException; |
|
281 |
||
282 |
/** |
|
283 |
* Sets the designated parameter to the given <code>java.sql.Timestamp</code> value. |
|
284 |
* The driver |
|
285 |
* converts this to an SQL <code>TIMESTAMP</code> value when it sends it to the |
|
286 |
* database. |
|
287 |
* |
|
288 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
289 |
* @param x the parameter value |
|
290 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
291 |
* marker in the SQL statement; if a database access error occurs or |
|
292 |
* this method is called on a closed <code>PreparedStatement</code> */ |
|
293 |
void setTimestamp(int parameterIndex, java.sql.Timestamp x) |
|
294 |
throws SQLException; |
|
295 |
||
296 |
/** |
|
297 |
* Sets the designated parameter to the given input stream, which will have |
|
298 |
* the specified number of bytes. |
|
299 |
* When a very large ASCII value is input to a <code>LONGVARCHAR</code> |
|
300 |
* parameter, it may be more practical to send it via a |
|
301 |
* <code>java.io.InputStream</code>. Data will be read from the stream |
|
302 |
* as needed until end-of-file is reached. The JDBC driver will |
|
303 |
* do any necessary conversion from ASCII to the database char format. |
|
304 |
* |
|
305 |
* <P><B>Note:</B> This stream object can either be a standard |
|
306 |
* Java stream object or your own subclass that implements the |
|
307 |
* standard interface. |
|
308 |
* |
|
309 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
310 |
* @param x the Java input stream that contains the ASCII parameter value |
|
311 |
* @param length the number of bytes in the stream |
|
312 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
313 |
* marker in the SQL statement; if a database access error occurs or |
|
314 |
* this method is called on a closed <code>PreparedStatement</code> |
|
315 |
*/ |
|
316 |
void setAsciiStream(int parameterIndex, java.io.InputStream x, int length) |
|
317 |
throws SQLException; |
|
318 |
||
319 |
/** |
|
320 |
* Sets the designated parameter to the given input stream, which |
|
321 |
* will have the specified number of bytes. |
|
322 |
* |
|
323 |
* When a very large Unicode value is input to a <code>LONGVARCHAR</code> |
|
324 |
* parameter, it may be more practical to send it via a |
|
325 |
* <code>java.io.InputStream</code> object. The data will be read from the |
|
326 |
* stream as needed until end-of-file is reached. The JDBC driver will |
|
327 |
* do any necessary conversion from Unicode to the database char format. |
|
328 |
* |
|
329 |
*The byte format of the Unicode stream must be a Java UTF-8, as defined in the |
|
330 |
*Java Virtual Machine Specification. |
|
331 |
* |
|
332 |
* <P><B>Note:</B> This stream object can either be a standard |
|
333 |
* Java stream object or your own subclass that implements the |
|
334 |
* standard interface. |
|
335 |
* |
|
336 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
337 |
* @param x a <code>java.io.InputStream</code> object that contains the |
|
338 |
* Unicode parameter value |
|
339 |
* @param length the number of bytes in the stream |
|
340 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
341 |
* marker in the SQL statement; if a database access error occurs or |
|
342 |
* this method is called on a closed <code>PreparedStatement</code> |
|
343 |
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support |
|
344 |
* this method |
|
14171
94eb36844bd7
7197395: Add @Deprecated to all deprecated methods to eliminate compiler warnings in JDBC
lancea
parents:
11016
diff
changeset
|
345 |
* @deprecated Use {@code setCharacterStream} |
2 | 346 |
*/ |
14171
94eb36844bd7
7197395: Add @Deprecated to all deprecated methods to eliminate compiler warnings in JDBC
lancea
parents:
11016
diff
changeset
|
347 |
@Deprecated |
2 | 348 |
void setUnicodeStream(int parameterIndex, java.io.InputStream x, |
349 |
int length) throws SQLException; |
|
350 |
||
351 |
/** |
|
352 |
* Sets the designated parameter to the given input stream, which will have |
|
353 |
* the specified number of bytes. |
|
354 |
* When a very large binary value is input to a <code>LONGVARBINARY</code> |
|
355 |
* parameter, it may be more practical to send it via a |
|
356 |
* <code>java.io.InputStream</code> object. The data will be read from the |
|
357 |
* stream as needed until end-of-file is reached. |
|
358 |
* |
|
359 |
* <P><B>Note:</B> This stream object can either be a standard |
|
360 |
* Java stream object or your own subclass that implements the |
|
361 |
* standard interface. |
|
362 |
* |
|
363 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
364 |
* @param x the java input stream which contains the binary parameter value |
|
365 |
* @param length the number of bytes in the stream |
|
366 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
367 |
* marker in the SQL statement; if a database access error occurs or |
|
368 |
* this method is called on a closed <code>PreparedStatement</code> |
|
369 |
*/ |
|
370 |
void setBinaryStream(int parameterIndex, java.io.InputStream x, |
|
371 |
int length) throws SQLException; |
|
372 |
||
373 |
/** |
|
374 |
* Clears the current parameter values immediately. |
|
375 |
* <P>In general, parameter values remain in force for repeated use of a |
|
376 |
* statement. Setting a parameter value automatically clears its |
|
377 |
* previous value. However, in some cases it is useful to immediately |
|
378 |
* release the resources used by the current parameter values; this can |
|
379 |
* be done by calling the method <code>clearParameters</code>. |
|
380 |
* |
|
381 |
* @exception SQLException if a database access error occurs or |
|
382 |
* this method is called on a closed <code>PreparedStatement</code> |
|
383 |
*/ |
|
384 |
void clearParameters() throws SQLException; |
|
385 |
||
386 |
//---------------------------------------------------------------------- |
|
387 |
// Advanced features: |
|
388 |
||
389 |
/** |
|
390 |
* Sets the value of the designated parameter with the given object. |
|
391 |
* This method is like the method <code>setObject</code> |
|
392 |
* above, except that it assumes a scale of zero. |
|
393 |
* |
|
394 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
395 |
* @param x the object containing the input parameter value |
|
396 |
* @param targetSqlType the SQL type (as defined in java.sql.Types) to be |
|
397 |
* sent to the database |
|
398 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
399 |
* marker in the SQL statement; if a database access error occurs or |
|
400 |
* this method is called on a closed <code>PreparedStatement</code> |
|
401 |
* @exception SQLFeatureNotSupportedException if <code>targetSqlType</code> is |
|
402 |
* a <code>ARRAY</code>, <code>BLOB</code>, <code>CLOB</code>, |
|
403 |
* <code>DATALINK</code>, <code>JAVA_OBJECT</code>, <code>NCHAR</code>, |
|
404 |
* <code>NCLOB</code>, <code>NVARCHAR</code>, <code>LONGNVARCHAR</code>, |
|
405 |
* <code>REF</code>, <code>ROWID</code>, <code>SQLXML</code> |
|
406 |
* or <code>STRUCT</code> data type and the JDBC driver does not support |
|
407 |
* this data type |
|
408 |
* @see Types |
|
409 |
*/ |
|
410 |
void setObject(int parameterIndex, Object x, int targetSqlType) |
|
411 |
throws SQLException; |
|
412 |
||
413 |
/** |
|
414 |
* <p>Sets the value of the designated parameter using the given object. |
|
415 |
* The second parameter must be of type <code>Object</code>; therefore, the |
|
416 |
* <code>java.lang</code> equivalent objects should be used for built-in types. |
|
417 |
* |
|
418 |
* <p>The JDBC specification specifies a standard mapping from |
|
419 |
* Java <code>Object</code> types to SQL types. The given argument |
|
420 |
* will be converted to the corresponding SQL type before being |
|
421 |
* sent to the database. |
|
422 |
* |
|
423 |
* <p>Note that this method may be used to pass datatabase- |
|
424 |
* specific abstract data types, by using a driver-specific Java |
|
425 |
* type. |
|
426 |
* |
|
427 |
* If the object is of a class implementing the interface <code>SQLData</code>, |
|
428 |
* the JDBC driver should call the method <code>SQLData.writeSQL</code> |
|
429 |
* to write it to the SQL data stream. |
|
430 |
* If, on the other hand, the object is of a class implementing |
|
431 |
* <code>Ref</code>, <code>Blob</code>, <code>Clob</code>, <code>NClob</code>, |
|
432 |
* <code>Struct</code>, <code>java.net.URL</code>, <code>RowId</code>, <code>SQLXML</code> |
|
433 |
* or <code>Array</code>, the driver should pass it to the database as a |
|
434 |
* value of the corresponding SQL type. |
|
435 |
* <P> |
|
436 |
*<b>Note:</b> Not all databases allow for a non-typed Null to be sent to |
|
437 |
* the backend. For maximum portability, the <code>setNull</code> or the |
|
438 |
* <code>setObject(int parameterIndex, Object x, int sqlType)</code> |
|
439 |
* method should be used |
|
440 |
* instead of <code>setObject(int parameterIndex, Object x)</code>. |
|
441 |
*<p> |
|
442 |
* <b>Note:</b> This method throws an exception if there is an ambiguity, for example, if the |
|
443 |
* object is of a class implementing more than one of the interfaces named above. |
|
444 |
* |
|
445 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
446 |
* @param x the object containing the input parameter value |
|
447 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
448 |
* marker in the SQL statement; if a database access error occurs; |
|
449 |
* this method is called on a closed <code>PreparedStatement</code> |
|
450 |
* or the type of the given object is ambiguous |
|
451 |
*/ |
|
452 |
void setObject(int parameterIndex, Object x) throws SQLException; |
|
453 |
||
454 |
/** |
|
455 |
* Executes the SQL statement in this <code>PreparedStatement</code> object, |
|
456 |
* which may be any kind of SQL statement. |
|
457 |
* Some prepared statements return multiple results; the <code>execute</code> |
|
458 |
* method handles these complex statements as well as the simpler |
|
459 |
* form of statements handled by the methods <code>executeQuery</code> |
|
460 |
* and <code>executeUpdate</code>. |
|
461 |
* <P> |
|
462 |
* The <code>execute</code> method returns a <code>boolean</code> to |
|
463 |
* indicate the form of the first result. You must call either the method |
|
464 |
* <code>getResultSet</code> or <code>getUpdateCount</code> |
|
465 |
* to retrieve the result; you must call <code>getMoreResults</code> to |
|
466 |
* move to any subsequent result(s). |
|
467 |
* |
|
468 |
* @return <code>true</code> if the first result is a <code>ResultSet</code> |
|
469 |
* object; <code>false</code> if the first result is an update |
|
470 |
* count or there is no result |
|
471 |
* @exception SQLException if a database access error occurs; |
|
472 |
* this method is called on a closed <code>PreparedStatement</code> |
|
473 |
* or an argument is supplied to this method |
|
6540 | 474 |
* @throws SQLTimeoutException when the driver has determined that the |
475 |
* timeout value that was specified by the {@code setQueryTimeout} |
|
476 |
* method has been exceeded and has at least attempted to cancel |
|
477 |
* the currently running {@code Statement} |
|
2 | 478 |
* @see Statement#execute |
479 |
* @see Statement#getResultSet |
|
480 |
* @see Statement#getUpdateCount |
|
481 |
* @see Statement#getMoreResults |
|
482 |
||
483 |
*/ |
|
484 |
boolean execute() throws SQLException; |
|
485 |
||
486 |
//--------------------------JDBC 2.0----------------------------- |
|
487 |
||
488 |
/** |
|
489 |
* Adds a set of parameters to this <code>PreparedStatement</code> |
|
490 |
* object's batch of commands. |
|
491 |
* |
|
492 |
* @exception SQLException if a database access error occurs or |
|
493 |
* this method is called on a closed <code>PreparedStatement</code> |
|
494 |
* @see Statement#addBatch |
|
495 |
* @since 1.2 |
|
496 |
*/ |
|
497 |
void addBatch() throws SQLException; |
|
498 |
||
499 |
/** |
|
500 |
* Sets the designated parameter to the given <code>Reader</code> |
|
501 |
* object, which is the given number of characters long. |
|
502 |
* When a very large UNICODE value is input to a <code>LONGVARCHAR</code> |
|
503 |
* parameter, it may be more practical to send it via a |
|
504 |
* <code>java.io.Reader</code> object. The data will be read from the stream |
|
505 |
* as needed until end-of-file is reached. The JDBC driver will |
|
506 |
* do any necessary conversion from UNICODE to the database char format. |
|
507 |
* |
|
508 |
* <P><B>Note:</B> This stream object can either be a standard |
|
509 |
* Java stream object or your own subclass that implements the |
|
510 |
* standard interface. |
|
511 |
* |
|
512 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
513 |
* @param reader the <code>java.io.Reader</code> object that contains the |
|
514 |
* Unicode data |
|
515 |
* @param length the number of characters in the stream |
|
516 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
517 |
* marker in the SQL statement; if a database access error occurs or |
|
518 |
* this method is called on a closed <code>PreparedStatement</code> |
|
519 |
* @since 1.2 |
|
520 |
*/ |
|
521 |
void setCharacterStream(int parameterIndex, |
|
522 |
java.io.Reader reader, |
|
523 |
int length) throws SQLException; |
|
524 |
||
525 |
/** |
|
526 |
* Sets the designated parameter to the given |
|
527 |
* <code>REF(<structured-type>)</code> value. |
|
528 |
* The driver converts this to an SQL <code>REF</code> value when it |
|
529 |
* sends it to the database. |
|
530 |
* |
|
531 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
532 |
* @param x an SQL <code>REF</code> value |
|
533 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
534 |
* marker in the SQL statement; if a database access error occurs or |
|
535 |
* this method is called on a closed <code>PreparedStatement</code> |
|
536 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
537 |
* @since 1.2 |
|
538 |
*/ |
|
539 |
void setRef (int parameterIndex, Ref x) throws SQLException; |
|
540 |
||
541 |
/** |
|
542 |
* Sets the designated parameter to the given <code>java.sql.Blob</code> object. |
|
543 |
* The driver converts this to an SQL <code>BLOB</code> value when it |
|
544 |
* sends it to the database. |
|
545 |
* |
|
546 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
547 |
* @param x a <code>Blob</code> object that maps an SQL <code>BLOB</code> value |
|
548 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
549 |
* marker in the SQL statement; if a database access error occurs or |
|
550 |
* this method is called on a closed <code>PreparedStatement</code> |
|
551 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
552 |
* @since 1.2 |
|
553 |
*/ |
|
554 |
void setBlob (int parameterIndex, Blob x) throws SQLException; |
|
555 |
||
556 |
/** |
|
557 |
* Sets the designated parameter to the given <code>java.sql.Clob</code> object. |
|
558 |
* The driver converts this to an SQL <code>CLOB</code> value when it |
|
559 |
* sends it to the database. |
|
560 |
* |
|
561 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
562 |
* @param x a <code>Clob</code> object that maps an SQL <code>CLOB</code> value |
|
563 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
564 |
* marker in the SQL statement; if a database access error occurs or |
|
565 |
* this method is called on a closed <code>PreparedStatement</code> |
|
566 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
567 |
* @since 1.2 |
|
568 |
*/ |
|
569 |
void setClob (int parameterIndex, Clob x) throws SQLException; |
|
570 |
||
571 |
/** |
|
572 |
* Sets the designated parameter to the given <code>java.sql.Array</code> object. |
|
573 |
* The driver converts this to an SQL <code>ARRAY</code> value when it |
|
574 |
* sends it to the database. |
|
575 |
* |
|
576 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
577 |
* @param x an <code>Array</code> object that maps an SQL <code>ARRAY</code> value |
|
578 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
579 |
* marker in the SQL statement; if a database access error occurs or |
|
580 |
* this method is called on a closed <code>PreparedStatement</code> |
|
581 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
582 |
* @since 1.2 |
|
583 |
*/ |
|
584 |
void setArray (int parameterIndex, Array x) throws SQLException; |
|
585 |
||
586 |
/** |
|
587 |
* Retrieves a <code>ResultSetMetaData</code> object that contains |
|
588 |
* information about the columns of the <code>ResultSet</code> object |
|
589 |
* that will be returned when this <code>PreparedStatement</code> object |
|
590 |
* is executed. |
|
591 |
* <P> |
|
592 |
* Because a <code>PreparedStatement</code> object is precompiled, it is |
|
593 |
* possible to know about the <code>ResultSet</code> object that it will |
|
594 |
* return without having to execute it. Consequently, it is possible |
|
595 |
* to invoke the method <code>getMetaData</code> on a |
|
596 |
* <code>PreparedStatement</code> object rather than waiting to execute |
|
597 |
* it and then invoking the <code>ResultSet.getMetaData</code> method |
|
598 |
* on the <code>ResultSet</code> object that is returned. |
|
599 |
* <P> |
|
600 |
* <B>NOTE:</B> Using this method may be expensive for some drivers due |
|
601 |
* to the lack of underlying DBMS support. |
|
602 |
* |
|
603 |
* @return the description of a <code>ResultSet</code> object's columns or |
|
604 |
* <code>null</code> if the driver cannot return a |
|
605 |
* <code>ResultSetMetaData</code> object |
|
606 |
* @exception SQLException if a database access error occurs or |
|
607 |
* this method is called on a closed <code>PreparedStatement</code> |
|
608 |
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support |
|
609 |
* this method |
|
610 |
* @since 1.2 |
|
611 |
*/ |
|
612 |
ResultSetMetaData getMetaData() throws SQLException; |
|
613 |
||
614 |
/** |
|
615 |
* Sets the designated parameter to the given <code>java.sql.Date</code> value, |
|
616 |
* using the given <code>Calendar</code> object. The driver uses |
|
617 |
* the <code>Calendar</code> object to construct an SQL <code>DATE</code> value, |
|
618 |
* which the driver then sends to the database. With |
|
619 |
* a <code>Calendar</code> object, the driver can calculate the date |
|
620 |
* taking into account a custom timezone. If no |
|
621 |
* <code>Calendar</code> object is specified, the driver uses the default |
|
622 |
* timezone, which is that of the virtual machine running the application. |
|
623 |
* |
|
624 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
625 |
* @param x the parameter value |
|
626 |
* @param cal the <code>Calendar</code> object the driver will use |
|
627 |
* to construct the date |
|
628 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
629 |
* marker in the SQL statement; if a database access error occurs or |
|
630 |
* this method is called on a closed <code>PreparedStatement</code> |
|
631 |
* @since 1.2 |
|
632 |
*/ |
|
633 |
void setDate(int parameterIndex, java.sql.Date x, Calendar cal) |
|
634 |
throws SQLException; |
|
635 |
||
636 |
/** |
|
637 |
* Sets the designated parameter to the given <code>java.sql.Time</code> value, |
|
638 |
* using the given <code>Calendar</code> object. The driver uses |
|
639 |
* the <code>Calendar</code> object to construct an SQL <code>TIME</code> value, |
|
640 |
* which the driver then sends to the database. With |
|
641 |
* a <code>Calendar</code> object, the driver can calculate the time |
|
642 |
* taking into account a custom timezone. If no |
|
643 |
* <code>Calendar</code> object is specified, the driver uses the default |
|
644 |
* timezone, which is that of the virtual machine running the application. |
|
645 |
* |
|
646 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
647 |
* @param x the parameter value |
|
648 |
* @param cal the <code>Calendar</code> object the driver will use |
|
649 |
* to construct the time |
|
650 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
651 |
* marker in the SQL statement; if a database access error occurs or |
|
652 |
* this method is called on a closed <code>PreparedStatement</code> |
|
653 |
* @since 1.2 |
|
654 |
*/ |
|
655 |
void setTime(int parameterIndex, java.sql.Time x, Calendar cal) |
|
656 |
throws SQLException; |
|
657 |
||
658 |
/** |
|
659 |
* Sets the designated parameter to the given <code>java.sql.Timestamp</code> value, |
|
660 |
* using the given <code>Calendar</code> object. The driver uses |
|
661 |
* the <code>Calendar</code> object to construct an SQL <code>TIMESTAMP</code> value, |
|
662 |
* which the driver then sends to the database. With a |
|
663 |
* <code>Calendar</code> object, the driver can calculate the timestamp |
|
664 |
* taking into account a custom timezone. If no |
|
665 |
* <code>Calendar</code> object is specified, the driver uses the default |
|
666 |
* timezone, which is that of the virtual machine running the application. |
|
667 |
* |
|
668 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
669 |
* @param x the parameter value |
|
670 |
* @param cal the <code>Calendar</code> object the driver will use |
|
671 |
* to construct the timestamp |
|
672 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
673 |
* marker in the SQL statement; if a database access error occurs or |
|
674 |
* this method is called on a closed <code>PreparedStatement</code> |
|
675 |
* @since 1.2 |
|
676 |
*/ |
|
677 |
void setTimestamp(int parameterIndex, java.sql.Timestamp x, Calendar cal) |
|
678 |
throws SQLException; |
|
679 |
||
680 |
/** |
|
681 |
* Sets the designated parameter to SQL <code>NULL</code>. |
|
682 |
* This version of the method <code>setNull</code> should |
|
683 |
* be used for user-defined types and REF type parameters. Examples |
|
684 |
* of user-defined types include: STRUCT, DISTINCT, JAVA_OBJECT, and |
|
685 |
* named array types. |
|
686 |
* |
|
687 |
* <P><B>Note:</B> To be portable, applications must give the |
|
688 |
* SQL type code and the fully-qualified SQL type name when specifying |
|
689 |
* a NULL user-defined or REF parameter. In the case of a user-defined type |
|
690 |
* the name is the type name of the parameter itself. For a REF |
|
691 |
* parameter, the name is the type name of the referenced type. If |
|
692 |
* a JDBC driver does not need the type code or type name information, |
|
693 |
* it may ignore it. |
|
694 |
* |
|
695 |
* Although it is intended for user-defined and Ref parameters, |
|
696 |
* this method may be used to set a null parameter of any JDBC type. |
|
697 |
* If the parameter does not have a user-defined or REF type, the given |
|
698 |
* typeName is ignored. |
|
699 |
* |
|
700 |
* |
|
701 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
702 |
* @param sqlType a value from <code>java.sql.Types</code> |
|
703 |
* @param typeName the fully-qualified name of an SQL user-defined type; |
|
704 |
* ignored if the parameter is not a user-defined type or REF |
|
705 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
706 |
* marker in the SQL statement; if a database access error occurs or |
|
707 |
* this method is called on a closed <code>PreparedStatement</code> |
|
708 |
* @exception SQLFeatureNotSupportedException if <code>sqlType</code> is |
|
709 |
* a <code>ARRAY</code>, <code>BLOB</code>, <code>CLOB</code>, |
|
710 |
* <code>DATALINK</code>, <code>JAVA_OBJECT</code>, <code>NCHAR</code>, |
|
711 |
* <code>NCLOB</code>, <code>NVARCHAR</code>, <code>LONGNVARCHAR</code>, |
|
712 |
* <code>REF</code>, <code>ROWID</code>, <code>SQLXML</code> |
|
713 |
* or <code>STRUCT</code> data type and the JDBC driver does not support |
|
714 |
* this data type or if the JDBC driver does not support this method |
|
715 |
* @since 1.2 |
|
716 |
*/ |
|
717 |
void setNull (int parameterIndex, int sqlType, String typeName) |
|
718 |
throws SQLException; |
|
719 |
||
720 |
//------------------------- JDBC 3.0 ----------------------------------- |
|
721 |
||
722 |
/** |
|
723 |
* Sets the designated parameter to the given <code>java.net.URL</code> value. |
|
724 |
* The driver converts this to an SQL <code>DATALINK</code> value |
|
725 |
* when it sends it to the database. |
|
726 |
* |
|
727 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
728 |
* @param x the <code>java.net.URL</code> object to be set |
|
729 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
730 |
* marker in the SQL statement; if a database access error occurs or |
|
731 |
* this method is called on a closed <code>PreparedStatement</code> |
|
732 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
733 |
* @since 1.4 |
|
734 |
*/ |
|
735 |
void setURL(int parameterIndex, java.net.URL x) throws SQLException; |
|
736 |
||
737 |
/** |
|
738 |
* Retrieves the number, types and properties of this |
|
739 |
* <code>PreparedStatement</code> object's parameters. |
|
740 |
* |
|
741 |
* @return a <code>ParameterMetaData</code> object that contains information |
|
742 |
* about the number, types and properties for each |
|
743 |
* parameter marker of this <code>PreparedStatement</code> object |
|
744 |
* @exception SQLException if a database access error occurs or |
|
745 |
* this method is called on a closed <code>PreparedStatement</code> |
|
746 |
* @see ParameterMetaData |
|
747 |
* @since 1.4 |
|
748 |
*/ |
|
749 |
ParameterMetaData getParameterMetaData() throws SQLException; |
|
750 |
||
751 |
//------------------------- JDBC 4.0 ----------------------------------- |
|
752 |
||
753 |
/** |
|
754 |
* Sets the designated parameter to the given <code>java.sql.RowId</code> object. The |
|
755 |
* driver converts this to a SQL <code>ROWID</code> value when it sends it |
|
756 |
* to the database |
|
757 |
* |
|
758 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
759 |
* @param x the parameter value |
|
760 |
* @throws SQLException if parameterIndex does not correspond to a parameter |
|
761 |
* marker in the SQL statement; if a database access error occurs or |
|
762 |
* this method is called on a closed <code>PreparedStatement</code> |
|
763 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
764 |
* |
|
765 |
* @since 1.6 |
|
766 |
*/ |
|
767 |
void setRowId(int parameterIndex, RowId x) throws SQLException; |
|
768 |
||
769 |
||
770 |
/** |
|
11016
e2665f4ac6d2
7110111: Minor Java SE javadoc & Constructor clean up
lancea
parents:
6540
diff
changeset
|
771 |
* Sets the designated parameter to the given <code>String</code> object. |
2 | 772 |
* The driver converts this to a SQL <code>NCHAR</code> or |
773 |
* <code>NVARCHAR</code> or <code>LONGNVARCHAR</code> value |
|
774 |
* (depending on the argument's |
|
775 |
* size relative to the driver's limits on <code>NVARCHAR</code> values) |
|
776 |
* when it sends it to the database. |
|
777 |
* |
|
778 |
* @param parameterIndex of the first parameter is 1, the second is 2, ... |
|
779 |
* @param value the parameter value |
|
780 |
* @throws SQLException if parameterIndex does not correspond to a parameter |
|
781 |
* marker in the SQL statement; if the driver does not support national |
|
782 |
* character sets; if the driver can detect that a data conversion |
|
783 |
* error could occur; if a database access error occurs; or |
|
784 |
* this method is called on a closed <code>PreparedStatement</code> |
|
785 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
786 |
* @since 1.6 |
|
787 |
*/ |
|
788 |
void setNString(int parameterIndex, String value) throws SQLException; |
|
789 |
||
790 |
/** |
|
791 |
* Sets the designated parameter to a <code>Reader</code> object. The |
|
792 |
* <code>Reader</code> reads the data till end-of-file is reached. The |
|
793 |
* driver does the necessary conversion from Java character format to |
|
794 |
* the national character set in the database. |
|
795 |
* @param parameterIndex of the first parameter is 1, the second is 2, ... |
|
796 |
* @param value the parameter value |
|
797 |
* @param length the number of characters in the parameter data. |
|
798 |
* @throws SQLException if parameterIndex does not correspond to a parameter |
|
799 |
* marker in the SQL statement; if the driver does not support national |
|
800 |
* character sets; if the driver can detect that a data conversion |
|
801 |
* error could occur; if a database access error occurs; or |
|
802 |
* this method is called on a closed <code>PreparedStatement</code> |
|
803 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
804 |
* @since 1.6 |
|
805 |
*/ |
|
806 |
void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException; |
|
807 |
||
808 |
/** |
|
809 |
* Sets the designated parameter to a <code>java.sql.NClob</code> object. The driver converts this to a |
|
810 |
* SQL <code>NCLOB</code> value when it sends it to the database. |
|
811 |
* @param parameterIndex of the first parameter is 1, the second is 2, ... |
|
812 |
* @param value the parameter value |
|
813 |
* @throws SQLException if parameterIndex does not correspond to a parameter |
|
814 |
* marker in the SQL statement; if the driver does not support national |
|
815 |
* character sets; if the driver can detect that a data conversion |
|
816 |
* error could occur; if a database access error occurs; or |
|
817 |
* this method is called on a closed <code>PreparedStatement</code> |
|
818 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
819 |
* @since 1.6 |
|
820 |
*/ |
|
821 |
void setNClob(int parameterIndex, NClob value) throws SQLException; |
|
822 |
||
823 |
/** |
|
824 |
* Sets the designated parameter to a <code>Reader</code> object. The reader must contain the number |
|
825 |
* of characters specified by length otherwise a <code>SQLException</code> will be |
|
826 |
* generated when the <code>PreparedStatement</code> is executed. |
|
827 |
*This method differs from the <code>setCharacterStream (int, Reader, int)</code> method |
|
828 |
* because it informs the driver that the parameter value should be sent to |
|
829 |
* the server as a <code>CLOB</code>. When the <code>setCharacterStream</code> method is used, the |
|
830 |
* driver may have to do extra work to determine whether the parameter |
|
831 |
* data should be sent to the server as a <code>LONGVARCHAR</code> or a <code>CLOB</code> |
|
832 |
* @param parameterIndex index of the first parameter is 1, the second is 2, ... |
|
833 |
* @param reader An object that contains the data to set the parameter value to. |
|
834 |
* @param length the number of characters in the parameter data. |
|
835 |
* @throws SQLException if parameterIndex does not correspond to a parameter |
|
836 |
* marker in the SQL statement; if a database access error occurs; this method is called on |
|
837 |
* a closed <code>PreparedStatement</code> or if the length specified is less than zero. |
|
838 |
* |
|
839 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
840 |
* @since 1.6 |
|
841 |
*/ |
|
842 |
void setClob(int parameterIndex, Reader reader, long length) |
|
843 |
throws SQLException; |
|
844 |
||
845 |
/** |
|
846 |
* Sets the designated parameter to a <code>InputStream</code> object. The inputstream must contain the number |
|
847 |
* of characters specified by length otherwise a <code>SQLException</code> will be |
|
848 |
* generated when the <code>PreparedStatement</code> is executed. |
|
849 |
* This method differs from the <code>setBinaryStream (int, InputStream, int)</code> |
|
850 |
* method because it informs the driver that the parameter value should be |
|
851 |
* sent to the server as a <code>BLOB</code>. When the <code>setBinaryStream</code> method is used, |
|
852 |
* the driver may have to do extra work to determine whether the parameter |
|
853 |
* data should be sent to the server as a <code>LONGVARBINARY</code> or a <code>BLOB</code> |
|
854 |
* @param parameterIndex index of the first parameter is 1, |
|
855 |
* the second is 2, ... |
|
856 |
* @param inputStream An object that contains the data to set the parameter |
|
857 |
* value to. |
|
858 |
* @param length the number of bytes in the parameter data. |
|
859 |
* @throws SQLException if parameterIndex does not correspond to a parameter |
|
860 |
* marker in the SQL statement; if a database access error occurs; |
|
861 |
* this method is called on a closed <code>PreparedStatement</code>; |
|
862 |
* if the length specified |
|
863 |
* is less than zero or if the number of bytes in the inputstream does not match |
|
864 |
* the specfied length. |
|
865 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
866 |
* |
|
867 |
* @since 1.6 |
|
868 |
*/ |
|
869 |
void setBlob(int parameterIndex, InputStream inputStream, long length) |
|
870 |
throws SQLException; |
|
871 |
/** |
|
872 |
* Sets the designated parameter to a <code>Reader</code> object. The reader must contain the number |
|
873 |
* of characters specified by length otherwise a <code>SQLException</code> will be |
|
874 |
* generated when the <code>PreparedStatement</code> is executed. |
|
875 |
* This method differs from the <code>setCharacterStream (int, Reader, int)</code> method |
|
876 |
* because it informs the driver that the parameter value should be sent to |
|
877 |
* the server as a <code>NCLOB</code>. When the <code>setCharacterStream</code> method is used, the |
|
878 |
* driver may have to do extra work to determine whether the parameter |
|
879 |
* data should be sent to the server as a <code>LONGNVARCHAR</code> or a <code>NCLOB</code> |
|
880 |
* @param parameterIndex index of the first parameter is 1, the second is 2, ... |
|
881 |
* @param reader An object that contains the data to set the parameter value to. |
|
882 |
* @param length the number of characters in the parameter data. |
|
883 |
* @throws SQLException if parameterIndex does not correspond to a parameter |
|
884 |
* marker in the SQL statement; if the length specified is less than zero; |
|
885 |
* if the driver does not support national character sets; |
|
886 |
* if the driver can detect that a data conversion |
|
887 |
* error could occur; if a database access error occurs or |
|
888 |
* this method is called on a closed <code>PreparedStatement</code> |
|
889 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
890 |
* |
|
891 |
* @since 1.6 |
|
892 |
*/ |
|
893 |
void setNClob(int parameterIndex, Reader reader, long length) |
|
894 |
throws SQLException; |
|
895 |
||
896 |
/** |
|
897 |
* Sets the designated parameter to the given <code>java.sql.SQLXML</code> object. |
|
898 |
* The driver converts this to an |
|
899 |
* SQL <code>XML</code> value when it sends it to the database. |
|
900 |
* <p> |
|
901 |
* |
|
902 |
* @param parameterIndex index of the first parameter is 1, the second is 2, ... |
|
903 |
* @param xmlObject a <code>SQLXML</code> object that maps an SQL <code>XML</code> value |
|
904 |
* @throws SQLException if parameterIndex does not correspond to a parameter |
|
905 |
* marker in the SQL statement; if a database access error occurs; |
|
906 |
* this method is called on a closed <code>PreparedStatement</code> |
|
907 |
* or the <code>java.xml.transform.Result</code>, |
|
908 |
* <code>Writer</code> or <code>OutputStream</code> has not been closed for |
|
909 |
* the <code>SQLXML</code> object |
|
910 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
911 |
* |
|
912 |
* @since 1.6 |
|
913 |
*/ |
|
914 |
void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException; |
|
915 |
||
916 |
/** |
|
917 |
* <p>Sets the value of the designated parameter with the given object. The second |
|
918 |
* argument must be an object type; for integral values, the |
|
919 |
* <code>java.lang</code> equivalent objects should be used. |
|
920 |
* |
|
921 |
* If the second argument is an <code>InputStream</code> then the stream must contain |
|
922 |
* the number of bytes specified by scaleOrLength. If the second argument is a |
|
923 |
* <code>Reader</code> then the reader must contain the number of characters specified |
|
924 |
* by scaleOrLength. If these conditions are not true the driver will generate a |
|
925 |
* <code>SQLException</code> when the prepared statement is executed. |
|
926 |
* |
|
927 |
* <p>The given Java object will be converted to the given targetSqlType |
|
928 |
* before being sent to the database. |
|
929 |
* |
|
930 |
* If the object has a custom mapping (is of a class implementing the |
|
931 |
* interface <code>SQLData</code>), |
|
932 |
* the JDBC driver should call the method <code>SQLData.writeSQL</code> to |
|
933 |
* write it to the SQL data stream. |
|
934 |
* If, on the other hand, the object is of a class implementing |
|
935 |
* <code>Ref</code>, <code>Blob</code>, <code>Clob</code>, <code>NClob</code>, |
|
936 |
* <code>Struct</code>, <code>java.net.URL</code>, |
|
937 |
* or <code>Array</code>, the driver should pass it to the database as a |
|
938 |
* value of the corresponding SQL type. |
|
939 |
* |
|
940 |
* <p>Note that this method may be used to pass database-specific |
|
941 |
* abstract data types. |
|
942 |
* |
|
943 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
944 |
* @param x the object containing the input parameter value |
|
945 |
* @param targetSqlType the SQL type (as defined in java.sql.Types) to be |
|
946 |
* sent to the database. The scale argument may further qualify this type. |
|
947 |
* @param scaleOrLength for <code>java.sql.Types.DECIMAL</code> |
|
948 |
* or <code>java.sql.Types.NUMERIC types</code>, |
|
949 |
* this is the number of digits after the decimal point. For |
|
950 |
* Java Object types <code>InputStream</code> and <code>Reader</code>, |
|
951 |
* this is the length |
|
952 |
* of the data in the stream or reader. For all other types, |
|
953 |
* this value will be ignored. |
|
954 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
955 |
* marker in the SQL statement; if a database access error occurs; |
|
956 |
* this method is called on a closed <code>PreparedStatement</code> or |
|
957 |
* if the Java Object specified by x is an InputStream |
|
958 |
* or Reader object and the value of the scale parameter is less |
|
959 |
* than zero |
|
960 |
* @exception SQLFeatureNotSupportedException if <code>targetSqlType</code> is |
|
961 |
* a <code>ARRAY</code>, <code>BLOB</code>, <code>CLOB</code>, |
|
962 |
* <code>DATALINK</code>, <code>JAVA_OBJECT</code>, <code>NCHAR</code>, |
|
963 |
* <code>NCLOB</code>, <code>NVARCHAR</code>, <code>LONGNVARCHAR</code>, |
|
964 |
* <code>REF</code>, <code>ROWID</code>, <code>SQLXML</code> |
|
965 |
* or <code>STRUCT</code> data type and the JDBC driver does not support |
|
966 |
* this data type |
|
967 |
* @see Types |
|
968 |
* |
|
969 |
* @since 1.6 |
|
970 |
*/ |
|
971 |
void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) |
|
972 |
throws SQLException; |
|
973 |
/** |
|
974 |
* Sets the designated parameter to the given input stream, which will have |
|
975 |
* the specified number of bytes. |
|
976 |
* When a very large ASCII value is input to a <code>LONGVARCHAR</code> |
|
977 |
* parameter, it may be more practical to send it via a |
|
978 |
* <code>java.io.InputStream</code>. Data will be read from the stream |
|
979 |
* as needed until end-of-file is reached. The JDBC driver will |
|
980 |
* do any necessary conversion from ASCII to the database char format. |
|
981 |
* |
|
982 |
* <P><B>Note:</B> This stream object can either be a standard |
|
983 |
* Java stream object or your own subclass that implements the |
|
984 |
* standard interface. |
|
985 |
* |
|
986 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
987 |
* @param x the Java input stream that contains the ASCII parameter value |
|
988 |
* @param length the number of bytes in the stream |
|
989 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
990 |
* marker in the SQL statement; if a database access error occurs or |
|
991 |
* this method is called on a closed <code>PreparedStatement</code> |
|
992 |
* @since 1.6 |
|
993 |
*/ |
|
994 |
void setAsciiStream(int parameterIndex, java.io.InputStream x, long length) |
|
995 |
throws SQLException; |
|
996 |
/** |
|
997 |
* Sets the designated parameter to the given input stream, which will have |
|
998 |
* the specified number of bytes. |
|
999 |
* When a very large binary value is input to a <code>LONGVARBINARY</code> |
|
1000 |
* parameter, it may be more practical to send it via a |
|
1001 |
* <code>java.io.InputStream</code> object. The data will be read from the |
|
1002 |
* stream as needed until end-of-file is reached. |
|
1003 |
* |
|
1004 |
* <P><B>Note:</B> This stream object can either be a standard |
|
1005 |
* Java stream object or your own subclass that implements the |
|
1006 |
* standard interface. |
|
1007 |
* |
|
1008 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
1009 |
* @param x the java input stream which contains the binary parameter value |
|
1010 |
* @param length the number of bytes in the stream |
|
1011 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
1012 |
* marker in the SQL statement; if a database access error occurs or |
|
1013 |
* this method is called on a closed <code>PreparedStatement</code> |
|
1014 |
* @since 1.6 |
|
1015 |
*/ |
|
1016 |
void setBinaryStream(int parameterIndex, java.io.InputStream x, |
|
1017 |
long length) throws SQLException; |
|
1018 |
/** |
|
1019 |
* Sets the designated parameter to the given <code>Reader</code> |
|
1020 |
* object, which is the given number of characters long. |
|
1021 |
* When a very large UNICODE value is input to a <code>LONGVARCHAR</code> |
|
1022 |
* parameter, it may be more practical to send it via a |
|
1023 |
* <code>java.io.Reader</code> object. The data will be read from the stream |
|
1024 |
* as needed until end-of-file is reached. The JDBC driver will |
|
1025 |
* do any necessary conversion from UNICODE to the database char format. |
|
1026 |
* |
|
1027 |
* <P><B>Note:</B> This stream object can either be a standard |
|
1028 |
* Java stream object or your own subclass that implements the |
|
1029 |
* standard interface. |
|
1030 |
* |
|
1031 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
1032 |
* @param reader the <code>java.io.Reader</code> object that contains the |
|
1033 |
* Unicode data |
|
1034 |
* @param length the number of characters in the stream |
|
1035 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
1036 |
* marker in the SQL statement; if a database access error occurs or |
|
1037 |
* this method is called on a closed <code>PreparedStatement</code> |
|
1038 |
* @since 1.6 |
|
1039 |
*/ |
|
1040 |
void setCharacterStream(int parameterIndex, |
|
1041 |
java.io.Reader reader, |
|
1042 |
long length) throws SQLException; |
|
1043 |
//----- |
|
1044 |
/** |
|
1045 |
* Sets the designated parameter to the given input stream. |
|
1046 |
* When a very large ASCII value is input to a <code>LONGVARCHAR</code> |
|
1047 |
* parameter, it may be more practical to send it via a |
|
1048 |
* <code>java.io.InputStream</code>. Data will be read from the stream |
|
1049 |
* as needed until end-of-file is reached. The JDBC driver will |
|
1050 |
* do any necessary conversion from ASCII to the database char format. |
|
1051 |
* |
|
1052 |
* <P><B>Note:</B> This stream object can either be a standard |
|
1053 |
* Java stream object or your own subclass that implements the |
|
1054 |
* standard interface. |
|
1055 |
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if |
|
1056 |
* it might be more efficient to use a version of |
|
1057 |
* <code>setAsciiStream</code> which takes a length parameter. |
|
1058 |
* |
|
1059 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
1060 |
* @param x the Java input stream that contains the ASCII parameter value |
|
1061 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
1062 |
* marker in the SQL statement; if a database access error occurs or |
|
1063 |
* this method is called on a closed <code>PreparedStatement</code> |
|
1064 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
1065 |
* @since 1.6 |
|
1066 |
*/ |
|
1067 |
void setAsciiStream(int parameterIndex, java.io.InputStream x) |
|
1068 |
throws SQLException; |
|
1069 |
/** |
|
1070 |
* Sets the designated parameter to the given input stream. |
|
1071 |
* When a very large binary value is input to a <code>LONGVARBINARY</code> |
|
1072 |
* parameter, it may be more practical to send it via a |
|
1073 |
* <code>java.io.InputStream</code> object. The data will be read from the |
|
1074 |
* stream as needed until end-of-file is reached. |
|
1075 |
* |
|
1076 |
* <P><B>Note:</B> This stream object can either be a standard |
|
1077 |
* Java stream object or your own subclass that implements the |
|
1078 |
* standard interface. |
|
1079 |
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if |
|
1080 |
* it might be more efficient to use a version of |
|
1081 |
* <code>setBinaryStream</code> which takes a length parameter. |
|
1082 |
* |
|
1083 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
1084 |
* @param x the java input stream which contains the binary parameter value |
|
1085 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
1086 |
* marker in the SQL statement; if a database access error occurs or |
|
1087 |
* this method is called on a closed <code>PreparedStatement</code> |
|
1088 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
1089 |
* @since 1.6 |
|
1090 |
*/ |
|
1091 |
void setBinaryStream(int parameterIndex, java.io.InputStream x) |
|
1092 |
throws SQLException; |
|
1093 |
/** |
|
1094 |
* Sets the designated parameter to the given <code>Reader</code> |
|
1095 |
* object. |
|
1096 |
* When a very large UNICODE value is input to a <code>LONGVARCHAR</code> |
|
1097 |
* parameter, it may be more practical to send it via a |
|
1098 |
* <code>java.io.Reader</code> object. The data will be read from the stream |
|
1099 |
* as needed until end-of-file is reached. The JDBC driver will |
|
1100 |
* do any necessary conversion from UNICODE to the database char format. |
|
1101 |
* |
|
1102 |
* <P><B>Note:</B> This stream object can either be a standard |
|
1103 |
* Java stream object or your own subclass that implements the |
|
1104 |
* standard interface. |
|
1105 |
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if |
|
1106 |
* it might be more efficient to use a version of |
|
1107 |
* <code>setCharacterStream</code> which takes a length parameter. |
|
1108 |
* |
|
1109 |
* @param parameterIndex the first parameter is 1, the second is 2, ... |
|
1110 |
* @param reader the <code>java.io.Reader</code> object that contains the |
|
1111 |
* Unicode data |
|
1112 |
* @exception SQLException if parameterIndex does not correspond to a parameter |
|
1113 |
* marker in the SQL statement; if a database access error occurs or |
|
1114 |
* this method is called on a closed <code>PreparedStatement</code> |
|
1115 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
1116 |
* @since 1.6 |
|
1117 |
*/ |
|
1118 |
void setCharacterStream(int parameterIndex, |
|
1119 |
java.io.Reader reader) throws SQLException; |
|
1120 |
/** |
|
1121 |
* Sets the designated parameter to a <code>Reader</code> object. The |
|
1122 |
* <code>Reader</code> reads the data till end-of-file is reached. The |
|
1123 |
* driver does the necessary conversion from Java character format to |
|
1124 |
* the national character set in the database. |
|
1125 |
||
1126 |
* <P><B>Note:</B> This stream object can either be a standard |
|
1127 |
* Java stream object or your own subclass that implements the |
|
1128 |
* standard interface. |
|
1129 |
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if |
|
1130 |
* it might be more efficient to use a version of |
|
1131 |
* <code>setNCharacterStream</code> which takes a length parameter. |
|
1132 |
* |
|
1133 |
* @param parameterIndex of the first parameter is 1, the second is 2, ... |
|
1134 |
* @param value the parameter value |
|
1135 |
* @throws SQLException if parameterIndex does not correspond to a parameter |
|
1136 |
* marker in the SQL statement; if the driver does not support national |
|
1137 |
* character sets; if the driver can detect that a data conversion |
|
1138 |
* error could occur; if a database access error occurs; or |
|
1139 |
* this method is called on a closed <code>PreparedStatement</code> |
|
1140 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
1141 |
* @since 1.6 |
|
1142 |
*/ |
|
1143 |
void setNCharacterStream(int parameterIndex, Reader value) throws SQLException; |
|
1144 |
||
1145 |
/** |
|
1146 |
* Sets the designated parameter to a <code>Reader</code> object. |
|
1147 |
* This method differs from the <code>setCharacterStream (int, Reader)</code> method |
|
1148 |
* because it informs the driver that the parameter value should be sent to |
|
1149 |
* the server as a <code>CLOB</code>. When the <code>setCharacterStream</code> method is used, the |
|
1150 |
* driver may have to do extra work to determine whether the parameter |
|
1151 |
* data should be sent to the server as a <code>LONGVARCHAR</code> or a <code>CLOB</code> |
|
1152 |
* |
|
1153 |
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if |
|
1154 |
* it might be more efficient to use a version of |
|
1155 |
* <code>setClob</code> which takes a length parameter. |
|
1156 |
* |
|
1157 |
* @param parameterIndex index of the first parameter is 1, the second is 2, ... |
|
1158 |
* @param reader An object that contains the data to set the parameter value to. |
|
1159 |
* @throws SQLException if parameterIndex does not correspond to a parameter |
|
1160 |
* marker in the SQL statement; if a database access error occurs; this method is called on |
|
1161 |
* a closed <code>PreparedStatement</code>or if parameterIndex does not correspond to a parameter |
|
1162 |
* marker in the SQL statement |
|
1163 |
* |
|
1164 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
1165 |
* @since 1.6 |
|
1166 |
*/ |
|
1167 |
void setClob(int parameterIndex, Reader reader) |
|
1168 |
throws SQLException; |
|
1169 |
||
1170 |
/** |
|
1171 |
* Sets the designated parameter to a <code>InputStream</code> object. |
|
1172 |
* This method differs from the <code>setBinaryStream (int, InputStream)</code> |
|
1173 |
* method because it informs the driver that the parameter value should be |
|
1174 |
* sent to the server as a <code>BLOB</code>. When the <code>setBinaryStream</code> method is used, |
|
1175 |
* the driver may have to do extra work to determine whether the parameter |
|
1176 |
* data should be sent to the server as a <code>LONGVARBINARY</code> or a <code>BLOB</code> |
|
1177 |
* |
|
1178 |
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if |
|
1179 |
* it might be more efficient to use a version of |
|
1180 |
* <code>setBlob</code> which takes a length parameter. |
|
1181 |
* |
|
1182 |
* @param parameterIndex index of the first parameter is 1, |
|
1183 |
* the second is 2, ... |
|
1184 |
* @param inputStream An object that contains the data to set the parameter |
|
1185 |
* value to. |
|
1186 |
* @throws SQLException if parameterIndex does not correspond to a parameter |
|
1187 |
* marker in the SQL statement; if a database access error occurs; |
|
1188 |
* this method is called on a closed <code>PreparedStatement</code> or |
|
1189 |
* if parameterIndex does not correspond |
|
1190 |
* to a parameter marker in the SQL statement, |
|
1191 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
1192 |
* |
|
1193 |
* @since 1.6 |
|
1194 |
*/ |
|
1195 |
void setBlob(int parameterIndex, InputStream inputStream) |
|
1196 |
throws SQLException; |
|
1197 |
/** |
|
1198 |
* Sets the designated parameter to a <code>Reader</code> object. |
|
1199 |
* This method differs from the <code>setCharacterStream (int, Reader)</code> method |
|
1200 |
* because it informs the driver that the parameter value should be sent to |
|
1201 |
* the server as a <code>NCLOB</code>. When the <code>setCharacterStream</code> method is used, the |
|
1202 |
* driver may have to do extra work to determine whether the parameter |
|
1203 |
* data should be sent to the server as a <code>LONGNVARCHAR</code> or a <code>NCLOB</code> |
|
1204 |
* <P><B>Note:</B> Consult your JDBC driver documentation to determine if |
|
1205 |
* it might be more efficient to use a version of |
|
1206 |
* <code>setNClob</code> which takes a length parameter. |
|
1207 |
* |
|
1208 |
* @param parameterIndex index of the first parameter is 1, the second is 2, ... |
|
1209 |
* @param reader An object that contains the data to set the parameter value to. |
|
1210 |
* @throws SQLException if parameterIndex does not correspond to a parameter |
|
1211 |
* marker in the SQL statement; |
|
1212 |
* if the driver does not support national character sets; |
|
1213 |
* if the driver can detect that a data conversion |
|
1214 |
* error could occur; if a database access error occurs or |
|
1215 |
* this method is called on a closed <code>PreparedStatement</code> |
|
1216 |
* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
1217 |
* |
|
1218 |
* @since 1.6 |
|
1219 |
*/ |
|
1220 |
void setNClob(int parameterIndex, Reader reader) |
|
1221 |
throws SQLException; |
|
1222 |
||
6540 | 1223 |
|
2 | 1224 |
} |