KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quadcap > jdbc > Statement


1 package com.quadcap.jdbc;
2
3 /* Copyright 1999 - 2003 Quadcap Software. All rights reserved.
4  *
5  * This software is distributed under the Quadcap Free Software License.
6  * This software may be used or modified for any purpose, personal or
7  * commercial. Open Source redistributions are permitted. Commercial
8  * redistribution of larger works derived from, or works which bundle
9  * this software requires a "Commercial Redistribution License"; see
10  * http://www.quadcap.com/purchase.
11  *
12  * Redistributions qualify as "Open Source" under one of the following terms:
13  *
14  * Redistributions are made at no charge beyond the reasonable cost of
15  * materials and delivery.
16  *
17  * Redistributions are accompanied by a copy of the Source Code or by an
18  * irrevocable offer to provide a copy of the Source Code for up to three
19  * years at the cost of materials and delivery. Such redistributions
20  * must allow further use, modification, and redistribution of the Source
21  * Code under substantially the same terms as this license.
22  *
23  * Redistributions of source code must retain the copyright notices as they
24  * appear in each source code file, these license terms, and the
25  * disclaimer/limitation of liability set forth as paragraph 6 below.
26  *
27  * Redistributions in binary form must reproduce this Copyright Notice,
28  * these license terms, and the disclaimer/limitation of liability set
29  * forth as paragraph 6 below, in the documentation and/or other materials
30  * provided with the distribution.
31  *
32  * The Software is provided on an "AS IS" basis. No warranty is
33  * provided that the Software is free of defects, or fit for a
34  * particular purpose.
35  *
36  * Limitation of Liability. Quadcap Software shall not be liable
37  * for any damages suffered by the Licensee or any third party resulting
38  * from use of the Software.
39  */

40
41 import java.io.IOException JavaDoc;
42
43 import java.sql.SQLException JavaDoc;
44 import java.sql.SQLWarning JavaDoc;
45
46 import antlr.RecognitionException;
47 import antlr.TokenStreamException;
48
49 import com.quadcap.sql.Database;
50 import com.quadcap.sql.Session;
51 import com.quadcap.sql.SQLParser;
52 import com.quadcap.sql.Stmt;
53
54 import com.quadcap.util.ConfigNumber;
55 import com.quadcap.util.Debug;
56 import com.quadcap.util.Util;
57
58 /**
59  * This class implements the <code>java.sql.Statement</code> interface, which
60  * provides facilities for executing SQL statements on a database
61  * connection, as part of that connection's transaction.
62  *
63  * TODO: setMaxFieldSize
64  * TODO: setQueryTimeout
65  * TODO: JDBC3.0: return generated keys
66  *
67  * @author Stan Bailes
68  */

