KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > resource > PreparedStatementWrapper


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2005 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: PreparedStatementWrapper.java,v 1.16.4.1 2005/08/03 10:49:16 coqp Exp $
23  * --------------------------------------------------------------------------
24  *
25  */

26
27 package org.objectweb.jonas.resource;
28
29 import java.io.InputStream JavaDoc;
30 import java.io.Reader JavaDoc;
31 import java.math.BigDecimal JavaDoc;
32 import java.net.URL JavaDoc;
33 import java.sql.Array JavaDoc;
34 import java.sql.Blob JavaDoc;
35 import java.sql.Clob JavaDoc;
36 import java.sql.Connection JavaDoc;
37 import java.sql.Date JavaDoc;
38 import java.sql.ParameterMetaData JavaDoc;
39 import java.sql.PreparedStatement JavaDoc;
40 import java.sql.Ref JavaDoc;
41 import java.sql.ResultSet JavaDoc;
42 import java.sql.ResultSetMetaData JavaDoc;
43 import java.sql.SQLException JavaDoc;
44 import java.sql.SQLWarning JavaDoc;
45 import java.sql.Time JavaDoc;
46 import java.sql.Timestamp JavaDoc;
47 import java.util.Arrays JavaDoc;
48 import java.util.Calendar JavaDoc;
49
50 import org.objectweb.util.monolog.api.BasicLevel;
51 import org.objectweb.util.monolog.api.Logger;
52
53 /**
54  * This class <b>PreparedStatementWrapper</b> wrapp an SQL PreparedStatement
55  * @author Eric HARDESTY
56  */

57 public class PreparedStatementWrapper implements PreparedStatement JavaDoc {
58
59     /**
60      * Prime numbers
61      */

62     private static final int[] PRIME_NUMBERS = new int[] {11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
63
64     /**
65      * Wrapped preparedstatement object
66      */

67     private PreparedStatement JavaDoc pstmt = null;
68
69     /**
70      * User used for the preparedstatement
71      */

72     private String JavaDoc user = null;
73
74     /**
75      * SQL statement
76      */

77     private String JavaDoc sql = null;
78
79     /**
80      * This object has been marked invalid ?
81      */

82     private boolean invalid = false;
83
84     /**
85      * This object is now closed ?
86      */

87     private boolean closed = false;
88
89     /**
90      * Hashcode of this object
91      */

92     private int hashCode;
93
94     /**
95      * Type of result set. one of <code>ResultSet.TYPE_FORWARD_ONLY</code>,
96      * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
97      * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
98      */

99     private int resultSetType = -1;
100
101     /**
102      * Concurrency type for result set; one of
103      * <code>ResultSet.CONCUR_READ_ONLY</code> or
104      * <code>ResultSet.CONCUR_UPDATABLE</code>
105      */

106     private int resultSetConcurrency = -1;
107
108     /**
109      * Holdability, One of the value :
110      * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
111      * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
112      */

113     private int resultSetHoldability = -1;
114
115     /**
116      * A flag indicating whether auto-generated keys should be returned; one of
117      * <code>Statement.RETURN_GENERATED_KEYS</code> or
118      * <code>Statement.NO_GENERATED_KEYS</code>
119      */

120     private int autoGeneratedKeys = -1;
121
122     /**
123      * An array of column indexes indicating the columns that should be returned
124      * from the inserted row or rows
125      */

126     private int[] columnIndexes = null;
127
128     /**
129      * An array of column names indicating the columns that should be returned
130      * from the inserted row or rows
131      */

132     private String JavaDoc[] columnNames = null;
133
134     /**
135      * Logger used for traces
136      */

137     private final Logger trace;
138
139     /**
140      * Direction was Changed ? need to reset or not
141      */

142     private boolean setFetchDirectionCalled = false;
143
144     /**
145      * Escape processing was changed ? need to reset or not
146      */

147     private boolean setEscapeProcessingCalled = false;
148
149     /**
150      * Max field size ? need to reset or not
151      */

152     private boolean setMaxFieldSizeCalled = false;
153
154     /**
155      * Debug logging enabled ?
156      */

157     private final boolean isDebugLogging;
158
159     /**
160      * Creates a <code>PreparedStatementWrapper</code> object.
161      * This constructor is private and is used by other constructors.
162      * It contains all constructors elements.
163      * @param user the user used for accessing the connection
164      * @param sql a <code>String</code> object that is the SQL statement to be
165      * sent to the database; may contain one or more ? IN parameters
166      * @param resultSetType a result set type; one of
167      * <code>ResultSet.TYPE_FORWARD_ONLY</code>,
168      * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
169      * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
170      * @param resultSetConcurrency a concurrency type; one of
171      * <code>ResultSet.CONCUR_READ_ONLY</code> or
172      * <code>ResultSet.CONCUR_UPDATABLE</code>
173      * @param resultSetHoldability one of the following <code>ResultSet</code>
174      * constants: <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
175      * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
176      * @param autoGeneratedKeys a flag indicating whether auto-generated keys
177      * should be returned; one of
178      * <code>Statement.RETURN_GENERATED_KEYS</code> or
179      * <code>Statement.NO_GENERATED_KEYS</code>
180      * @param columnIndexes an array of column indexes indicating the columns
181      * that should be returned from the inserted row or rows
182      * @param columnNames an array of column names indicating the columns that
183      * should be returned from the inserted row or rows
184      * @param trace the logger to use for logging purpose
185      * @param isDebugLogging if true, log the debug event in the logger
186      */

187     private PreparedStatementWrapper(final String JavaDoc user, final String JavaDoc sql, final int resultSetType,
188             final int resultSetConcurrency, final int resultSetHoldability, final int autoGeneratedKeys,
189             final int[] columnIndexes, final String JavaDoc[] columnNames, final Logger trace, final boolean isDebugLogging) {
190
191         this.user = user;
192         this.sql = sql;
193         this.resultSetType = resultSetType;
194         this.resultSetConcurrency = resultSetConcurrency;
195         this.resultSetHoldability = resultSetHoldability;
196         this.autoGeneratedKeys = autoGeneratedKeys;
197         this.columnIndexes = columnIndexes;
198         this.columnNames = columnNames;
199         this.trace = trace;
200
201         int i = 0;
202         // hashcode computing
203
if (sql != null) {
204             hashCode = sql.hashCode();
205         } else {
206             hashCode = PRIME_NUMBERS[i++];
207         }
208         if (user != null) {
209             hashCode ^= user.hashCode();
210         } else {
211             hashCode ^= PRIME_NUMBERS[i++];
212         }
213         hashCode ^= (resultSetType * PRIME_NUMBERS[i++]);
214         hashCode ^= (resultSetConcurrency * PRIME_NUMBERS[i++]);
215         hashCode ^= (resultSetHoldability * PRIME_NUMBERS[i++]);
216         hashCode ^= (autoGeneratedKeys * PRIME_NUMBERS[i++]);
217         if (columnIndexes != null) {
218             hashCode ^= columnIndexes.hashCode();
219         } else {
220             hashCode ^= PRIME_NUMBERS[i++];
221         }
222         if (columnNames != null) {
223             hashCode ^= columnNames.hashCode();
224         } else {
225             hashCode ^= PRIME_NUMBERS[i++];
226         }
227         this.isDebugLogging = isDebugLogging;
228     }
229
230
231
232     /**
233      * Creates a <code>PreparedStatementWrapper</code> object that will
234      * generate <code>ResultSet</code> objects with the given type and
235      * concurrency. This method is the same as the <code>prepareStatement</code>
236      * method above, but it allows the default result set type and concurrency
237      * to be overridden.
238      * @param user the user used for accessing the connection
239      * @param sql a <code>String</code> object that is the SQL statement to be
240      * sent to the database; may contain one or more ? IN parameters
241      * @param resultSetType a result set type; one of
242      * <code>ResultSet.TYPE_FORWARD_ONLY</code>,
243      * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
244      * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
245      * @param resultSetConcurrency a concurrency type; one of
246      * <code>ResultSet.CONCUR_READ_ONLY</code> or
247      * <code>ResultSet.CONCUR_UPDATABLE</code>
248      * @param trace the logger to use for logging purpose
249      * @param isDebugLogging if true, log the debug event in the logger
250      * @since JDK 1.2
251      */

252     public PreparedStatementWrapper(final String JavaDoc user, final String JavaDoc sql, final int resultSetType,
253             final int resultSetConcurrency, final Logger trace, final boolean isDebugLogging) {
254         this(user, sql, resultSetType, resultSetConcurrency, -1, -1, null, null, trace, isDebugLogging);
255     }
256
257     /**
258      * Creates a <code>PreparedStatementWrapper</code> object that will
259      * generate <code>ResultSet</code> objects with the given type,
260      * concurrency, and holdability.
261      * <P>
262      * This method is the same as the <code>prepareStatement</code> method
263      * above, but it allows the default result set type, concurrency, and
264      * holdability to be overridden.
265      * @param user the user used for accessing the connection
266      * @param sql a <code>String</code> object that is the SQL statement to be
267      * sent to the database; may contain one or more ? IN parameters
268      * @param resultSetType one of the following <code>ResultSet</code>
269      * constants: <code>ResultSet.TYPE_FORWARD_ONLY</code>,
270      * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
271      * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
272      * @param resultSetConcurrency one of the following <code>ResultSet</code>
273      * constants: <code>ResultSet.CONCUR_READ_ONLY</code> or
274      * <code>ResultSet.CONCUR_UPDATABLE</code>
275      * @param resultSetHoldability one of the following <code>ResultSet</code>
276      * constants: <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
277      * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
278      * @param trace the logger to use for logging purpose
279      * @param isDebugLogging if true, log the debug event in the logger
280      * @since JDK 1.4
281      */

282     public PreparedStatementWrapper(final String JavaDoc user, final String JavaDoc sql, final int resultSetType,
283             final int resultSetConcurrency, final int resultSetHoldability, final Logger trace, final boolean isDebugLogging) {
284         this(user, sql, resultSetType, resultSetConcurrency, resultSetHoldability, -1, null, null, trace, isDebugLogging);
285     }
286
287     /**
288      * Creates a default <code>PreparedStatementWrapper</code> object that has
289      * the capability to retrieve auto-generated keys. The given constant tells
290      * the driver whether it should make auto-generated keys available for
291      * retrieval. This parameter is ignored if the SQL statement is not an
292      * <code>INSERT</code> statement.
293      * @param user the user used for accessing the connection
294      * @param sql an SQL statement that may contain one or more '?' IN parameter
295      * placeholders
296      * @param autoGeneratedKeys a flag indicating whether auto-generated keys
297      * should be returned; one of
298      * <code>Statement.RETURN_GENERATED_KEYS</code> or
299      * <code>Statement.NO_GENERATED_KEYS</code>
300      * @param trace the logger to use for logging purpose
301      * @param isDebugLogging if true, log the debug event in the logger
302      * @since JDK 1.4
303      */

304     public PreparedStatementWrapper(final String JavaDoc user, final String JavaDoc sql, final int autoGeneratedKeys, final Logger trace, final boolean isDebugLogging) {
305         this(user, sql, -1, -1, -1, autoGeneratedKeys, null, null, trace, isDebugLogging);
306     }
307
308     /**
309      * Creates a default <code>PreparedStatementWrapper</code> object capable
310      * of returning the auto-generated keys designated by the given array. This
311      * array contains the indexes of the columns in the target table that
312      * contain the auto-generated keys that should be made available. This array
313      * is ignored if the SQL statement is not an <code>INSERT</code>
314      * statement.
315      * <P>
316      * An SQL statement with or without IN parameters can be pre-compiled and
317      * stored in a <code>PreparedStatement</code> object. This object can then
318      * be used to efficiently execute this statement multiple times.
319      * @param user the user used for accessing the connection
320      * @param sql an SQL statement that may contain one or more '?' IN parameter
321      * placeholders
322      * @param columnIndexes an array of column indexes indicating the columns
323      * that should be returned from the inserted row or rows
324      * @param trace the logger to use for logging purpose
325      * @param isDebugLogging if true, log the debug event in the logger
326      * @since JDK 1.4
327      */

328     public PreparedStatementWrapper(final String JavaDoc user, final String JavaDoc sql, final int[] columnIndexes, final Logger trace, final boolean isDebugLogging) {
329         this(user, sql, -1, -1, -1, -1, columnIndexes, null, trace, isDebugLogging);
330     }
331
332     /**
333      * Creates a default <code>PreparedStatementWrapper</code> object capable
334      * of returning the auto-generated keys designated by the given array. This
335      * array contains the names of the columns in the target table that contain
336      * the auto-generated keys that should be returned. This array is ignored if
337      * the SQL statement is not an <code>INSERT</code> statement.
338      * <P>
339      * An SQL statement with or without IN parameters can be pre-compiled and
340      * stored in a <code>PreparedStatement</code> object. This object can then
341      * be used to efficiently execute this statement multiple times.
342      * @param user the user used for accessing the connection
343      * @param sql an SQL statement that may contain one or more '?' IN parameter
344      * placeholders
345      * @param columnNames an array of column names indicating the columns that
346      * should be returned from the inserted row or rows
347      * @param trace the logger to use for logging purpose
348      * @param isDebugLogging if true, log the debug event in the logger
349      * @since JDK 1.4
350      */

351     public PreparedStatementWrapper(final String JavaDoc user, final String JavaDoc sql, final String JavaDoc[] columnNames, final Logger trace, final boolean isDebugLogging) {
352         this(user, sql, -1, -1, -1, -1, null, columnNames, trace, isDebugLogging);
353     }
354
355     /**
356      * Checks that this object is not in invalid state
357      * @throws SQLException if object is in invalid mode
358      */

359     public void checkIfValid() throws SQLException JavaDoc {
360         if (invalid) {
361             SQLException JavaDoc se = new SQLException JavaDoc("PreparedStatement(" + this + ") is invalid.");
362             trace.log(BasicLevel.ERROR, se);
363             throw se;
364         }
365
366     }
367
368     /**
369      * Clears the values stored in the preparement. This is required as this
370      * preparedstatement is reused
371      */

372     public void clearPstmtValues() {
373         closed = false;
374         try {
375             pstmt.clearParameters();
376             pstmt.clearBatch();
377         } catch (Throwable JavaDoc ex) {
378             if (isDebugLogging) {
379                 trace.log(BasicLevel.DEBUG, "Cannot clear parameters", ex);
380             }
381         }
382         if (setEscapeProcessingCalled) {
383             try {
384                 pstmt.setEscapeProcessing(true);
385                 setEscapeProcessingCalled = false;
386             } catch (Throwable JavaDoc ex) {
387                 if (isDebugLogging) {
388                     trace.log(BasicLevel.DEBUG, "Cannot reset escape processing to true", ex);
389                 }
390             }
391         }
392         if (setFetchDirectionCalled) {
393             try {
394                 pstmt.setFetchDirection(ResultSet.FETCH_FORWARD);
395                 setFetchDirectionCalled = false;
396             } catch (Throwable JavaDoc ex) {
397                 if (isDebugLogging) {
398                     trace.log(BasicLevel.DEBUG, "Cannot set fetch direction to ResultSet.FETCH_FORWARD", ex);
399                 }
400             }
401         }
402         if (setMaxFieldSizeCalled) {
403             try {
404                 pstmt.setMaxFieldSize(0);
405                 setMaxFieldSizeCalled=false;
406             } catch (Throwable JavaDoc ex) {
407                 if (isDebugLogging) {
408                     trace.log(BasicLevel.DEBUG, "Cannot set max field size to 0", ex);
409                 }
410             }
411         }
412         try {
413             pstmt.setMaxRows(0);
414         } catch (Throwable JavaDoc ex) {
415             if (isDebugLogging) {
416                 trace.log(BasicLevel.DEBUG, "Cannot set max rows to 0", ex);
417             }
418         }
419         try {
420             pstmt.setQueryTimeout(0);
421         } catch (Throwable JavaDoc ex) {
422             if (isDebugLogging) {
423                 trace.log(BasicLevel.DEBUG, "Cannot set query timeout to 0", ex);
424             }
425         }
426         try {
427             pstmt.clearWarnings();
428         } catch (Throwable JavaDoc ex) {
429             if (isDebugLogging) {
430                 trace.log(BasicLevel.DEBUG, "Cannot clear warnings", ex);
431             }
432         }
433     }
434
435     /**
436      * Close this object
437      * @throws SQLException if object cannot be closed
438      */

439     public void closePstmt() throws SQLException JavaDoc {
440         closed = true;
441         pstmt.close();
442     }
443
444     /**
445      * Destroy this preparestatement object, then it becomes closed and invalid
446      * @throws SQLException if it cannot be closed
447      */

448     public void destroy() throws SQLException JavaDoc {
449         if (isDebugLogging) {
450             trace.log(BasicLevel.DEBUG, "" + this);
451         }
452         try {
453             pstmt.close();
454         } finally {
455             invalid = true;
456             closed = true;
457         }
458     }
459
460     /**
461      * @param stmt given statement for comparing it
462      * @return true if given object is equals to this current object
463      */

464     public boolean equals(Object JavaDoc stmt) {
465         if (stmt == null) {
466             return false;
467         }
468         // different hashcode, cannot be equals
469
if (this.hashCode != stmt.hashCode()) {
470             return false;
471         }
472
473         // if got same hashcode, try to see if cast is ok.
474
if (!(stmt instanceof PreparedStatementWrapper)) {
475             return false;
476         }
477         PreparedStatementWrapper psw = (PreparedStatementWrapper) stmt;
478
479         if (invalid) {
480             if (isDebugLogging) {
481                 trace.log(BasicLevel.DEBUG, "Prepared Statement is invalid");
482             }
483             return false;
484         }
485         if (sql == null && psw.sql != null) {
486             if (isDebugLogging) {
487                 trace.log(BasicLevel.DEBUG, "Stmt sql: " + psw.sql + " not equal to " + sql);
488             }
489             return false;
490         }
491         if (sql != null && !sql.equals(psw.sql)) {
492             if (isDebugLogging) {
493                 trace.log(BasicLevel.DEBUG, "Stmt sql: " + psw.sql + " not equal to " + sql);
494             }
495             return false;
496         }
497         if (user == null && psw.user != null) {
498             if (isDebugLogging) {
499                 trace.log(BasicLevel.DEBUG, "Stmt user: " + psw.user + " not equal to " + user);
500             }
501             return false;
502         }
503         if (user != null && !user.equals(psw.user)) {
504             if (isDebugLogging) {
505                 trace.log(BasicLevel.DEBUG, "Stmt user: " + psw.user + " not equal to " + user);
506             }
507             return false;
508         }
509         if (resultSetType != psw.resultSetType) {
510             if (isDebugLogging) {
511                 trace.log(BasicLevel.DEBUG, "Stmt resultSetType: " + psw.resultSetType + " not equal to "
512                         + resultSetType);
513             }
514             return false;
515         }
516         if (resultSetConcurrency != psw.resultSetConcurrency) {
517             if (isDebugLogging) {
518                 trace.log(BasicLevel.DEBUG, "Stmt resultSetConcurrency: " + psw.resultSetConcurrency + " not equal to "
519                         + resultSetConcurrency);
520             }
521             return false;
522         }
523         if (resultSetHoldability != psw.resultSetHoldability) {
524             if (isDebugLogging) {
525                 trace.log(BasicLevel.DEBUG, "Stmt resultSetHoldability: " + psw.resultSetHoldability + " not equal to "
526                         + resultSetHoldability);
527             }
528             return false;
529         }
530         if (autoGeneratedKeys != psw.autoGeneratedKeys) {
531             if (isDebugLogging) {
532                 trace.log(BasicLevel.DEBUG, "Stmt autoGeneratedKeys: " + psw.autoGeneratedKeys + " not equal to "
533                         + autoGeneratedKeys);
534             }
535             return false;
536         }
537         if (!Arrays.equals(columnIndexes, psw.columnIndexes)) {
538             if (isDebugLogging) {
539                 trace.log(BasicLevel.DEBUG, "Stmt columnIndexes: " + psw.columnIndexes + " not equal to "
540                         + columnIndexes);
541             }
542             return false;
543         }
544         if (!Arrays.equals(columnNames, psw.columnNames)) {
545             if (isDebugLogging) {
546                 trace.log(BasicLevel.DEBUG, "Stmt columnNames: " + psw.columnNames + " not equal to " + columnNames);
547             }
548             return false;
549         }
550         if (isDebugLogging) {
551             trace.log(BasicLevel.DEBUG, "Stmt found at " + this);
552         }
553         return true;
554     }
555
556     /**
557      * Close this object
558      * @param val true/false
559      */

560     public void setClosed(boolean val) {
561         closed = val;
562     }
563
564     /**
565      * Sets the real prepared statement object on which we wrap calls
566      * @param pstmt sql preparedstatement
567      */

568     public void setPreparedStatement(PreparedStatement JavaDoc pstmt) {
569         this.pstmt = pstmt;
570     }
571
572     /***************************************************************************
573      * Prepared Statment calls
574      */

575
576     /**
577      * Adds a set of parameters to this <code>PreparedStatement</code>
578      * object's batch of commands.
579      * @exception SQLException if a database access error occurs
580      * @see Statement#addBatch
581      * @since 1.2
582      */

583     public void addBatch() throws SQLException JavaDoc {
584         checkIfValid();
585         pstmt.addBatch();
586     }
587
588     /**
589      * Clears the current parameter values immediately.
590      * <P>
591      * In general, parameter values remain in force for repeated use of a
592      * statement. Setting a parameter value automatically clears its previous
593      * value. However, in some cases it is useful to immediately release the
594      * resources used by the current parameter values; this can be done by
595      * calling the method <code>clearParameters</code>.
596      * @exception SQLException if a database access error occurs
597      */

598     public void clearParameters() throws SQLException JavaDoc {
599         checkIfValid();
600         pstmt.clearParameters();
601     }
602
603     /**
604      * Executes the SQL statement in this <code>PreparedStatement</code>
605      * object, which may be any kind of SQL statement. Some prepared statements
606      * return multiple results; the <code>execute</code> method handles these
607      * complex statements as well as the simpler form of statements handled by
608      * the methods <code>executeQuery</code> and <code>executeUpdate</code>.
609      * <P>
610      * The <code>execute</code> method returns a <code>boolean</code> to
611      * indicate the form of the first result. You must call either the method
612      * <code>getResultSet</code> or <code>getUpdateCount</code> to retrieve
613      * the result; you must call <code>getMoreResults</code> to move to any
614      * subsequent result(s).
615      * @return <code>true</code> if the first result is a
616      * <code>ResultSet</code> object; <code>false</code> if the
617      * first result is an update count or there is no result
618      * @exception SQLException if a database access error occurs or an argument
619      * is supplied to this method
620      * @see Statement#execute
621      * @see Statement#getResultSet
622      * @see Statement#getUpdateCount
623      * @see Statement#getMoreResults
624      */

625     public boolean execute() throws SQLException JavaDoc {
626         checkIfValid();
627         return pstmt.execute();
628     }
629
630     // JDK1.4
631
/**
632      * Executes the given SQL statement, which may return multiple results, and
633      * signals the driver that any auto-generated keys should be made available
634      * for retrieval. The driver will ignore this signal if the SQL statement is
635      * not an <code>INSERT</code> statement.
636      * <P>
637      * In some (uncommon) situations, a single SQL statement may return multiple
638      * result sets and/or update counts. Normally you can ignore this unless you
639      * are (1) executing a stored procedure that you know may return multiple
640      * results or (2) you are dynamically executing an unknown SQL string.
641      * <P>
642      * The <code>execute</code> method executes an SQL statement and indicates
643      * the form of the first result. You must then use the methods
644      * <code>getResultSet</code> or <code>getUpdateCount</code> to retrieve
645      * the result, and <code>getMoreResults</code> to move to any subsequent
646      * result(s).
647      * @param sql any SQL statement
648      * @param autoGeneratedKeys a constant indicating whether auto-generated
649      * keys should be made available for retrieval using the method
650      * <code>getGeneratedKeys</code>; one of the following constants:
651      * <code>Statement.RETURN_GENERATED_KEYS</code> or
652      * <code>Statement.NO_GENERATED_KEYS</code>
653      * @return <code>true</code> if the first result is a
654      * <code>ResultSet</code> object; <code>false</code> if it is an
655      * update count or there are no results
656      * @exception SQLException if a database access error occurs or the second
657      * parameter supplied to this method is not
658      * <code>Statement.RETURN_GENERATED_KEYS</code> or
659      * <code>Statement.NO_GENERATED_KEYS</code>.
660      * @see #getResultSet
661      * @see #getUpdateCount
662      * @see #getMoreResults
663      * @see #getGeneratedKeys
664      * @since 1.4
665      */

666     public boolean execute(String JavaDoc sql, int autoGeneratedKeys) throws SQLException JavaDoc {
667         checkIfValid();
668         return pstmt.execute(sql, autoGeneratedKeys);
669     }
670
671     // JDK1.4
672
/**
673      * Executes the given SQL statement, which may return multiple results, and
674      * signals the driver that the auto-generated keys indicated in the given
675      * array should be made available for retrieval. This array contains the
676      * indexes of the columns in the target table that contain the
677      * auto-generated keys that should be made available. The driver will ignore
678      * the array if the given SQL statement is not an <code>INSERT</code>
679      * statement.
680      * <P>
681      * Under some (uncommon) situations, a single SQL statement may return
682      * multiple result sets and/or update counts. Normally you can ignore this
683      * unless you are (1) executing a stored procedure that you know may return
684      * multiple results or (2) you are dynamically executing an unknown SQL
685      * string.
686      * <P>
687      * The <code>execute</code> method executes an SQL statement and indicates
688      * the form of the first result. You must then use the methods
689      * <code>getResultSet</code> or <code>getUpdateCount</code> to retrieve
690      * the result, and <code>getMoreResults</code> to move to any subsequent
691      * result(s).
692      * @param sql any SQL statement
693      * @param columnIndexes an array of the indexes of the columns in the
694      * inserted row that should be made available for retrieval by a call
695      * to the method <code>getGeneratedKeys</code>
696      * @return <code>true</code> if the first result is a
697      * <code>ResultSet</code> object; <code>false</code> if it is an
698      * update count or there are no results
699      * @exception SQLException if a database access error occurs or the elements
700      * in the <code>int</code> array passed to this method are not
701      * valid column indexes
702      * @see #getResultSet
703      * @see #getUpdateCount
704      * @see #getMoreResults
705      * @since 1.4
706      */

707     public boolean execute(String JavaDoc sql, int[] columnIndexes) throws SQLException JavaDoc {
708         checkIfValid();
709         return pstmt.execute(sql, columnIndexes);
710     }
711
712     // JDK1.4
713
/**
714      * Executes the given SQL statement, which may return multiple results, and
715      * signals the driver that the auto-generated keys indicated in the given
716      * array should be made available for retrieval. This array contains the
717      * names of the columns in the target table that contain the auto-generated
718      * keys that should be made available. The driver will ignore the array if
719      * the given SQL statement is not an <code>INSERT</code> statement.
720      * <P>
721      * In some (uncommon) situations, a single SQL statement may return multiple
722      * result sets and/or update counts. Normally you can ignore this unless you
723      * are (1) executing a stored procedure that you know may return multiple
724      * results or (2) you are dynamically executing an unknown SQL string.
725      * <P>
726      * The <code>execute</code> method executes an SQL statement and indicates
727      * the form of the first result. You must then use the methods
728      * <code>getResultSet</code> or <code>getUpdateCount</code> to retrieve
729      * the result, and <code>getMoreResults</code> to move to any subsequent
730      * result(s).
731      * @param sql any SQL statement
732      * @param columnNames an array of the names of the columns in the inserted
733      * row that should be made available for retrieval by a call to the
734      * method <code>getGeneratedKeys</code>
735      * @return <code>true</code> if the next result is a
736      * <code>ResultSet</code> object; <code>false</code> if it is an
737      * update count or there are no more results
738      * @exception SQLException if a database access error occurs or the elements
739      * of the <code>String</code> array passed to this method are
740      * not valid column names
741      * @see #getResultSet
742      * @see #getUpdateCount
743      * @see #getMoreResults
744      * @see #getGeneratedKeys
745      * @since 1.4
746      */

747     public boolean execute(String JavaDoc sql, String JavaDoc[] columnNames) throws SQLException JavaDoc {
748         checkIfValid();
749         return pstmt.execute(sql, columnNames);
750     }
751
752     /**
753      * Executes the SQL query in this <code>PreparedStatement</code> object
754      * and returns the <code>ResultSet</code> object generated by the query.
755      * @return a <code>ResultSet</code> object that contains the data produced
756      * by the query; never <code>null</code>
757      * @exception SQLException if a database access error occurs or the SQL
758      * statement does not return a <code>ResultSet</code> object
759      */

760     public ResultSet JavaDoc executeQuery() throws SQLException JavaDoc {
761         checkIfValid();
762         return pstmt.executeQuery();
763     }
764
765     /**
766      * Executes the SQL statement in this <code>PreparedStatement</code>
767      * object, which must be an SQL <code>INSERT</code>, <code>UPDATE</code>
768      * or <code>DELETE</code> statement; or an SQL statement that returns
769      * nothing, such as a DDL statement.
770      * @return either (1) the row count for <code>INSERT</code>,
771      * <code>UPDATE</code>, or <code>DELETE</code> statements or
772      * (2) 0 for SQL statements that return nothing
773      * @exception SQLException if a database access error occurs or the SQL
774      * statement returns a <code>ResultSet</code> object
775      */

776     public int executeUpdate() throws SQLException JavaDoc {
777         checkIfValid();
778         return pstmt.executeUpdate();
779     }
780
781     // JDK1.4
782
/**
783      * Executes the given SQL statement and signals the driver with the given
784      * flag about whether the auto-generated keys produced by this
785      * <code>Statement</code> object should be made available for retrieval.
786      * @param sql must be an SQL <code>INSERT</code>, <code>UPDATE</code>
787      * or <code>DELETE</code> statement or an SQL statement that
788      * returns nothing
789      * @param autoGeneratedKeys a flag indicating whether auto-generated keys
790      * should be made available for retrieval; one of the following
791      * constants: <code>Statement.RETURN_GENERATED_KEYS</code>
792      * <code>Statement.NO_GENERATED_KEYS</code>
793      * @return either the row count for <code>INSERT</code>,
794      * <code>UPDATE</code> or <code>DELETE</code> statements, or
795      * <code>0</code> for SQL statements that return nothing
796      * @exception SQLException if a database access error occurs, the given SQL
797      * statement returns a <code>ResultSet</code> object, or the
798      * given constant is not one of those allowed
799      * @since 1.4
800      */

801     public int executeUpdate(String JavaDoc sql, int autoGeneratedKeys) throws SQLException JavaDoc {
802         checkIfValid();
803         return pstmt.executeUpdate(sql, autoGeneratedKeys);
804     }
805
806     // JDK1.4
807
/**
808      * Executes the given SQL statement and signals the driver that the
809      * auto-generated keys indicated in the given array should be made available
810      * for retrieval. The driver will ignore the array if the SQL statement is
811      * not an <code>INSERT</code> statement.
812      * @param sql an SQL <code>INSERT</code>, <code>UPDATE</code> or
813      * <code>DELETE</code> statement or an SQL statement that returns
814      * nothing, such as an SQL DDL statement
815      * @param columnIndexes an array of column indexes indicating the columns
816      * that should be returned from the inserted row
817      * @return either the row count for <code>INSERT</code>,
818      * <code>UPDATE</code>, or <code>DELETE</code> statements, or 0
819      * for SQL statements that return nothing
820      * @exception SQLException if a database access error occurs, the SQL
821      * statement returns a <code>ResultSet</code> object, or the
822      * second argument supplied to this method is not an
823      * <code>int</code> array whose elements are valid column
824      * indexes
825      * @since 1.4
826      */

827     public int executeUpdate(String JavaDoc sql, int[] columnIndexes) throws SQLException JavaDoc {
828         checkIfValid();
829         return pstmt.executeUpdate(sql, columnIndexes);
830     }
831
832     // JDK1.4
833
/**
834      * Executes the given SQL statement and signals the driver that the
835      * auto-generated keys indicated in the given array should be made available
836      * for retrieval. The driver will ignore the array if the SQL statement is
837      * not an <code>INSERT</code> statement.
838      * @param sql an SQL <code>INSERT</code>, <code>UPDATE</code> or
839      * <code>DELETE</code> statement or an SQL statement that returns
840      * nothing
841      * @param columnNames an array of the names of the columns that should be
842      * returned from the inserted row
843      * @return either the row count for <code>INSERT</code>,
844      * <code>UPDATE</code>, or <code>DELETE</code> statements, or 0
845      * for SQL statements that return nothing
846      * @exception SQLException if a database access error occurs, the SQL
847      * statement returns a <code>ResultSet</code> object, or the
848      * second argument supplied to this method is not a
849      * <code>String</code> array whose elements are valid column
850      * names
851      * @since 1.4
852      */

853     public int executeUpdate(String JavaDoc sql, String JavaDoc[] columnNames) throws SQLException JavaDoc {
854         checkIfValid();
855         return pstmt.executeUpdate(sql, columnNames);
856     }
857
858     // JDK1.4
859
/**
860      * Retrieves any auto-generated keys created as a result of executing this
861      * <code>Statement</code> object. If this <code>Statement</code> object
862      * did not generate any keys, an empty <code>ResultSet</code> object is
863      * returned.
864      * @return a <code>ResultSet</code> object containing the auto-generated
865      * key(s) generated by the execution of this <code>Statement</code>
866      * object
867      * @exception SQLException if a database access error occurs
868      * @since 1.4
869      */

870     public ResultSet JavaDoc getGeneratedKeys() throws SQLException JavaDoc {
871         checkIfValid();
872         return pstmt.getGeneratedKeys();
873     }
874
875     /**
876      * Retrieves a <code>ResultSetMetaData</code> object that contains
877      * information about the columns of the <code>ResultSet</code> object that
878      * will be returned when this <code>PreparedStatement</code> object is
879      * executed.
880      * <P>
881      * Because a <code>PreparedStatement</code> object is precompiled, it is
882      * possible to know about the <code>ResultSet</code> object that it will
883      * return without having to execute it. Consequently, it is possible to
884      * invoke the method <code>getMetaData</code> on a
885      * <code>PreparedStatement</code> object rather than waiting to execute it
886      * and then invoking the <code>ResultSet.getMetaData</code> method on the
887      * <code>ResultSet</code> object that is returned.
888      * <P>
889      * <B>NOTE:</B> Using this method may be expensive for some drivers due to
890      * the lack of underlying DBMS support.
891      * @return the description of a <code>ResultSet</code> object's columns or
892      * <code>null</code> if the driver cannot return a
893      * <code>ResultSetMetaData</code> object
894      * @exception SQLException if a database access error occurs
895      * @since 1.2
896      */

897     public ResultSetMetaData JavaDoc getMetaData() throws SQLException JavaDoc {
898         checkIfValid();
899         return pstmt.getMetaData();
900     }
901
902     // JDK1.4
903
/**
904      * Moves to this <code>Statement</code> object's next result, deals with
905      * any current <code>ResultSet</code> object(s) according to the
906      * instructions specified by the given flag, and returns <code>true</code>
907      * if the next result is a <code>ResultSet</code> object.
908      * <P>
909      * There are no more results when the following is true:
910      *
911      * <PRE> // stmt is a Statement object ((stmt.getMoreResults() == false) &&
912      * (stmt.getUpdateCount() == -1))
913      *
914      * </PRE>
915      *
916      * @param current one of the following <code>Statement</code> constants
917      * indicating what should happen to current <code>ResultSet</code>
918      * objects obtained using the method <code>getResultSet</code>:
919      * <code>Statement.CLOSE_CURRENT_RESULT</code>,
920      * <code>Statement.KEEP_CURRENT_RESULT</code>, or
921      * <code>Statement.CLOSE_ALL_RESULTS</code>
922      * @return <code>true</code> if the next result is a
923      * <code>ResultSet</code> object; <code>false</code> if it is an
924      * update count or there are no more results
925      * @exception SQLException if a database access error occurs or the argument
926      * supplied is not one of the following:
927      * <code>Statement.CLOSE_CURRENT_RESULT</code>,
928      * <code>Statement.KEEP_CURRENT_RESULT</code>, or
929      * <code>Statement.CLOSE_ALL_RESULTS</code>
930      * @since 1.4
931      * @see #execute
932      */

933     public boolean getMoreResults(int current) throws SQLException JavaDoc {
934         checkIfValid();
935         return pstmt.getMoreResults(current);
936
937     }
938
939     // JDK1.4
940
/**
941      * Retrieves the number, types and properties of this
942      * <code>PreparedStatement</code> object's parameters.
943      * @return a <code>ParameterMetaData</code> object that contains
944      * information about the number, types and properties of this
945      * <code>PreparedStatement</code> object's parameters
946      * @exception SQLException if a database access error occurs
947      * @see ParameterMetaData
948      * @since 1.4
949      */

950     public ParameterMetaData JavaDoc getParameterMetaData() throws SQLException JavaDoc {
951         checkIfValid();
952         return pstmt.getParameterMetaData();
953
954     }
955
956     // JDK1.4
957
/**
958      * Retrieves the result set holdability for <code>ResultSet</code> objects
959      * generated by this <code>Statement</code> object.
960      * @return either <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
961      * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
962      * @exception SQLException if a database access error occurs
963      * @since 1.4
964      */

965     public int getResultSetHoldability() throws SQLException JavaDoc {
966         checkIfValid();
967         return pstmt.getResultSetHoldability();
968     }
969
970     /**
971      * Sets the designated parameter to the given <code>Array</code> object.
972      * The driver converts this to an SQL <code>ARRAY</code> value when it
973      * sends it to the database.
974      * @param i the first parameter is 1, the second is 2, ...
975      * @param x an <code>Array</code> object that maps an SQL
976      * <code>ARRAY</code> value
977      * @exception SQLException if a database access error occurs
978      * @since 1.2
979      */

980     public void setArray(int i, Array JavaDoc x) throws SQLException JavaDoc {
981         checkIfValid();
982         pstmt.setArray(i, x);
983     }
984
985     /**
986      * Sets the designated parameter to the given input stream, which will have
987      * the specified number of bytes. When a very large ASCII value is input to
988      * a <code>LONGVARCHAR</code> parameter, it may be more practical to send
989      * it via a <code>java.io.InputStream</code>. Data will be read from the
990      * stream as needed until end-of-file is reached. The JDBC driver will do
991      * any necessary conversion from ASCII to the database char format.
992      * <P>
993      * <B>Note:</B> This stream object can either be a standard Java stream
994      * object or your own subclass that implements the standard interface.
995      * @param parameterIndex the first parameter is 1, the second is 2, ...
996      * @param x the Java input stream that contains the ASCII parameter value
997      * @param length the number of bytes in the stream
998      * @exception SQLException if a database access error occurs
999      */

1000    public void setAsciiStream(int parameterIndex, InputStream JavaDoc x, int length) throws SQLException JavaDoc {
1001        checkIfValid();
1002        pstmt.setAsciiStream(parameterIndex, x, length);
1003
1004    }
1005
1006    /**
1007     * Sets the designated parameter to the given
1008     * <code>java.math.BigDecimal</code> value. The driver converts this to an
1009     * SQL <code>NUMERIC</code> value when it sends it to the database.
1010     * @param parameterIndex the first parameter is 1, the second is 2, ...
1011     * @param x the parameter value
1012     * @exception SQLException if a database access error occurs
1013     */

1014    public void setBigDecimal(int parameterIndex, BigDecimal JavaDoc x) throws SQLException JavaDoc {
1015        checkIfValid();
1016        pstmt.setBigDecimal(parameterIndex, x);
1017    }
1018
1019    /**
1020     * Sets the designated parameter to the given input stream, which will have
1021     * the specified number of bytes. When a very large binary value is input to
1022     * a <code>LONGVARBINARY</code> parameter, it may be more practical to
1023     * send it via a <code>java.io.InputStream</code> object. The data will be
1024     * read from the stream as needed until end-of-file is reached.
1025     * <P>
1026     * <B>Note:</B> This stream object can either be a standard Java stream
1027     * object or your own subclass that implements the standard interface.
1028     * @param parameterIndex the first parameter is 1, the second is 2, ...
1029     * @param x the java input stream which contains the binary parameter value
1030     * @param length the number of bytes in the stream
1031     * @exception SQLException if a database access error occurs
1032     */

1033    public void setBinaryStream(int parameterIndex, InputStream JavaDoc x, int length) throws SQLException JavaDoc {
1034        checkIfValid();
1035        pstmt.setBinaryStream(parameterIndex, x, length);
1036    }
1037
1038    /**
1039     * Sets the designated parameter to the given <code>Blob</code> object.
1040     * The driver converts this to an SQL <code>BLOB</code> value when it
1041     * sends it to the database.
1042     * @param i the first parameter is 1, the second is 2, ...
1043     * @param x a <code>Blob</code> object that maps an SQL <code>BLOB</code>
1044     * value
1045     * @exception SQLException if a database access error occurs
1046     * @since 1.2
1047     */

1048    public void setBlob(int i, Blob JavaDoc x) throws SQLException JavaDoc {
1049        checkIfValid();
1050        pstmt.setBlob(i, x);
1051    }
1052
1053    /**
1054     * Sets the designated parameter to the given Java <code>boolean</code>
1055     * value. The driver converts this to an SQL <code>BIT</code> value when
1056     * it sends it to the database.
1057     * @param parameterIndex the first parameter is 1, the second is 2, ...
1058     * @param x the parameter value
1059     * @exception SQLException if a database access error occurs
1060     */

1061    public void setBoolean(int parameterIndex, boolean x) throws SQLException JavaDoc {
1062        checkIfValid();
1063        pstmt.setBoolean(parameterIndex, x);
1064    }
1065
1066    /**
1067     * Sets the designated parameter to the given Java <code>byte</code>
1068     * value. The driver converts this to an SQL <code>TINYINT</code> value
1069     * when it sends it to the database.
1070     * @param parameterIndex the first parameter is 1, the second is 2, ...
1071     * @param x the parameter value
1072     * @exception SQLException if a database access error occurs
1073     */

1074    public void setByte(int parameterIndex, byte x) throws SQLException JavaDoc {
1075        checkIfValid();
1076        pstmt.setByte(parameterIndex, x);
1077    }
1078
1079    /**
1080     * Sets the designated parameter to the given Java array of bytes. The
1081     * driver converts this to an SQL <code>VARBINARY</code> or
1082     * <code>LONGVARBINARY</code> (depending on the argument's size relative
1083     * to the driver's limits on <code>VARBINARY</code> values) when it sends
1084     * it to the database.
1085     * @param parameterIndex the first parameter is 1, the second is 2, ...
1086     * @param x the parameter value
1087     * @exception SQLException if a database access error occurs
1088     */

1089    public void setBytes(int parameterIndex, byte[] x) throws SQLException JavaDoc {
1090        checkIfValid();
1091        pstmt.setBytes(parameterIndex, x);
1092    }
1093
1094    /**
1095     * Sets the designated parameter to the given <code>Reader</code> object,
1096     * which is the given number of characters long. When a very large UNICODE
1097     * value is input to a <code>LONGVARCHAR</code> parameter, it may be more
1098     * practical to send it via a <code>java.io.Reader</code> object. The data
1099     * will be read from the stream as needed until end-of-file is reached. The
1100     * JDBC driver will do any necessary conversion from UNICODE to the database
1101     * char format.
1102     * <P>
1103     * <B>Note:</B> This stream object can either be a standard Java stream
1104     * object or your own subclass that implements the standard interface.
1105     * @param parameterIndex the first parameter is 1, the second is 2, ...
1106     * @param reader the <code>java.io.Reader</code> object that contains the
1107     * Unicode data
1108     * @param length the number of characters in the stream
1109     * @exception SQLException if a database access error occurs
1110     * @since 1.2
1111     */

1112    public void setCharacterStream(int parameterIndex, Reader JavaDoc reader, int length) throws SQLException JavaDoc {
1113        checkIfValid();
1114        pstmt.setCharacterStream(parameterIndex, reader, length);
1115    }
1116
1117    /**
1118     * Sets the designated parameter to the given <code>Clob</code> object.
1119     * The driver converts this to an SQL <code>CLOB</code> value when it
1120     * sends it to the database.
1121     * @param i the first parameter is 1, the second is 2, ...
1122     * @param x a <code>Clob</code> object that maps an SQL <code>CLOB</code>
1123     * value
1124     * @exception SQLException if a database access error occurs
1125     * @since 1.2
1126     */

1127    public void setClob(int i, Clob JavaDoc x) throws SQLException JavaDoc {
1128        checkIfValid();
1129        pstmt.setClob(i, x);
1130    }
1131
1132    /**
1133     * Sets the designated parameter to the given <code>java.sql.Date</code>
1134     * value. The driver converts this to an SQL <code>DATE</code> value when
1135     * it sends it to the database.
1136     * @param parameterIndex the first parameter is 1, the second is 2, ...
1137     * @param x the parameter value
1138     * @exception SQLException if a database access error occurs
1139     */

1140    public void setDate(int parameterIndex, Date JavaDoc x) throws SQLException JavaDoc {
1141        checkIfValid();
1142        pstmt.setDate(parameterIndex, x);
1143    }
1144
1145    /**
1146     * Sets the designated parameter to the given <code>java.sql.Date</code>
1147     * value, using the given <code>Calendar</code> object. The driver uses
1148     * the <code>Calendar</code> object to construct an SQL <code>DATE</code>
1149     * value, which the driver then sends to the database. With a
1150     * <code>Calendar</code> object, the driver can calculate the date taking
1151     * into account a custom timezone. If no <code>Calendar</code> object is
1152     * specified, the driver uses the default timezone, which is that of the
1153     * virtual machine running the application.
1154     * @param parameterIndex the first parameter is 1, the second is 2, ...
1155     * @param x the parameter value
1156     * @param cal the <code>Calendar</code> object the driver will use to
1157     * construct the date
1158     * @exception SQLException if a database access error occurs
1159     * @since 1.2
1160     */

1161    public void setDate(int parameterIndex, Date JavaDoc x, Calendar JavaDoc cal) throws SQLException JavaDoc {
1162        checkIfValid();
1163        pstmt.setDate(parameterIndex, x, cal);
1164    }
1165
1166    /**
1167     * Sets the designated parameter to the given Java <code>double</code>
1168     * value. The driver converts this to an SQL <code>DOUBLE</code> value
1169     * when it sends it to the database.
1170     * @param parameterIndex the first parameter is 1, the second is 2, ...
1171     * @param x the parameter value
1172     * @exception SQLException if a database access error occurs
1173     */

1174    public void setDouble(int parameterIndex, double x) throws SQLException JavaDoc {
1175        checkIfValid();
1176        pstmt.setDouble(parameterIndex, x);
1177    }
1178
1179    /**
1180     * Sets the designated parameter to the given Java <code>float</code>
1181     * value. The driver converts this to an SQL <code>FLOAT</code> value when
1182     * it sends it to the database.
1183     * @param parameterIndex the first parameter is 1, the second is 2, ...
1184     * @param x the parameter value
1185     * @exception SQLException if a database access error occurs
1186     */

1187    public void setFloat(int parameterIndex, float x) throws SQLException JavaDoc {
1188        checkIfValid();
1189        pstmt.setFloat(parameterIndex, x);
1190    }
1191
1192    /**
1193     * Sets the designated parameter to the given Java <code>int</code> value.
1194     * The driver converts this to an SQL <code>INTEGER</code> value when it
1195     * sends it to the database.
1196     * @param parameterIndex the first parameter is 1, the second is 2, ...
1197     * @param x the parameter value
1198     * @exception SQLException if a database access error occurs
1199     */

1200    public void setInt(int parameterIndex, int x) throws SQLException JavaDoc {
1201        checkIfValid();
1202        pstmt.setInt(parameterIndex, x);
1203    }
1204
1205    /**
1206     * Sets the designated parameter to the given Java <code>long</code>
1207     * value. The driver converts this to an SQL <code>BIGINT</code> value
1208     * when it sends it to the database.
1209     * @param parameterIndex the first parameter is 1, the second is 2, ...
1210     * @param x the parameter value
1211     * @exception SQLException if a database access error occurs
1212     */

1213    public void setLong(int parameterIndex, long x) throws SQLException JavaDoc {
1214        checkIfValid();
1215        pstmt.setLong(parameterIndex, x);
1216    }
1217
1218    /**
1219     * Sets the designated parameter to SQL <code>NULL</code>.
1220     * <P>
1221     * <B>Note:</B> You must specify the parameter's SQL type.
1222     * @param parameterIndex the first parameter is 1, the second is 2, ...
1223     * @param sqlType the SQL type code defined in <code>java.sql.Types</code>
1224     * @exception SQLException if a database access error occurs
1225     */

1226    public void setNull(int parameterIndex, int sqlType) throws SQLException JavaDoc {
1227        checkIfValid();
1228        pstmt.setNull(parameterIndex, sqlType);
1229    }
1230
1231    /**
1232     * Sets the designated parameter to SQL <code>NULL</code>. This version
1233     * of the method <code>setNull</code> should be used for user-defined
1234     * types and REF type parameters. Examples of user-defined types include:
1235     * STRUCT, DISTINCT, JAVA_OBJECT, and named array types.
1236     * <P>
1237     * <B>Note:</B> To be portable, applications must give the SQL type code
1238     * and the fully-qualified SQL type name when specifying a NULL user-defined
1239     * or REF parameter. In the case of a user-defined type the name is the type
1240     * name of the parameter itself. For a REF parameter, the name is the type
1241     * name of the referenced type. If a JDBC driver does not need the type code
1242     * or type name information, it may ignore it. Although it is intended for
1243     * user-defined and Ref parameters, this method may be used to set a null
1244     * parameter of any JDBC type. If the parameter does not have a user-defined
1245     * or REF type, the given typeName is ignored.
1246     * @param paramIndex the first parameter is 1, the second is 2, ...
1247     * @param sqlType a value from <code>java.sql.Types</code>
1248     * @param typeName the fully-qualified name of an SQL user-defined type;
1249     * ignored if the parameter is not a user-defined type or REF
1250     * @exception SQLException if a database access error occurs
1251     * @since 1.2
1252     */

1253    public void setNull(int paramIndex, int sqlType, String JavaDoc typeName) throws SQLException JavaDoc {
1254        checkIfValid();
1255        pstmt.setNull(paramIndex, sqlType, typeName);
1256    }
1257
1258    /**
1259     * <p>
1260     * Sets the value of the designated parameter using the given object. The
1261     * second parameter must be of type <code>Object</code>; therefore, the
1262     * <code>java.lang</code> equivalent objects should be used for built-in
1263     * types.
1264     * <p>
1265     * The JDBC specification specifies a standard mapping from Java
1266     * <code>Object</code> types to SQL types. The given argument will be
1267     * converted to the corresponding SQL type before being sent to the
1268     * database.
1269     * <p>
1270     * Note that this method may be used to pass datatabase- specific abstract
1271     * data types, by using a driver-specific Java type. If the object is of a
1272     * class implementing the interface <code>SQLData</code>, the JDBC driver
1273     * should call the method <code>SQLData.writeSQL</code> to write it to the
1274     * SQL data stream. If, on the other hand, the object is of a class
1275     * implementing <code>Ref</code>, <code>Blob</code>, <code>Clob</code>,
1276     * <code>Struct</code>, or <code>Array</code>, the driver should pass
1277     * it to the database as a value of the corresponding SQL type.
1278     * <P>
1279     * This method throws an exception if there is an ambiguity, for example, if
1280     * the object is of a class implementing more than one of the interfaces
1281     * named above.
1282     * @param parameterIndex the first parameter is 1, the second is 2, ...
1283     * @param x the object containing the input parameter value
1284     * @exception SQLException if a database access error occurs or the type of
1285     * the given object is ambiguous
1286     */

1287    public void setObject(int parameterIndex, Object JavaDoc x) throws SQLException JavaDoc {
1288        checkIfValid();
1289        pstmt.setObject(parameterIndex, x);
1290    }
1291
1292    /**
1293     * Sets the value of the designated parameter with the given object. This
1294     * method is like the method <code>setObject</code> above, except that it
1295     * assumes a scale of zero.
1296     * @param parameterIndex the first parameter is 1, the second is 2, ...
1297     * @param x the object containing the input parameter value
1298     * @param targetSqlType the SQL type (as defined in java.sql.Types) to be
1299     * sent to the database
1300     * @exception SQLException if a database access error occurs
1301     */

1302    public void setObject(int parameterIndex, Object JavaDoc x, int targetSqlType) throws SQLException JavaDoc {
1303        checkIfValid();
1304        pstmt.setObject(parameterIndex, x, targetSqlType);
1305    }
1306
1307    /**
1308     * <p>
1309     * Sets the value of the designated parameter with the given object. The
1310     * second argument must be an object type; for integral values, the
1311     * <code>java.lang</code> equivalent objects should be used.
1312     * <p>
1313     * The given Java object will be converted to the given targetSqlType before
1314     * being sent to the database. If the object has a custom mapping (is of a
1315     * class implementing the interface <code>SQLData</code>), the JDBC
1316     * driver should call the method <code>SQLData.writeSQL</code> to write it
1317     * to the SQL data stream. If, on the other hand, the object is of a class
1318     * implementing <code>Ref</code>, <code>Blob</code>, <code>Clob</code>,
1319     * <code>Struct</code>, or <code>Array</code>, the driver should pass
1320     * it to the database as a value of the corresponding SQL type.
1321     * <p>
1322     * Note that this method may be used to pass database-specific abstract data
1323     * types.
1324     * @param parameterIndex the first parameter is 1, the second is 2, ...
1325     * @param x the object containing the input parameter value
1326     * @param targetSqlType the SQL type (as defined in java.sql.Types) to be
1327     * sent to the database. The scale argument may further qualify this
1328     * type.
1329     * @param scale for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types,
1330     * this is the number of digits after the decimal point. For all
1331     * other types, this value will be ignored.
1332     * @exception SQLException if a database access error occurs
1333     * @see Types
1334     */

1335    public void setObject(int parameterIndex, Object JavaDoc x, int targetSqlType, int scale) throws SQLException JavaDoc {
1336        checkIfValid();
1337        pstmt.setObject(parameterIndex, x, targetSqlType, scale);
1338    }
1339
1340    /**
1341     * Sets the designated parameter to the given
1342     * <code>REF(&lt;structured-type&gt;)</code> value. The driver converts
1343     * this to an SQL <code>REF</code> value when it sends it to the database.
1344     * @param i the first parameter is 1, the second is 2, ...
1345     * @param x an SQL <code>REF</code> value
1346     * @exception SQLException if a database access error occurs
1347     * @since 1.2
1348     */

1349    public void setRef(int i, Ref JavaDoc x) throws SQLException JavaDoc {
1350        checkIfValid();
1351        pstmt.setRef(i, x);
1352    }
1353
1354    /**
1355     * Sets the designated parameter to the given Java <code>short</code>
1356     * value. The driver converts this to an SQL <code>SMALLINT</code> value
1357     * when it sends it to the database.
1358     * @param parameterIndex the first parameter is 1, the second is 2, ...
1359     * @param x the parameter value
1360     * @exception SQLException if a database access error occurs
1361     */

1362    public void setShort(int parameterIndex, short x) throws SQLException JavaDoc {
1363        checkIfValid();
1364        pstmt.setShort(parameterIndex, x);
1365    }
1366
1367    /**
1368     * Sets the designated parameter to the given Java <code>String</code>
1369     * value. The driver converts this to an SQL <code>VARCHAR</code> or
1370     * <code>LONGVARCHAR</code> value (depending on the argument's size
1371     * relative to the driver's limits on <code>VARCHAR</code> values) when it
1372     * sends it to the database.
1373     * @param parameterIndex the first parameter is 1, the second is 2, ...
1374     * @param x the parameter value
1375     * @exception SQLException if a database access error occurs
1376     */

1377    public void setString(int parameterIndex, String JavaDoc x) throws SQLException JavaDoc {
1378        checkIfValid();
1379        pstmt.setString(parameterIndex, x);
1380    }
1381
1382    /**
1383     * Sets the designated parameter to the given <code>java.sql.Time</code>
1384     * value. The driver converts this to an SQL <code>TIME</code> value when
1385     * it sends it to the database.
1386     * @param parameterIndex the first parameter is 1, the second is 2, ...
1387     * @param x the parameter value
1388     * @exception SQLException if a database access error occurs
1389     */

1390    public void setTime(int parameterIndex, Time JavaDoc x) throws SQLException JavaDoc {
1391        checkIfValid();
1392        pstmt.setTime(parameterIndex, x);
1393    }
1394
1395    /**
1396     * Sets the designated parameter to the given <code>java.sql.Time</code>
1397     * value, using the given <code>Calendar</code> object. The driver uses
1398     * the <code>Calendar</code> object to construct an SQL <code>TIME</code>
1399     * value, which the driver then sends to the database. With a
1400     * <code>Calendar</code> object, the driver can calculate the time taking
1401     * into account a custom timezone. If no <code>Calendar</code> object is
1402     * specified, the driver uses the default timezone, which is that of the
1403     * virtual machine running the application.
1404     * @param parameterIndex the first parameter is 1, the second is 2, ...
1405     * @param x the parameter value
1406     * @param cal the <code>Calendar</code> object the driver will use to
1407     * construct the time
1408     * @exception SQLException if a database access error occurs
1409     * @since 1.2
1410     */

1411    public void setTime(int parameterIndex, Time JavaDoc x, Calendar JavaDoc cal) throws SQLException JavaDoc {
1412        checkIfValid();
1413        pstmt.setTime(parameterIndex, x, cal);
1414    }
1415
1416    /**
1417     * Sets the designated parameter to the given
1418     * <code>java.sql.Timestamp</code> value. The driver converts this to an
1419     * SQL <code>TIMESTAMP</code> value when it sends it to the database.
1420     * @param parameterIndex the first parameter is 1, the second is 2, ...
1421     * @param x the parameter value
1422     * @exception SQLException if a database access error occurs
1423     */

1424    public void setTimestamp(int parameterIndex, Timestamp JavaDoc x) throws SQLException JavaDoc {
1425        checkIfValid();
1426        pstmt.setTimestamp(parameterIndex, x);
1427    }
1428
1429    /**
1430     * Sets the designated parameter to the given
1431     * <code>java.sql.Timestamp</code> value, using the given
1432     * <code>Calendar</code> object. The driver uses the <code>Calendar</code>
1433     * object to construct an SQL <code>TIMESTAMP</code> value, which the
1434     * driver then sends to the database. With a <code>Calendar</code> object,
1435     * the driver can calculate the timestamp taking into account a custom
1436     * timezone. If no <code>Calendar</code> object is specified, the driver
1437     * uses the default timezone, which is that of the virtual machine running
1438     * the application.
1439     * @param parameterIndex the first parameter is 1, the second is 2, ...
1440     * @param x the parameter value
1441     * @param cal the <code>Calendar</code> object the driver will use to
1442     * construct the timestamp
1443     * @exception SQLException if a database access error occurs
1444     * @since 1.2
1445     */

1446    public void setTimestamp(int parameterIndex, Timestamp JavaDoc x, Calendar JavaDoc cal) throws SQLException JavaDoc {
1447        checkIfValid();
1448        pstmt.setTimestamp(parameterIndex, x, cal);
1449    }
1450
1451    /**
1452     * Sets the designated parameter to the given input stream, which will have
1453     * the specified number of bytes. A Unicode character has two bytes, with
1454     * the first byte being the high byte, and the second being the low byte.
1455     * When a very large Unicode value is input to a <code>LONGVARCHAR</code>
1456     * parameter, it may be more practical to send it via a
1457     * <code>java.io.InputStream</code> object. The data will be read from the
1458     * stream as needed until end-of-file is reached. The JDBC driver will do
1459     * any necessary conversion from Unicode to the database char format.
1460     * <P>
1461     * <B>Note:</B> This stream object can either be a standard Java stream
1462     * object or your own subclass that implements the standard interface.
1463     * @param parameterIndex the first parameter is 1, the second is 2, ...
1464     * @param x a <code>java.io.InputStream</code> object that contains the
1465     * Unicode parameter value as two-byte Unicode characters
1466     * @param length the number of bytes in the stream
1467     * @exception SQLException if a database access error occurs
1468     * @deprecated
1469     */

1470    public void setUnicodeStream(int parameterIndex, InputStream JavaDoc x, int length) throws SQLException JavaDoc {
1471        checkIfValid();
1472        pstmt.setUnicodeStream(parameterIndex, x, length);
1473    }
1474
1475    // Statement interface
1476

1477    /**
1478     * Adds the given SQL command to the current list of commmands for this
1479     * <code>Statement</code> object. The commands in this list can be
1480     * executed as a batch by calling the method <code>executeBatch</code>.
1481     * <P>
1482     * <B>NOTE:</B> This method is optional.
1483     * @param s typically this is a static SQL <code>INSERT</code> or
1484     * <code>UPDATE</code> statement
1485     * @exception SQLException if a database access error occurs, or the driver
1486     * does not support batch updates
1487     * @see #executeBatch
1488     * @since 1.2
1489     */

1490    public void addBatch(String JavaDoc s) throws SQLException JavaDoc {
1491        checkIfValid();
1492        pstmt.addBatch(s);
1493    }
1494
1495    /**
1496     * Cancels this <code>Statement</code> object if both the DBMS and driver
1497     * support aborting an SQL statement. This method can be used by one thread
1498     * to cancel a statement that is being executed by another thread.
1499     * @exception SQLException if a database access error occurs
1500     */

1501    public void cancel() throws SQLException JavaDoc {
1502        checkIfValid();
1503        pstmt.cancel();
1504    }
1505
1506    /**
1507     * Empties this <code>Statement</code> object's current list of SQL
1508     * commands.
1509     * <P>
1510     * <B>NOTE:</B> This method is optional.
1511     * @exception SQLException if a database access error occurs or the driver
1512     * does not support batch updates
1513     * @see #addBatch
1514     * @since 1.2
1515     */

1516    public void clearBatch() throws SQLException JavaDoc {
1517        checkIfValid();
1518        pstmt.clearBatch();
1519    }
1520
1521    /**
1522     * Clears all the warnings reported on this <code>Statement</code> object.
1523     * After a call to this method, the method <code>getWarnings</code> will
1524     * return <code>null</code> until a new warning is reported for this
1525     * <code>Statement</code> object.
1526     * @exception SQLException if a database access error occurs
1527     */

1528    public void clearWarnings() throws SQLException JavaDoc {
1529        checkIfValid();
1530        pstmt.clearWarnings();
1531    }
1532
1533    /**
1534     * Releases this <code>Statement</code> object's database and JDBC
1535     * resources immediately instead of waiting for this to happen when it is
1536     * automatically closed. It is generally good practice to release resources
1537     * as soon as you are finished with them to avoid tying up database
1538     * resources.
1539     * <P>
1540     * Calling the method <code>close</code> on a <code>Statement</code>
1541     * object that is already closed has no effect.
1542     * <P>
1543     * <B>Note:</B> A <code>Statement</code> object is automatically closed
1544     * when it is garbage collected. When a <code>Statement</code> object is
1545     * closed, its current <code>ResultSet</code> object, if one exists, is
1546     * also closed.
1547     * @exception SQLException if a database access error occurs
1548     */

1549    public void close() throws SQLException JavaDoc {
1550        if (isDebugLogging) {
1551            trace.log(BasicLevel.DEBUG, "" + this);
1552        }
1553        closed = true;
1554    }
1555
1556    /**
1557     * Executes the given SQL statement, which may return multiple results. In
1558     * some (uncommon) situations, a single SQL statement may return multiple
1559     * result sets and/or update counts. Normally you can ignore this unless you
1560     * are (1) executing a stored procedure that you know may return multiple
1561     * results or (2) you are dynamically executing an unknown SQL string.
1562     * <P>
1563     * The <code>execute</code> method executes an SQL statement and indicates
1564     * the form of the first result. You must then use the methods
1565     * <code>getResultSet</code> or <code>getUpdateCount</code> to retrieve
1566     * the result, and <code>getMoreResults</code> to move to any subsequent
1567     * result(s).
1568     * @param s any SQL statement
1569     * @return <code>true</code> if the first result is a
1570     * <code>ResultSet</code> object; <code>false</code> if it is an
1571     * update count or there are no results
1572     * @exception SQLException if a database access error occurs
1573     * @see #getResultSet
1574     * @see #getUpdateCount
1575     * @see #getMoreResults
1576     */

1577    public boolean execute(String JavaDoc s) throws SQLException JavaDoc {
1578        checkIfValid();
1579        return pstmt.execute(s);
1580    }
1581
1582    /**
1583     * Submits a batch of commands to the database for execution and if all
1584     * commands execute successfully, returns an array of update counts. The
1585     * <code>int</code> elements of the array that is returned are ordered to
1586     * correspond to the commands in the batch, which are ordered according to
1587     * the order in which they were added to the batch. The elements in the
1588     * array returned by the method <code>executeBatch</code> may be one of
1589     * the following:
1590     * <OL>
1591     * <LI>A number greater than or equal to zero -- indicates that the command
1592     * was processed successfully and is an update count giving the number of
1593     * rows in the database that were affected by the command's execution
1594     * <LI>A value of <code>SUCCESS_NO_INFO</code> -- indicates that the
1595     * command was processed successfully but that the number of rows affected
1596     * is unknown
1597     * <P>
1598     * If one of the commands in a batch update fails to execute properly, this
1599     * method throws a <code>BatchUpdateException</code>, and a JDBC driver
1600     * may or may not continue to process the remaining commands in the batch.
1601     * However, the driver's behavior must be consistent with a particular DBMS,
1602     * either always continuing to process commands or never continuing to
1603     * process commands. If the driver continues processing after a failure, the
1604     * array returned by the method
1605     * <code>BatchUpdateException.getUpdateCounts</code> will contain as many
1606     * elements as there are commands in the batch, and at least one of the
1607     * elements will be the following:
1608     * <P>
1609     * <LI>A value of <code>EXECUTE_FAILED</code> -- indicates that the
1610     * command failed to execute successfully and occurs only if a driver
1611     * continues to process commands after a command fails
1612     * </OL>
1613     * <P>
1614     * A driver is not required to implement this method. The possible
1615     * implementations and return values have been modified in the Java 2 SDK,
1616     * Standard Edition, version 1.3 to accommodate the option of continuing to
1617     * proccess commands in a batch update after a
1618     * <code>BatchUpdateException</code> obejct has been thrown.
1619     * @return an array of update counts containing one element for each command
1620     * in the batch. The elements of the array are ordered according to
1621     * the order in which commands were added to the batch.
1622     * @exception SQLException if a database access error occurs or the driver
1623     * does not support batch statements. Throws
1624     * {@link BatchUpdateException} (a subclass of
1625     * <code>SQLException</code>) if one of the commands sent to
1626     * the database fails to execute properly or attempts to return a
1627     * result set.
1628     * @since 1.3
1629     */

1630    public int[] executeBatch() throws SQLException JavaDoc {
1631        checkIfValid();
1632        return pstmt.executeBatch();
1633    }
1634
1635    /**
1636     * Executes the given SQL statement, which returns a single
1637     * <code>ResultSet</code> object.
1638     * @param s an SQL statement to be sent to the database, typically a static
1639     * SQL <code>SELECT</code> statement
1640     * @return a <code>ResultSet</code> object that contains the data produced
1641     * by the given query; never <code>null</code>
1642     * @exception SQLException if a database access error occurs or the given
1643     * SQL statement produces anything other than a single
1644     * <code>ResultSet</code> object
1645     */

1646    public ResultSet JavaDoc executeQuery(String JavaDoc s) throws SQLException JavaDoc {
1647        checkIfValid();
1648        return pstmt.executeQuery(s);
1649    }
1650
1651    /**
1652     * Executes the given SQL statement, which may be an <code>INSERT</code>,
1653     * <code>UPDATE</code>, or <code>DELETE</code> statement or an SQL
1654     * statement that returns nothing, such as an SQL DDL statement.
1655     * @param s an SQL <code>INSERT</code>, <code>UPDATE</code> or
1656     * <code>DELETE</code> statement or an SQL statement that returns
1657     * nothing
1658     * @return either the row count for <code>INSERT</code>,
1659     * <code>UPDATE</code> or <code>DELETE</code> statements, or
1660     * <code>0</code> for SQL statements that return nothing
1661     * @exception SQLException if a database access error occurs or the given
1662     * SQL statement produces a <code>ResultSet</code> object
1663     */

1664    public int executeUpdate(String JavaDoc s) throws SQLException JavaDoc {
1665        checkIfValid();
1666        return pstmt.executeUpdate(s);
1667    }
1668
1669    /**
1670     * Retrieves the <code>Connection</code> object that produced this
1671     * <code>Statement</code> object.
1672     * @return the connection that produced this statement
1673     * @exception SQLException if a database access error occurs
1674     * @since 1.2
1675     */

1676    public Connection JavaDoc getConnection() throws SQLException JavaDoc {
1677        checkIfValid();
1678        return pstmt.getConnection();
1679    }
1680
1681    /**
1682     * Retrieves the direction for fetching rows from database tables that is
1683     * the default for result sets generated from this <code>Statement</code>
1684     * object. If this <code>Statement</code> object has not set a fetch
1685     * direction by calling the method <code>setFetchDirection</code>, the
1686     * return value is implementation-specific.
1687     * @return the default fetch direction for result sets generated from this
1688     * <code>Statement</code> object
1689     * @exception SQLException if a database access error occurs
1690     * @since 1.2
1691     * @see #setFetchDirection
1692     */

1693    public int getFetchDirection() throws SQLException JavaDoc {
1694        checkIfValid();
1695        return pstmt.getFetchDirection();
1696    }
1697
1698    /**
1699     * Retrieves the number of result set rows that is the default fetch size
1700     * for <code>ResultSet</code> objects generated from this
1701     * <code>Statement</code> object. If this <code>Statement</code> object
1702     * has not set a fetch size by calling the method <code>setFetchSize</code>,
1703     * the return value is implementation-specific.
1704     * @return the default fetch size for result sets generated from this
1705     * <code>Statement</code> object
1706     * @exception SQLException if a database access error occurs
1707     * @since 1.2
1708     * @see #setFetchSize
1709     */

1710    public int getFetchSize() throws SQLException JavaDoc {
1711        checkIfValid();
1712        return pstmt.getFetchSize();
1713    }
1714
1715    /**
1716     * Retrieves the maximum number of bytes that can be returned for character
1717     * and binary column values in a <code>ResultSet</code> object produced by
1718     * this <code>Statement</code> object. This limit applies only to
1719     * <code>BINARY</code>, <code>VARBINARY</code>,
1720     * <code>LONGVARBINARY</code>, <code>CHAR</code>, <code>VARCHAR</code>,
1721     * and <code>LONGVARCHAR</code> columns. If the limit is exceeded, the
1722     * excess data is silently discarded.
1723     * @return the current column size limit for columns storing character and
1724     * binary values; zero means there is no limit
1725     * @exception SQLException if a database access error occurs
1726     * @see #setMaxFieldSize
1727     */

1728    public int getMaxFieldSize() throws SQLException JavaDoc {
1729        checkIfValid();
1730        return pstmt.getMaxFieldSize();
1731    }
1732
1733    /**
1734     * Retrieves the maximum number of rows that a <code>ResultSet</code>
1735     * object produced by this <code>Statement</code> object can contain. If
1736     * this limit is exceeded, the excess rows are silently dropped.
1737     * @return the current maximum number of rows for a <code>ResultSet</code>
1738     * object produced by this <code>Statement</code> object; zero
1739     * means there is no limit
1740     * @exception SQLException if a database access error occurs
1741     * @see #setMaxRows
1742     */

1743    public int getMaxRows() throws SQLException JavaDoc {
1744        checkIfValid();
1745        return pstmt.getMaxRows();
1746    }
1747
1748    /**
1749     * Moves to this <code>Statement</code> object's next result, returns
1750     * <code>true</code> if it is a <code>ResultSet</code> object, and
1751     * implicitly closes any current <code>ResultSet</code> object(s) obtained
1752     * with the method <code>getResultSet</code>.
1753     * <P>
1754     * There are no more results when the following is true:
1755     *
1756     * <PRE> // stmt is a Statement object ((stmt.getMoreResults() == false) &&
1757     * (stmt.getUpdateCount() == -1))
1758     *
1759     * </PRE>
1760     *
1761     * @return <code>true</code> if the next result is a
1762     * <code>ResultSet</code> object; <code>false</code> if it is an
1763     * update count or there are no more results
1764     * @exception SQLException if a database access error occurs
1765     * @see #execute
1766     */

1767    public boolean getMoreResults() throws SQLException JavaDoc {
1768        checkIfValid();
1769        return pstmt.getMoreResults();
1770    }
1771
1772    /**
1773     * Retrieves the number of seconds the driver will wait for a
1774     * <code>Statement</code> object to execute. If the limit is exceeded, a
1775     * <code>SQLException</code> is thrown.
1776     * @return the current query timeout limit in seconds; zero means there is
1777     * no limit
1778     * @exception SQLException if a database access error occurs
1779     * @see #setQueryTimeout
1780     */

1781    public int getQueryTimeout() throws SQLException JavaDoc {
1782        checkIfValid();
1783        return pstmt.getQueryTimeout();
1784    }
1785
1786    /**
1787     * Retrieves the current result as a <code>ResultSet</code> object. This
1788     * method should be called only once per result.
1789     * @return the current result as a <code>ResultSet</code> object or
1790     * <code>null</code> if the result is an update count or there are
1791     * no more results
1792     * @exception SQLException if a database access error occurs
1793     * @see #execute
1794     */

1795    public ResultSet JavaDoc getResultSet() throws SQLException JavaDoc {
1796        checkIfValid();
1797        return pstmt.getResultSet();
1798    }
1799
1800    /**
1801     * Retrieves the result set concurrency for <code>ResultSet</code> objects
1802     * generated by this <code>Statement</code> object.
1803     * @return either <code>ResultSet.CONCUR_READ_ONLY</code> or
1804     * <code>ResultSet.CONCUR_UPDATABLE</code>
1805     * @exception SQLException if a database access error occurs
1806     * @since 1.2
1807     */

1808    public int getResultSetConcurrency() throws SQLException JavaDoc {
1809        checkIfValid();
1810        return pstmt.getResultSetConcurrency();
1811    }
1812
1813    /**
1814     * Retrieves the result set type for <code>ResultSet</code> objects
1815     * generated by this <code>Statement</code> object.
1816     * @return one of <code>ResultSet.TYPE_FORWARD_ONLY</code>,
1817     * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
1818     * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
1819     * @exception SQLException if a database access error occurs
1820     * @since 1.2
1821     */

1822    public int getResultSetType() throws SQLException JavaDoc {
1823        checkIfValid();
1824        return pstmt.getResultSetType();
1825    }
1826
1827    /**
1828     * Retrieves the current result as an update count; if the result is a
1829     * <code>ResultSet</code> object or there are no more results, -1 is
1830     * returned. This method should be called only once per result.
1831     * @return the current result as an update count; -1 if the current result
1832     * is a <code>ResultSet</code> object or there are no more results
1833     * @exception SQLException if a database access error occurs
1834     * @see #execute
1835     */

1836    public int getUpdateCount() throws SQLException JavaDoc {
1837        checkIfValid();
1838        return pstmt.getUpdateCount();
1839    }
1840
1841    /**
1842     * Retrieves the first warning reported by calls on this
1843     * <code>Statement</code> object. Subsequent <code>Statement</code>
1844     * object warnings will be chained to this <code>SQLWarning</code> object.
1845     * <p>
1846     * The warning chain is automatically cleared each time a statement is
1847     * (re)executed. This method may not be called on a closed
1848     * <code>Statement</code> object; doing so will cause an
1849     * <code>SQLException</code> to be thrown.
1850     * <P>
1851     * <B>Note:</B> If you are processing a <code>ResultSet</code> object,
1852     * any warnings associated with reads on that <code>ResultSet</code>
1853     * object will be chained on it rather than on the <code>Statement</code>
1854     * object that produced it.
1855     * @return the first <code>SQLWarning</code> object or <code>null</code>
1856     * if there are no warnings
1857     * @exception SQLException if a database access error occurs or this method
1858     * is called on a closed statement
1859     */

1860    public SQLWarning JavaDoc getWarnings() throws SQLException JavaDoc {
1861        checkIfValid();
1862        return pstmt.getWarnings();
1863    }
1864
1865    /**
1866     * Sets the SQL cursor name to the given <code>String</code>, which will
1867     * be used by subsequent <code>Statement</code> object
1868     * <code>execute</code> methods. This name can then be used in SQL
1869     * positioned update or delete statements to identify the current row in the
1870     * <code>ResultSet</code> object generated by this statement. If the
1871     * database does not support positioned update/delete, this method is a
1872     * noop. To insure that a cursor has the proper isolation level to support
1873     * updates, the cursor's <code>SELECT</code> statement should have the
1874     * form <code>SELECT FOR UPDATE</code>. If <code>FOR UPDATE</code> is
1875     * not present, positioned updates may fail.
1876     * <P>
1877     * <B>Note:</B> By definition, the execution of positioned updates and
1878     * deletes must be done by a different <code>Statement</code> object than
1879     * the one that generated the <code>ResultSet</code> object being used for
1880     * positioning. Also, cursor names must be unique within a connection.
1881     * @param name the new cursor name, which must be unique within a connection
1882     * @exception SQLException if a database access error occurs
1883     */

1884    public void setCursorName(String JavaDoc name) throws SQLException JavaDoc {
1885        checkIfValid();
1886        pstmt.setCursorName(name);
1887    }
1888
1889    /**
1890     * Sets escape processing on or off. If escape scanning is on (the default),
1891     * the driver will do escape substitution before sending the SQL statement
1892     * to the database. Note: Since prepared statements have usually been parsed
1893     * prior to making this call, disabling escape processing for
1894     * <code>PreparedStatements</code> objects will have no effect.
1895     * @param enable <code>true</code> to enable escape processing;
1896     * <code>false</code> to disable it
1897     * @exception SQLException if a database access error occurs
1898     */

1899    public void setEscapeProcessing(boolean enable) throws SQLException JavaDoc {
1900        checkIfValid();
1901        // mark this method as called (even if it doesn't succeed)
1902
setEscapeProcessingCalled = true;
1903        pstmt.setEscapeProcessing(enable);
1904    }
1905
1906    /**
1907     * Gives the driver a hint as to the direction in which rows will be
1908     * processed in <code>ResultSet</code> objects created using this
1909     * <code>Statement</code> object. The default value is
1910     * <code>ResultSet.FETCH_FORWARD</code>.
1911     * <P>
1912     * Note that this method sets the default fetch direction for result sets
1913     * generated by this <code>Statement</code> object. Each result set has
1914     * its own methods for getting and setting its own fetch direction.
1915     * @param direction the initial direction for processing rows
1916     * @exception SQLException if a database access error occurs or the given
1917     * direction is not one of <code>ResultSet.FETCH_FORWARD</code>,
1918     * <code>ResultSet.FETCH_REVERSE</code>, or
1919     * <code>ResultSet.FETCH_UNKNOWN</code>
1920     * @since 1.2
1921     * @see #getFetchDirection
1922     */

1923    public void setFetchDirection(int direction) throws SQLException JavaDoc {
1924        checkIfValid();
1925        // mark this method as called (even if it doesn't succeed)
1926
setFetchDirectionCalled = true;
1927        pstmt.setFetchDirection(direction);
1928    }
1929
1930    /**
1931     * Gives the JDBC driver a hint as to the number of rows that should be
1932     * fetched from the database when more rows are needed. The number of rows
1933     * specified affects only result sets created using this statement. If the
1934     * value specified is zero, then the hint is ignored. The default value is
1935     * zero.
1936     * @param rows the number of rows to fetch
1937     * @exception SQLException if a database access error occurs, or the
1938     * condition 0 <= <code>rows</code> <=
1939     * <code>this.getMaxRows()</code> is not satisfied.
1940     * @since 1.2
1941     * @see #getFetchSize
1942     */

1943    public void setFetchSize(int rows) throws SQLException JavaDoc {
1944        checkIfValid();
1945        pstmt.setFetchSize(rows);
1946    }
1947
1948    /**
1949     * Sets the limit for the maximum number of bytes in a
1950     * <code>ResultSet</code> column storing character or binary values to the
1951     * given number of bytes. This limit applies only to <code>BINARY</code>,
1952     * <code>VARBINARY</code>, <code>LONGVARBINARY</code>,
1953     * <code>CHAR</code>, <code>VARCHAR</code>, and
1954     * <code>LONGVARCHAR</code> fields. If the limit is exceeded, the excess
1955     * data is silently discarded. For maximum portability, use values greater
1956     * than 256.
1957     * @param max the new column size limit in bytes; zero means there is no
1958     * limit
1959     * @exception SQLException if a database access error occurs or the
1960     * condition max >= 0 is not satisfied
1961     * @see #getMaxFieldSize
1962     */

1963    public void setMaxFieldSize(int max) throws SQLException JavaDoc {
1964        checkIfValid();
1965        // mark this method as called (even if it doesn't succeed)
1966
setMaxFieldSizeCalled = true;
1967        pstmt.setMaxFieldSize(max);
1968    }
1969
1970    /**
1971     * Sets the limit for the maximum number of rows that any
1972     * <code>ResultSet</code> object can contain to the given number. If the
1973     * limit is exceeded, the excess rows are silently dropped.
1974     * @param max the new max rows limit; zero means there is no limit
1975     * @exception SQLException if a database access error occurs or the
1976     * condition max >= 0 is not satisfied
1977     * @see #getMaxRows
1978     */

1979    public void setMaxRows(int max) throws SQLException JavaDoc {
1980        checkIfValid();
1981        pstmt.setMaxRows(max);
1982    }
1983
1984    /**
1985     * Sets the number of seconds the driver will wait for a
1986     * <code>Statement</code> object to execute to the given number of
1987     * seconds. If the limit is exceeded, an <code>SQLException</code> is
1988     * thrown.
1989     * @param seconds the new query timeout limit in seconds; zero means there
1990     * is no limit
1991     * @exception SQLException if a database access error occurs or the
1992     * condition seconds >= 0 is not satisfied
1993     * @see #getQueryTimeout
1994     */

1995    public void setQueryTimeout(int seconds) throws SQLException JavaDoc {
1996        checkIfValid();
1997        pstmt.setQueryTimeout(seconds);
1998    }
1999
2000    // JDK1.4
2001
/**
2002     * Sets the designated parameter to the given <code>java.net.URL</code>
2003     * value. The driver converts this to an SQL <code>DATALINK</code> value
2004     * when it sends it to the database.
2005     * @param parameterIndex the first parameter is 1, the second is 2, ...
2006     * @param x the <code>java.net.URL</code> object to be set
2007     * @exception SQLException if a database access error occurs
2008     * @since 1.4
2009     */

2010    public void setURL(int parameterIndex, URL JavaDoc x) throws SQLException JavaDoc {
2011        checkIfValid();
2012        pstmt.setURL(parameterIndex, x);
2013    }
2014
2015    /**
2016     * @return hashcode of the object
2017     */

2018    public int hashCode() {
2019        return hashCode;
2020    }
2021
2022    /**
2023     * @return true if statement has been closed
2024     */

2025    public boolean isClosed() {
2026        return closed;
2027    }
2028
2029}
2030
Popular Tags