69 public class Statement implements java.sql.Statement JavaDoc {
70     /*{com.quadcap.qed.Trace-vars.xml-1054}
71      * <config-var>
72      * <config-name>qed.trace.Statement</config-name>
73      * <config-dflt>0</config-dflt>
74      * <config-desc>
75      * <pre>
76      * bit 0: statement lifecycle
77      * bit 1: statement execution
78      * bit 2: statement + result
79      * bit 4: params in prepared statements
80      * </pre>
81      * </config-desc>
82      * </config-var>
83      */

84     static final ConfigNumber trace =
85     ConfigNumber.find("qed.trace.Statement", "0");
86
87     Connection conn;
88     com.quadcap.sql.Connection qConn = null;
89     Session session = null;
90     ResultSet rs = null;
91     int updateCount = -1;
92     protected boolean escapeProcessing = true;
93     int maxRows = -1;
94
95     /**
96      * Create a new statement
97      */

98     public Statement(Connection conn) throws SQLException JavaDoc, IOException JavaDoc {
99     this.conn = conn;
100     this.qConn = conn.getConnection();
101         this.session = qConn.createSession();
102         //#ifdef DEBUG
103
if (trace.bit(0)) {
104             Debug.println(toString() + " created");
105         }
106         //#endif
107
}
108
109     /**
110      * Create a new Statement with the specified result set type and
111      * concurrency.
112      */

113     public Statement(Connection conn, int resultSetType,
114              int resultSetConcurrency)
115         throws SQLException JavaDoc, IOException JavaDoc
116     {
117     this(conn);
118     this.resultSetType = resultSetType;
119     this.resultSetConcurrency = resultSetConcurrency;
120     }
121
122     /**
123      * My short life is ended
124      */

125     public void finalize() throws Throwable JavaDoc {
126         try {
127             close();
128         } catch (Throwable JavaDoc t) {}
129         super.finalize();
130     }
131     
132     /**
133      * This QED release doesn't support batch statement execution.
134      *
135      * @exception SQLException "not implemented"
136      */

137     public void addBatch(String JavaDoc sql) throws SQLException JavaDoc {
138     throw new SQLException JavaDoc("not implemented", "0A000");
139     }
140     
141     /**
142      * QED does not support the <code>cancel()</code> feature.
143      */

144     public void cancel() throws SQLException JavaDoc {
145     }
146     
147     /**
148      * This QED release doesn't support batch statement execution.
149      *
150      * @exception SQLException "not implemented"
151      */

152     public void clearBatch() throws SQLException JavaDoc {
153     throw new SQLException JavaDoc("not implemented", "0A000");
154     }
155     
156     /**
157      * Clear any warnings associated with this <code>Statement</code>
158      * object. Since this QED release doesn't generate
159      * <code>SQLWarning</code>s, this function does nothing.
160      */

161     public void clearWarnings() {
162     }
163     
164     /**
165      * Close this statement object and free up any resources held by it.
166      */

167     public void close() {
168     //#ifdef DEBUG
169
if (trace.bit(0)) {
170         Debug.println(toString() + ".close()");
171     }
172     //#endif
173
if (session != null) {
174             try {
175                 session.close();
176             } catch (SQLException JavaDoc e) {
177             } catch (IOException JavaDoc e) {
178             } finally {
179                 session = null;
180                 qConn = null;
181             }
182         }
183     }
184
185     //#ifdef DEBUG
186
public String JavaDoc toString() {
187         return "Statement[" + session == null ? "" : session.toString() + "]";
188     }
189     //#endif
190

191     /**
192      * Execute the specified SQL statement, returning <code>true</code>
193      * if the statement generates a <code>ResultSet</code> object.
194      *
195      * @param sql an SQL statement
196      * @return true if execution of the statement results in the creation
197      * of a <code>ResultSet</code>
198      * @see #getResultSet()
199      * @exception SQLException may be thrown
200      */

201     public boolean execute(String JavaDoc sql) throws SQLException JavaDoc {
202     //#ifdef DEBUG
203
if (trace.bit(1)) {
204         Debug.println(toString() + ".execute(" + sql + ")");
205     }
206     //#endif
207
if (this.qConn == null || this.qConn.isClosed()) {
208             throw new SQLException JavaDoc("Connection closed");
209         }
210
211     if (this.rs != null) {
212         this.rs.close();
213             this.rs = null;
214         }
215     this.updateCount = -1;
216
217         session.makeTransaction();
218     SQLParser p = new SQLParser(session, sql, escapeProcessing);
219     String JavaDoc auth = qConn.getAuth();
220         //#ifdef DEBUG
221
String JavaDoc res = "";
222         //#endif
223
try {
224         try {
225         Stmt s = p.statement();
226         if (s == null) {
227             throw new SQLException JavaDoc("Parse error", "42000");
228         }
229         session.doStatement(s);
230         this.rs = (ResultSet)session.getResultSet(this);
231         if (rs != null) {
232                     //#ifdef DEBUG
233
res = "true";
234                     //#endif
235
return true;
236         } else {
237             this.updateCount = session.getUpdateCount();
238                     //#ifdef DEBUG
239
res = String.valueOf(updateCount);
240                     //#endif
241
return false;
242         }
243         } catch (IOException JavaDoc e) {
244                 //#ifdef DEBUG
245
res = e.toString();
246                 //#endif
247
Debug.print(e);
248         session.endStatement(true);
249         throw new SQLException JavaDoc(e.toString(), "Q0012");
250         } catch (RecognitionException e) {
251                 //#ifdef DEBUG
252
Debug.print(e);
253                 Debug.println("SQL: " + sql);
254                 res = e.toString();
255                 //#endif
256
session.endStatement(true);
257         SQLException JavaDoc se = new SQLException JavaDoc("Statment: " + sql);
258         SQLException JavaDoc s2 = new SQLException JavaDoc(e.toString(), "42000");
259         s2.setNextException(se);
260         throw s2;
261         } catch (TokenStreamException e) {
262                 //#ifdef DEBUG
263
res = e.toString();
264                 //#endif
265
session.endStatement(true);
266         SQLException JavaDoc se = new SQLException JavaDoc("Statment: " + sql);
267         SQLException JavaDoc s2 = new SQLException JavaDoc(e.toString(), "42000");
268         s2.setNextException(se);
269         throw s2;
270         } catch (SQLException JavaDoc e) {
271                 //#ifdef DEBUG
272
res = e.toString();
273                 //#endif
274
session.endStatement(true);
275         throw e;
276         } catch (Throwable JavaDoc e) {
277                 //#ifdef DEBUG
278
res = e.toString();
279         Debug.println("Throwable: " + e);
280         Debug.print(e);
281                 //#endif
282
session.endStatement(true);
283         throw new SQLException JavaDoc(e.toString(), "Q0013");
284         }
285     } catch (IOException JavaDoc e) {
286         Debug.print(e);
287         throw new SQLException JavaDoc(e.toString(), "Q0014");
288     } finally {
289         // XXX restore auth in case of createSchema
290
// This is a hack. 'create schema' will temporarily set the
291
// 'auth' to the schema name, and this is the first place where
292
// we get a chance to restore the correct auth.
293
//
294
// This is made worse by the fact that names are resolved during
295
// the parse phase, and could be made better if antlr parser
296
// rules allowed you to specify a 'finally' handler.
297

298         // Also 'create schema' where the schema name is a parameter is
299
// going to fail badly.
300
session.getConnection().setAuth(auth, null);
301             //#ifdef DEBUG
302
if (trace.bit(2)) {
303                 Debug.println("Statement.execute(" + sql + ") = " + res);
304             }
305             //#endif
306
}
307     }
308     
309     /**
310      * This QED release doesn't support batch statement execution.
311      *
312      * @exception SQLException "not implemented"
313      */

314     public int[] executeBatch() throws SQLException JavaDoc {
315     throw new SQLException JavaDoc("not implemented", "0A000");
316     }
317
318     
319     /**
320      * Execute the specified SQL query statement, returning the
321      * <code>ResultSet</code> object containing the results of the
322      * query.
323      *
324      * @param sql an SQL query statement
325      * @return a <code>ResultSet</code> object containing the results of
326      * the query
327      * @exception SQLException may be thrown
328      */

329     public java.sql.ResultSet JavaDoc executeQuery(String JavaDoc sql) throws SQLException JavaDoc {
330     if (execute(sql)) {
331         return this.rs;
332     } else {
333         return null;
334     }
335     }
336
337     /**
338      * Execute the specified SQL update statement, returning the update
339      * count, meaning the number of rows updated or inserted by this
340      * statement.
341      *
342      * @param sql an SQL update statement
343      * @return the update count
344      * @exception SQLException may be thrown
345      */

346     public int executeUpdate(String JavaDoc sql) throws SQLException JavaDoc {
347     if (!execute(sql)) {
348         return this.updateCount;
349     } else {
350         return 0;
351     }
352     }
353     
354     /**
355      * Return the <code>Connection</code> object used to create this
356      * <code>Statement</code> object.
357      *
358      * @return this statement's connection.
359      */

360     public java.sql.Connection JavaDoc getConnection() {
361     return conn;
362     }
363     
364     /**
365      * In QED, the fetch size is always 1.
366      *
367      * @return one
368      */

369     public int getFetchSize() {
370     return 1;
371     }
372     
373     /**
374      * QED imposes no maximum field size.
375      *
376      * @return zero, meaning unlimited
377      */

378     public int getMaxFieldSize() {
379     return 0;
380     }
381     
382     /**
383      * QED imposes no limit on the number of rows in a <code>ResultSet</code>.
384      *
385      * @return zero, meaning unlimited
386      */

387     public int getMaxRows() {
388     return 0;
389     }
390     
391     /**
392      * QED only returns one <code>ResultSet</code> per statement, so
393      * this function always returns <code>false</code> (after closing
394      * the current <code>ResultSet</code> object for this
395      * <code>Statement</code>.
396      *
397      * @return false
398      * @exception SQLException may be thrown
399      */

400     public boolean getMoreResults() throws SQLException JavaDoc {
401     if (rs != null) rs.close();
402     this.updateCount = -1;
403     return false;
404     }
405     
406     /**
407      * QED doesn't support query timeouts, so this method always returns
408      * zero.
409      *
410      * @return zero, meaning unlimited
411      */

412     public int getQueryTimeout() {
413     return 0;
414     }
415     
416     /**
417      * Return the <code>ResultSet</code> generated by the last call to
418      * <code>execute()</code>, unless that <code>ResultSet</code> has
419      * been closed, or if there was no <code>ResultSet</code> generated
420      * by the last call to <code>execute()</code>, in which case, return
421      * <code>null</code>.
422      *
423      * @return the current <code>ResultSet</code>
424      *
425      */

426     public java.sql.ResultSet JavaDoc getResultSet() {
427     return rs;
428     }
429
430     /**
431      * Return the update count for the last statement executed. If no
432      * records were updated, inserted, or deleted, return -1.
433      *
434      * @return the update count for the last <code>execute()</code>
435      * operation
436      */

437     public int getUpdateCount() {
438     return updateCount;
439     }
440     
441     /**
442      * Since this QED release doesn't generate
443      * <code>SQLWarning</code>s, this function always returns null.
444      *
445      * @return null
446      */

447     public SQLWarning JavaDoc getWarnings() {
448     return null;
449     }
450     
451     /**
452      * This QED release doesn't support SQL named cursors
453      *
454      * @exception SQLException "not implemented"
455      */

456     public void setCursorName(String JavaDoc name) throws SQLException JavaDoc {
457     throw new SQLException JavaDoc("not implemented", "0A000");
458     }
459     
460     /**
461      * Enable or disable JDBC escape processing mode.
462      *
463      * @boolean enable <code>true</code> is the driver should perform
464      * JDBC escape processing on statement execution.
465      */

466     public void setEscapeProcessing(boolean enable) {
467     escapeProcessing = enable;
468     }
469     
470     /**
471      * Set the default fetch direction for <code>ResultSet</code> objects
472      * generated by this <code>Statement</code> object.
473      */

474     public void setFetchDirection(int dir) throws SQLException JavaDoc {
475     }
476     
477     /**
478      * QED, being an embedded driver, fetches rows only when they are
479      * needed, with no performance penalty. Thus, the fetch size is
480      * always <code>one</code>, and this function has no effect.
481      */

482     public void setFetchSize(int x) throws SQLException JavaDoc {
483     }
484     
485     /**
486      * Not implemented in this release of QED
487      *
488      * @exception SQLException "not implemented"
489      */

490     public void setMaxFieldSize(int x) throws SQLException JavaDoc {
491     throw new SQLException JavaDoc("not implemented", "0A000");
492     }
493     
494     /**
495      * Set the maximum number of rows that will be returned by this
496      * ResultSet
497      */

498     public void setMaxRows(int x) throws SQLException JavaDoc {
499     maxRows = x;
500     }
501     
502     /**
503      * Not implemented in this release of QED
504      *
505      * @exception SQLException "not implemented"
506      */

507     public void setQueryTimeout(int x) throws SQLException JavaDoc {
508     throw new SQLException JavaDoc("not implemented", "0A000");
509     }
510     
511     int resultSetType = ResultSet.TYPE_SCROLL_INSENSITIVE;
512     int resultSetConcurrency = ResultSet.CONCUR_UPDATABLE;
513
514     /**
515      * Return the default result set concurrency for <code>ResultSet</code>
516      * objects generated by this <code>Statement</code> object.
517      *
518      * @return the default result set concurrency
519      */

520     public int getResultSetConcurrency() {
521     return resultSetConcurrency;
522     }
523     
524     /**
525      * Return the default result set type for <code>ResultSet</code>
526      * objects generated by this <code>Statement</code> object.
527      *
528      * @return the default result set type
529      */

530     public int getResultSetType() {
531     return resultSetType;
532     }
533
534     /**
535      * This release of QED only supports the fetch direction:
536      * <code>ResultSet.FETCH_FORWARD</code>
537      *
538      * @return <code>ResultSet.FETCH_FORWARD</code>
539      */

540     public int getFetchDirection() {
541     return ResultSet.FETCH_FORWARD;
542     }
543         
544     // JDBC 3.0 -------------------------------------------------------
545
//#ifdef JDK14
546
/**
547      * Moves to this <code>Statement</code> object's next result, deals with
548      * any current <code>ResultSet</code> object(s) according to the
549      * instructions specified by the given flag, and returns
550      * <code>true</code> if the next result is a <code>ResultSet</code> object.
551      *
552      * <P>There are no more results when the following is true:
553      * <PRE>
554      * <code>(!getMoreResults() && (getUpdateCount() == -1)</code>
555      * </PRE>
556      *
557      * @param current one of the following <code>Statement</code>
558      * constants indicating what should happen to current
559      * <code>ResultSet</code> objects obtained using the method
560      * <code>getResultSet</code:
561      * <code>CLOSE_CURRENT_RESULT</code>,
562      * <code>KEEP_CURRENT_RESULT</code>, or
563      * <code>CLOSE_ALL_RESULTS</code>
564      * @return <code>true</code> if the next result is a <code>ResultSet</code>
565      * object; <code>false</code> if it is an update count or there are no
566      * more results
567      * @exception SQLException if a database access error occurs
568      * @since 1.4
569      * @see #execute
570      */

571     public boolean getMoreResults(int current) throws SQLException JavaDoc {
572         if (current == KEEP_CURRENT_RESULT) {
573             throw new SQLException JavaDoc("JDBC 3.0 feature KEEP_CURRENT_RESULT " +
574                                    "not implemented");
575         }
576         return getMoreResults();
577     }
578
579     /**
580      * Retrieves any auto-generated keys created as a result of executing this
581      * <code>Statement</code> object. If this <code>Statement</code> object
582      * did not generate any keys, an empty <code>ResultSet</code>
583      * object is returned.
584      *
585      * @return a <code>ResultSet</code> object containing the auto-generated
586      * key(s) generated by the execution of this
587      * <code>Statement</code> object
588      * @exception SQLException if a database access error occurs
589      * @since 1.4
590      */

591     public java.sql.ResultSet JavaDoc getGeneratedKeys() throws SQLException JavaDoc {
592         throw new SQLException JavaDoc("JDBC3.0 feature not implemented");
593     }
594
595     /**
596      * Executes the given SQL statement and signals the driver with the
597      * given flag about whether the
598      * auto-generated keys produced by this <code>Statement</code> object
599      * should be made available for retrieval.
600      *
601      * @param sql must be an SQL <code>INSERT</code>, <code>UPDATE</code> or
602      * <code>DELETE</code> statement or an SQL statement that
603      * returns nothing
604      * @param autoGeneratedKeys a flag indicating whether auto-generated keys
605      * should be made available for retrieval;
606      * one of the following constants:
607      * <code>Statement.RETURN_GENERATED_KEYS</code>
608      * <code>Statement.NO_GENERATED_KEYS</code>
609      * @return either the row count for <code>INSERT</code>,
610      * <code>UPDATE</code>
611      * or <code>DELETE</code> statements, or <code>0</code> for SQL
612      * statements that return nothing
613      * @exception SQLException if a database access error occurs, the given
614      * SQL statement returns a <code>ResultSet</code> object, or
615      * the given constant is not one of those allowed
616      * @since 1.4
617      */

618     public int executeUpdate(String JavaDoc sql, int autoGeneratedKeys)
619         throws SQLException JavaDoc
620     {
621         if (autoGeneratedKeys == RETURN_GENERATED_KEYS) {
622             throw new SQLException JavaDoc("JDBC3.0 feature not implemented");
623         }
624         return executeUpdate(sql);
625     }
626
627     /**
628      * Executes the given SQL statement and signals the driver that the
629      * auto-generated keys indicated in the given array should be made
630      * available for retrieval. The driver will ignore the array if the
631      * SQL statement is not an <code>INSERT</code> statement.
632      *
633      * @param sql an SQL <code>INSERT</code>, <code>UPDATE</code> or
634      * <code>DELETE</code> statement or an SQL statement that returns
635      * nothing, such as an SQL DDL statement
636      * @param columnIndexes an array of column indexes indicating the columns
637      * that should be returned from the inserted row
638      * @return either the row count for <code>INSERT</code>,
639      * <code>UPDATE</code>,
640      * or <code>DELETE</code> statements, or 0 for SQL statements
641      * that return nothing
642      * @exception SQLException if a database access error occurs or the SQL
643      * statement returns a <code>ResultSet</code> object
644      * @since 1.4
645      */

646     public int executeUpdate(String JavaDoc sql, int columnIndexes[])
647         throws SQLException JavaDoc
648     {
649         return executeUpdate(sql);
650     }
651
652     /**
653      * Executes the given SQL statement and signals the driver that the
654      * auto-generated keys indicated in the given array should be made available
655      * for retrieval. The driver will ignore the array if the SQL statement
656      * is not an <code>INSERT</code> statement.
657      *
658      * @param sql an SQL <code>INSERT</code>, <code>UPDATE</code> or
659      * <code>DELETE</code> statement or an SQL statement that returns nothing
660      * @param columnNames an array of the names of the columns that should be
661      * returned from the inserted row
662      * @return either the row count for <code>INSERT</code>, <code>UPDATE</code>,
663      * or <code>DELETE</code> statements, or 0 for SQL statements
664      * that return nothing
665      * @exception SQLException if a database access error occurs
666      *
667      * @since 1.4
668      */

669     public int executeUpdate(String JavaDoc sql, String JavaDoc columnNames[])
670         throws SQLException JavaDoc
671     {
672         return executeUpdate(sql);
673     }
674
675     /**
676      * Executes the given SQL statement, which may return multiple results,
677      * and signals the driver that any
678      * auto-generated keys should be made available
679      * for retrieval. The driver will ignore this signal if the SQL statement
680      * is not an <code>INSERT</code> statement.
681      * <P>
682      * In some (uncommon) situations, a single SQL statement may return
683      * multiple result sets and/or update counts. Normally you can ignore
684      * this unless you are (1) executing a stored procedure that you know may
685      * return multiple results or (2) you are dynamically executing an
686      * unknown SQL string.
687      * <P>
688      * The <code>execute</code> method executes an SQL statement and indicates the
689      * form of the first result. You must then use the methods
690      * <code>getResultSet</code> or <code>getUpdateCount</code>
691      * to retrieve the result, and <code>getMoreResults</code> to
692      * move to any subsequent result(s).
693      *
694      * @param sql any SQL statement
695      * @param autoGeneratedKeys a constant indicating whether auto-generated
696      * keys should be made available for retrieval using the method
697      * <code>getGeneratedKeys</code>; one of the following constants:
698      * <code>Statement.RETURN_GENERATED_KEYS</code> or
699      * <code>Statement.NO_GENERATED_KEYS</code>
700      * @return <code>true</code> if the first result is a <code>ResultSet</code>
701      * object; <code>false</code> if it is an update count or there are
702      * no results
703      * @exception SQLException if a database access error occurs
704      * @see #getResultSet
705      * @see #getUpdateCount
706      * @see #getMoreResults
707      * @see #getGeneratedKeys
708      *
709      * @since 1.4
710      */

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

752     public boolean execute(String JavaDoc sql, int columnIndexes[])
753         throws SQLException JavaDoc
754     {
755         return execute(sql);
756     }
757
758     /**
759      * Executes the given SQL statement, which may return multiple results,
760      * and signals the driver that the
761      * auto-generated keys indicated in the given array should be made available
762      * for retrieval. This array contains the names of the columns in the
763      * target table that contain the auto-generated keys that should be made
764      * available. The driver will ignore the array if the given SQL statement
765      * is not an <code>INSERT</code> statement.
766      * <P>
767      * In some (uncommon) situations, a single SQL statement may return
768      * multiple result sets and/or update counts. Normally you can ignore
769      * this unless you are (1) executing a stored procedure that you know may
770      * return multiple results or (2) you are dynamically executing an
771      * unknown SQL string.
772      * <P>
773      * The <code>execute</code> method executes an SQL statement and indicates the
774      * form of the first result. You must then use the methods
775      * <code>getResultSet</code> or <code>getUpdateCount</code>
776      * to retrieve the result, and <code>getMoreResults</code> to
777      * move to any subsequent result(s).
778      *
779      * @param sql any SQL statement
780      * @param columnNames an array of the names of the columns in the inserted
781      * row that should be made available for retrieval by a call to the
782      * method <code>getGeneratedKeys</code>
783      * @return <code>true</code> if the next result is a <code>ResultSet</code>
784      * object; <code>false</code> if it is an update count or there
785      * are no more results
786      * @exception SQLException if a database access error occurs
787      * @see #getResultSet
788      * @see #getUpdateCount
789      * @see #getMoreResults
790      * @see #getGeneratedKeys
791      *
792      * @since 1.4
793      */

794     public boolean execute(String JavaDoc sql, String JavaDoc columnNames[])
795         throws SQLException JavaDoc
796     {
797         return execute(sql);
798     }
799
800    /**
801      * Retrieves the result set holdability for <code>ResultSet</code> objects
802      * generated by this <code>Statement</code> object.
803      *
804      * @return either <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
805      * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
806      * @exception SQLException if a database access error occurs
807      *
808      * @since 1.4
809      */

810     public int getResultSetHoldability() throws SQLException JavaDoc {
811         return ResultSet.CLOSE_CURSORS_AT_COMMIT;
812     }
813     //#endif
814

815 }
816
Popular Tags