38 * <code>ResultSet</code> object if an open one exists. |
38 * <code>ResultSet</code> object if an open one exists. |
39 * |
39 * |
40 * @see Connection#createStatement |
40 * @see Connection#createStatement |
41 * @see ResultSet |
41 * @see ResultSet |
42 */ |
42 */ |
43 public interface Statement extends Wrapper { |
43 public interface Statement extends Wrapper, AutoCloseable { |
44 |
44 |
45 /** |
45 /** |
46 * Executes the given SQL statement, which returns a single |
46 * Executes the given SQL statement, which returns a single |
47 * <code>ResultSet</code> object. |
47 * <code>ResultSet</code> object. |
48 * |
48 *<p> |
|
49 * <strong>Note:</strong>This method cannot be called on a |
|
50 * <code>PreparedStatement</code> or <code>CallableStatement</code>. |
49 * @param sql an SQL statement to be sent to the database, typically a |
51 * @param sql an SQL statement to be sent to the database, typically a |
50 * static SQL <code>SELECT</code> statement |
52 * static SQL <code>SELECT</code> statement |
51 * @return a <code>ResultSet</code> object that contains the data produced |
53 * @return a <code>ResultSet</code> object that contains the data produced |
52 * by the given query; never <code>null</code> |
54 * by the given query; never <code>null</code> |
53 * @exception SQLException if a database access error occurs, |
55 * @exception SQLException if a database access error occurs, |
54 * this method is called on a closed <code>Statement</code> or the given |
56 * this method is called on a closed <code>Statement</code>, the given |
55 * SQL statement produces anything other than a single |
57 * SQL statement produces anything other than a single |
56 * <code>ResultSet</code> object |
58 * <code>ResultSet</code> object, the method is called on a |
|
59 * <code>PreparedStatement</code> or <code>CallableStatement</code> |
|
60 * @throws SQLTimeoutException when the driver has determined that the |
|
61 * timeout value that was specified by the {@code setQueryTimeout} |
|
62 * method has been exceeded and has at least attempted to cancel |
|
63 * the currently running {@code Statement} |
57 */ |
64 */ |
58 ResultSet executeQuery(String sql) throws SQLException; |
65 ResultSet executeQuery(String sql) throws SQLException; |
59 |
66 |
60 /** |
67 /** |
61 * Executes the given SQL statement, which may be an <code>INSERT</code>, |
68 * Executes the given SQL statement, which may be an <code>INSERT</code>, |
62 * <code>UPDATE</code>, or <code>DELETE</code> statement or an |
69 * <code>UPDATE</code>, or <code>DELETE</code> statement or an |
63 * SQL statement that returns nothing, such as an SQL DDL statement. |
70 * SQL statement that returns nothing, such as an SQL DDL statement. |
64 * |
71 *<p> |
|
72 * <strong>Note:</strong>This method cannot be called on a |
|
73 * <code>PreparedStatement</code> or <code>CallableStatement</code>. |
65 * @param sql an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or |
74 * @param sql an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or |
66 * <code>DELETE</code>; or an SQL statement that returns nothing, |
75 * <code>DELETE</code>; or an SQL statement that returns nothing, |
67 * such as a DDL statement. |
76 * such as a DDL statement. |
68 * |
77 * |
69 * @return either (1) the row count for SQL Data Manipulation Language (DML) statements |
78 * @return either (1) the row count for SQL Data Manipulation Language (DML) statements |
70 * or (2) 0 for SQL statements that return nothing |
79 * or (2) 0 for SQL statements that return nothing |
71 * |
80 * |
72 * @exception SQLException if a database access error occurs, |
81 * @exception SQLException if a database access error occurs, |
73 * this method is called on a closed <code>Statement</code> or the given |
82 * this method is called on a closed <code>Statement</code>, the given |
74 * SQL statement produces a <code>ResultSet</code> object |
83 * SQL statement produces a <code>ResultSet</code> object, the method is called on a |
|
84 * <code>PreparedStatement</code> or <code>CallableStatement</code> |
|
85 * @throws SQLTimeoutException when the driver has determined that the |
|
86 * timeout value that was specified by the {@code setQueryTimeout} |
|
87 * method has been exceeded and has at least attempted to cancel |
|
88 * the currently running {@code Statement} |
75 */ |
89 */ |
76 int executeUpdate(String sql) throws SQLException; |
90 int executeUpdate(String sql) throws SQLException; |
77 |
91 |
78 /** |
92 /** |
79 * Releases this <code>Statement</code> object's database |
93 * Releases this <code>Statement</code> object's database |
196 int getQueryTimeout() throws SQLException; |
210 int getQueryTimeout() throws SQLException; |
197 |
211 |
198 /** |
212 /** |
199 * Sets the number of seconds the driver will wait for a |
213 * Sets the number of seconds the driver will wait for a |
200 * <code>Statement</code> object to execute to the given number of seconds. |
214 * <code>Statement</code> object to execute to the given number of seconds. |
201 * If the limit is exceeded, an <code>SQLException</code> is thrown. A JDBC |
215 *By default there is no limit on the amount of time allowed for a running |
202 * driver must apply this limit to the <code>execute</code>, |
216 * statement to complete. If the limit is exceeded, an |
203 * <code>executeQuery</code> and <code>executeUpdate</code> methods. JDBC driver |
217 * <code>SQLTimeoutException</code> is thrown. |
204 * implementations may also apply this limit to <code>ResultSet</code> methods |
218 * A JDBC driver must apply this limit to the <code>execute</code>, |
|
219 * <code>executeQuery</code> and <code>executeUpdate</code> methods. |
|
220 * <p> |
|
221 * <strong>Note:</strong> JDBC driver implementations may also apply this |
|
222 * limit to {@code ResultSet} methods |
205 * (consult your driver vendor documentation for details). |
223 * (consult your driver vendor documentation for details). |
|
224 * <p> |
|
225 * <strong>Note:</strong> In the case of {@code Statement} batching, it is |
|
226 * implementation defined as to whether the time-out is applied to |
|
227 * individual SQL commands added via the {@code addBatch} method or to |
|
228 * the entire batch of SQL commands invoked by the {@code executeBatch} |
|
229 * method (consult your driver vendor documentation for details). |
206 * |
230 * |
207 * @param seconds the new query timeout limit in seconds; zero means |
231 * @param seconds the new query timeout limit in seconds; zero means |
208 * there is no limit |
232 * there is no limit |
209 * @exception SQLException if a database access error occurs, |
233 * @exception SQLException if a database access error occurs, |
210 * this method is called on a closed <code>Statement</code> |
234 * this method is called on a closed <code>Statement</code> |
298 * The <code>execute</code> method executes an SQL statement and indicates the |
322 * The <code>execute</code> method executes an SQL statement and indicates the |
299 * form of the first result. You must then use the methods |
323 * form of the first result. You must then use the methods |
300 * <code>getResultSet</code> or <code>getUpdateCount</code> |
324 * <code>getResultSet</code> or <code>getUpdateCount</code> |
301 * to retrieve the result, and <code>getMoreResults</code> to |
325 * to retrieve the result, and <code>getMoreResults</code> to |
302 * move to any subsequent result(s). |
326 * move to any subsequent result(s). |
303 * |
327 * <p> |
|
328 *<strong>Note:</strong>This method cannot be called on a |
|
329 * <code>PreparedStatement</code> or <code>CallableStatement</code>. |
304 * @param sql any SQL statement |
330 * @param sql any SQL statement |
305 * @return <code>true</code> if the first result is a <code>ResultSet</code> |
331 * @return <code>true</code> if the first result is a <code>ResultSet</code> |
306 * object; <code>false</code> if it is an update count or there are |
332 * object; <code>false</code> if it is an update count or there are |
307 * no results |
333 * no results |
308 * @exception SQLException if a database access error occurs or |
334 * @exception SQLException if a database access error occurs, |
309 * this method is called on a closed <code>Statement</code> |
335 * this method is called on a closed <code>Statement</code>, |
|
336 * the method is called on a |
|
337 * <code>PreparedStatement</code> or <code>CallableStatement</code> |
|
338 * @throws SQLTimeoutException when the driver has determined that the |
|
339 * timeout value that was specified by the {@code setQueryTimeout} |
|
340 * method has been exceeded and has at least attempted to cancel |
|
341 * the currently running {@code Statement} |
310 * @see #getResultSet |
342 * @see #getResultSet |
311 * @see #getUpdateCount |
343 * @see #getUpdateCount |
312 * @see #getMoreResults |
344 * @see #getMoreResults |
313 */ |
345 */ |
314 boolean execute(String sql) throws SQLException; |
346 boolean execute(String sql) throws SQLException; |
463 /** |
495 /** |
464 * Adds the given SQL command to the current list of commmands for this |
496 * Adds the given SQL command to the current list of commmands for this |
465 * <code>Statement</code> object. The commands in this list can be |
497 * <code>Statement</code> object. The commands in this list can be |
466 * executed as a batch by calling the method <code>executeBatch</code>. |
498 * executed as a batch by calling the method <code>executeBatch</code>. |
467 * <P> |
499 * <P> |
468 * |
500 *<strong>Note:</strong>This method cannot be called on a |
|
501 * <code>PreparedStatement</code> or <code>CallableStatement</code>. |
469 * @param sql typically this is a SQL <code>INSERT</code> or |
502 * @param sql typically this is a SQL <code>INSERT</code> or |
470 * <code>UPDATE</code> statement |
503 * <code>UPDATE</code> statement |
471 * @exception SQLException if a database access error occurs, |
504 * @exception SQLException if a database access error occurs, |
472 * this method is called on a closed <code>Statement</code> or the |
505 * this method is called on a closed <code>Statement</code>, the |
473 * driver does not support batch updates |
506 * driver does not support batch updates, the method is called on a |
|
507 * <code>PreparedStatement</code> or <code>CallableStatement</code> |
474 * @see #executeBatch |
508 * @see #executeBatch |
475 * @see DatabaseMetaData#supportsBatchUpdates |
509 * @see DatabaseMetaData#supportsBatchUpdates |
476 * @since 1.2 |
510 * @since 1.2 |
477 */ |
511 */ |
478 void addBatch( String sql ) throws SQLException; |
512 void addBatch( String sql ) throws SQLException; |
534 * @exception SQLException if a database access error occurs, |
568 * @exception SQLException if a database access error occurs, |
535 * this method is called on a closed <code>Statement</code> or the |
569 * this method is called on a closed <code>Statement</code> or the |
536 * driver does not support batch statements. Throws {@link BatchUpdateException} |
570 * driver does not support batch statements. Throws {@link BatchUpdateException} |
537 * (a subclass of <code>SQLException</code>) if one of the commands sent to the |
571 * (a subclass of <code>SQLException</code>) if one of the commands sent to the |
538 * database fails to execute properly or attempts to return a result set. |
572 * database fails to execute properly or attempts to return a result set. |
539 * |
573 * @throws SQLTimeoutException when the driver has determined that the |
|
574 * timeout value that was specified by the {@code setQueryTimeout} |
|
575 * method has been exceeded and has at least attempted to cancel |
|
576 * the currently running {@code Statement} |
540 * |
577 * |
541 * @see #addBatch |
578 * @see #addBatch |
542 * @see DatabaseMetaData#supportsBatchUpdates |
579 * @see DatabaseMetaData#supportsBatchUpdates |
543 * @since 1.3 |
580 * @since 1.3 |
544 */ |
581 */ |
676 * auto-generated keys produced by this <code>Statement</code> object |
713 * auto-generated keys produced by this <code>Statement</code> object |
677 * should be made available for retrieval. The driver will ignore the |
714 * should be made available for retrieval. The driver will ignore the |
678 * flag if the SQL statement |
715 * flag if the SQL statement |
679 * is not an <code>INSERT</code> statement, or an SQL statement able to return |
716 * is not an <code>INSERT</code> statement, or an SQL statement able to return |
680 * auto-generated keys (the list of such statements is vendor-specific). |
717 * auto-generated keys (the list of such statements is vendor-specific). |
681 * |
718 *<p> |
|
719 * <strong>Note:</strong>This method cannot be called on a |
|
720 * <code>PreparedStatement</code> or <code>CallableStatement</code>. |
682 * @param sql an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or |
721 * @param sql an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or |
683 * <code>DELETE</code>; or an SQL statement that returns nothing, |
722 * <code>DELETE</code>; or an SQL statement that returns nothing, |
684 * such as a DDL statement. |
723 * such as a DDL statement. |
685 * |
724 * |
686 * @param autoGeneratedKeys a flag indicating whether auto-generated keys |
725 * @param autoGeneratedKeys a flag indicating whether auto-generated keys |
691 * @return either (1) the row count for SQL Data Manipulation Language (DML) statements |
730 * @return either (1) the row count for SQL Data Manipulation Language (DML) statements |
692 * or (2) 0 for SQL statements that return nothing |
731 * or (2) 0 for SQL statements that return nothing |
693 * |
732 * |
694 * @exception SQLException if a database access error occurs, |
733 * @exception SQLException if a database access error occurs, |
695 * this method is called on a closed <code>Statement</code>, the given |
734 * this method is called on a closed <code>Statement</code>, the given |
696 * SQL statement returns a <code>ResultSet</code> object, or |
735 * SQL statement returns a <code>ResultSet</code> object, |
697 * the given constant is not one of those allowed |
736 * the given constant is not one of those allowed, the method is called on a |
|
737 * <code>PreparedStatement</code> or <code>CallableStatement</code> |
698 * @exception SQLFeatureNotSupportedException if the JDBC driver does not support |
738 * @exception SQLFeatureNotSupportedException if the JDBC driver does not support |
699 * this method with a constant of Statement.RETURN_GENERATED_KEYS |
739 * this method with a constant of Statement.RETURN_GENERATED_KEYS |
|
740 * @throws SQLTimeoutException when the driver has determined that the |
|
741 * timeout value that was specified by the {@code setQueryTimeout} |
|
742 * method has been exceeded and has at least attempted to cancel |
|
743 * the currently running {@code Statement} |
700 * @since 1.4 |
744 * @since 1.4 |
701 */ |
745 */ |
702 int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException; |
746 int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException; |
703 |
747 |
704 /** |
748 /** |
707 * for retrieval. This array contains the indexes of the columns in the |
751 * for retrieval. This array contains the indexes of the columns in the |
708 * target table that contain the auto-generated keys that should be made |
752 * target table that contain the auto-generated keys that should be made |
709 * available. The driver will ignore the array if the SQL statement |
753 * available. The driver will ignore the array if the SQL statement |
710 * is not an <code>INSERT</code> statement, or an SQL statement able to return |
754 * is not an <code>INSERT</code> statement, or an SQL statement able to return |
711 * auto-generated keys (the list of such statements is vendor-specific). |
755 * auto-generated keys (the list of such statements is vendor-specific). |
712 * |
756 *<p> |
|
757 * <strong>Note:</strong>This method cannot be called on a |
|
758 * <code>PreparedStatement</code> or <code>CallableStatement</code>. |
713 * @param sql an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or |
759 * @param sql an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or |
714 * <code>DELETE</code>; or an SQL statement that returns nothing, |
760 * <code>DELETE</code>; or an SQL statement that returns nothing, |
715 * such as a DDL statement. |
761 * such as a DDL statement. |
716 * |
762 * |
717 * @param columnIndexes an array of column indexes indicating the columns |
763 * @param columnIndexes an array of column indexes indicating the columns |
719 * @return either (1) the row count for SQL Data Manipulation Language (DML) statements |
765 * @return either (1) the row count for SQL Data Manipulation Language (DML) statements |
720 * or (2) 0 for SQL statements that return nothing |
766 * or (2) 0 for SQL statements that return nothing |
721 * |
767 * |
722 * @exception SQLException if a database access error occurs, |
768 * @exception SQLException if a database access error occurs, |
723 * this method is called on a closed <code>Statement</code>, the SQL |
769 * this method is called on a closed <code>Statement</code>, the SQL |
724 * statement returns a <code>ResultSet</code> object, or the |
770 * statement returns a <code>ResultSet</code> object,the second argument |
725 * second argument supplied to this method is not an <code>int</code> array |
771 * supplied to this method is not an |
726 * whose elements are valid column indexes |
772 * <code>int</code> array whose elements are valid column indexes, the method is called on a |
|
773 * <code>PreparedStatement</code> or <code>CallableStatement</code> |
727 * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
774 * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
775 * @throws SQLTimeoutException when the driver has determined that the |
|
776 * timeout value that was specified by the {@code setQueryTimeout} |
|
777 * method has been exceeded and has at least attempted to cancel |
|
778 * the currently running {@code Statement} |
728 * @since 1.4 |
779 * @since 1.4 |
729 */ |
780 */ |
730 int executeUpdate(String sql, int columnIndexes[]) throws SQLException; |
781 int executeUpdate(String sql, int columnIndexes[]) throws SQLException; |
731 |
782 |
732 /** |
783 /** |
735 * for retrieval. This array contains the names of the columns in the |
786 * for retrieval. This array contains the names of the columns in the |
736 * target table that contain the auto-generated keys that should be made |
787 * target table that contain the auto-generated keys that should be made |
737 * available. The driver will ignore the array if the SQL statement |
788 * available. The driver will ignore the array if the SQL statement |
738 * is not an <code>INSERT</code> statement, or an SQL statement able to return |
789 * is not an <code>INSERT</code> statement, or an SQL statement able to return |
739 * auto-generated keys (the list of such statements is vendor-specific). |
790 * auto-generated keys (the list of such statements is vendor-specific). |
740 * |
791 *<p> |
|
792 * <strong>Note:</strong>This method cannot be called on a |
|
793 * <code>PreparedStatement</code> or <code>CallableStatement</code>. |
741 * @param sql an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or |
794 * @param sql an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or |
742 * <code>DELETE</code>; or an SQL statement that returns nothing, |
795 * <code>DELETE</code>; or an SQL statement that returns nothing, |
743 * such as a DDL statement. |
796 * such as a DDL statement. |
744 * @param columnNames an array of the names of the columns that should be |
797 * @param columnNames an array of the names of the columns that should be |
745 * returned from the inserted row |
798 * returned from the inserted row |
746 * @return either the row count for <code>INSERT</code>, <code>UPDATE</code>, |
799 * @return either the row count for <code>INSERT</code>, <code>UPDATE</code>, |
747 * or <code>DELETE</code> statements, or 0 for SQL statements |
800 * or <code>DELETE</code> statements, or 0 for SQL statements |
748 * that return nothing |
801 * that return nothing |
749 * @exception SQLException if a database access error occurs, |
802 * @exception SQLException if a database access error occurs, |
750 * this method is called on a closed <code>Statement</code>, the SQL |
803 * this method is called on a closed <code>Statement</code>, the SQL |
751 * statement returns a <code>ResultSet</code> object, or the |
804 * statement returns a <code>ResultSet</code> object, the |
752 * second argument supplied to this method is not a <code>String</code> array |
805 * second argument supplied to this method is not a <code>String</code> array |
753 * whose elements are valid column names |
806 * whose elements are valid column names, the method is called on a |
754 * |
807 * <code>PreparedStatement</code> or <code>CallableStatement</code> |
755 * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
808 * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
809 * @throws SQLTimeoutException when the driver has determined that the |
|
810 * timeout value that was specified by the {@code setQueryTimeout} |
|
811 * method has been exceeded and has at least attempted to cancel |
|
812 * the currently running {@code Statement} |
756 * @since 1.4 |
813 * @since 1.4 |
757 */ |
814 */ |
758 int executeUpdate(String sql, String columnNames[]) throws SQLException; |
815 int executeUpdate(String sql, String columnNames[]) throws SQLException; |
759 |
816 |
760 /** |
817 /** |
774 * The <code>execute</code> method executes an SQL statement and indicates the |
831 * The <code>execute</code> method executes an SQL statement and indicates the |
775 * form of the first result. You must then use the methods |
832 * form of the first result. You must then use the methods |
776 * <code>getResultSet</code> or <code>getUpdateCount</code> |
833 * <code>getResultSet</code> or <code>getUpdateCount</code> |
777 * to retrieve the result, and <code>getMoreResults</code> to |
834 * to retrieve the result, and <code>getMoreResults</code> to |
778 * move to any subsequent result(s). |
835 * move to any subsequent result(s). |
779 * |
836 *<p> |
|
837 *<strong>Note:</strong>This method cannot be called on a |
|
838 * <code>PreparedStatement</code> or <code>CallableStatement</code>. |
780 * @param sql any SQL statement |
839 * @param sql any SQL statement |
781 * @param autoGeneratedKeys a constant indicating whether auto-generated |
840 * @param autoGeneratedKeys a constant indicating whether auto-generated |
782 * keys should be made available for retrieval using the method |
841 * keys should be made available for retrieval using the method |
783 * <code>getGeneratedKeys</code>; one of the following constants: |
842 * <code>getGeneratedKeys</code>; one of the following constants: |
784 * <code>Statement.RETURN_GENERATED_KEYS</code> or |
843 * <code>Statement.RETURN_GENERATED_KEYS</code> or |
785 * <code>Statement.NO_GENERATED_KEYS</code> |
844 * <code>Statement.NO_GENERATED_KEYS</code> |
786 * @return <code>true</code> if the first result is a <code>ResultSet</code> |
845 * @return <code>true</code> if the first result is a <code>ResultSet</code> |
787 * object; <code>false</code> if it is an update count or there are |
846 * object; <code>false</code> if it is an update count or there are |
788 * no results |
847 * no results |
789 * @exception SQLException if a database access error occurs, |
848 * @exception SQLException if a database access error occurs, |
790 * this method is called on a closed <code>Statement</code> or the second |
849 * this method is called on a closed <code>Statement</code>, the second |
791 * parameter supplied to this method is not |
850 * parameter supplied to this method is not |
792 * <code>Statement.RETURN_GENERATED_KEYS</code> or |
851 * <code>Statement.RETURN_GENERATED_KEYS</code> or |
793 * <code>Statement.NO_GENERATED_KEYS</code>. |
852 * <code>Statement.NO_GENERATED_KEYS</code>, |
|
853 * the method is called on a |
|
854 * <code>PreparedStatement</code> or <code>CallableStatement</code> |
794 * @exception SQLFeatureNotSupportedException if the JDBC driver does not support |
855 * @exception SQLFeatureNotSupportedException if the JDBC driver does not support |
795 * this method with a constant of Statement.RETURN_GENERATED_KEYS |
856 * this method with a constant of Statement.RETURN_GENERATED_KEYS |
|
857 * @throws SQLTimeoutException when the driver has determined that the |
|
858 * timeout value that was specified by the {@code setQueryTimeout} |
|
859 * method has been exceeded and has at least attempted to cancel |
|
860 * the currently running {@code Statement} |
796 * @see #getResultSet |
861 * @see #getResultSet |
797 * @see #getUpdateCount |
862 * @see #getUpdateCount |
798 * @see #getMoreResults |
863 * @see #getMoreResults |
799 * @see #getGeneratedKeys |
864 * @see #getGeneratedKeys |
800 * |
865 * |
821 * The <code>execute</code> method executes an SQL statement and indicates the |
886 * The <code>execute</code> method executes an SQL statement and indicates the |
822 * form of the first result. You must then use the methods |
887 * form of the first result. You must then use the methods |
823 * <code>getResultSet</code> or <code>getUpdateCount</code> |
888 * <code>getResultSet</code> or <code>getUpdateCount</code> |
824 * to retrieve the result, and <code>getMoreResults</code> to |
889 * to retrieve the result, and <code>getMoreResults</code> to |
825 * move to any subsequent result(s). |
890 * move to any subsequent result(s). |
826 * |
891 *<p> |
|
892 * <strong>Note:</strong>This method cannot be called on a |
|
893 * <code>PreparedStatement</code> or <code>CallableStatement</code>. |
827 * @param sql any SQL statement |
894 * @param sql any SQL statement |
828 * @param columnIndexes an array of the indexes of the columns in the |
895 * @param columnIndexes an array of the indexes of the columns in the |
829 * inserted row that should be made available for retrieval by a |
896 * inserted row that should be made available for retrieval by a |
830 * call to the method <code>getGeneratedKeys</code> |
897 * call to the method <code>getGeneratedKeys</code> |
831 * @return <code>true</code> if the first result is a <code>ResultSet</code> |
898 * @return <code>true</code> if the first result is a <code>ResultSet</code> |
832 * object; <code>false</code> if it is an update count or there |
899 * object; <code>false</code> if it is an update count or there |
833 * are no results |
900 * are no results |
834 * @exception SQLException if a database access error occurs, |
901 * @exception SQLException if a database access error occurs, |
835 * this method is called on a closed <code>Statement</code> or the |
902 * this method is called on a closed <code>Statement</code>, the |
836 * elements in the <code>int</code> array passed to this method |
903 * elements in the <code>int</code> array passed to this method |
837 * are not valid column indexes |
904 * are not valid column indexes, the method is called on a |
|
905 * <code>PreparedStatement</code> or <code>CallableStatement</code> |
838 * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
906 * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
907 * @throws SQLTimeoutException when the driver has determined that the |
|
908 * timeout value that was specified by the {@code setQueryTimeout} |
|
909 * method has been exceeded and has at least attempted to cancel |
|
910 * the currently running {@code Statement} |
839 * @see #getResultSet |
911 * @see #getResultSet |
840 * @see #getUpdateCount |
912 * @see #getUpdateCount |
841 * @see #getMoreResults |
913 * @see #getMoreResults |
842 * |
914 * |
843 * @since 1.4 |
915 * @since 1.4 |
863 * The <code>execute</code> method executes an SQL statement and indicates the |
935 * The <code>execute</code> method executes an SQL statement and indicates the |
864 * form of the first result. You must then use the methods |
936 * form of the first result. You must then use the methods |
865 * <code>getResultSet</code> or <code>getUpdateCount</code> |
937 * <code>getResultSet</code> or <code>getUpdateCount</code> |
866 * to retrieve the result, and <code>getMoreResults</code> to |
938 * to retrieve the result, and <code>getMoreResults</code> to |
867 * move to any subsequent result(s). |
939 * move to any subsequent result(s). |
868 * |
940 *<p> |
|
941 * <strong>Note:</strong>This method cannot be called on a |
|
942 * <code>PreparedStatement</code> or <code>CallableStatement</code>. |
869 * @param sql any SQL statement |
943 * @param sql any SQL statement |
870 * @param columnNames an array of the names of the columns in the inserted |
944 * @param columnNames an array of the names of the columns in the inserted |
871 * row that should be made available for retrieval by a call to the |
945 * row that should be made available for retrieval by a call to the |
872 * method <code>getGeneratedKeys</code> |
946 * method <code>getGeneratedKeys</code> |
873 * @return <code>true</code> if the next result is a <code>ResultSet</code> |
947 * @return <code>true</code> if the next result is a <code>ResultSet</code> |
874 * object; <code>false</code> if it is an update count or there |
948 * object; <code>false</code> if it is an update count or there |
875 * are no more results |
949 * are no more results |
876 * @exception SQLException if a database access error occurs, |
950 * @exception SQLException if a database access error occurs, |
877 * this method is called on a closed <code>Statement</code> or the |
951 * this method is called on a closed <code>Statement</code>,the |
878 * elements of the <code>String</code> array passed to this |
952 * elements of the <code>String</code> array passed to this |
879 * method are not valid column names |
953 * method are not valid column names, the method is called on a |
|
954 * <code>PreparedStatement</code> or <code>CallableStatement</code> |
880 * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
955 * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method |
|
956 * @throws SQLTimeoutException when the driver has determined that the |
|
957 * timeout value that was specified by the {@code setQueryTimeout} |
|
958 * method has been exceeded and has at least attempted to cancel |
|
959 * the currently running {@code Statement} |
881 * @see #getResultSet |
960 * @see #getResultSet |
882 * @see #getUpdateCount |
961 * @see #getUpdateCount |
883 * @see #getMoreResults |
962 * @see #getMoreResults |
884 * @see #getGeneratedKeys |
963 * @see #getGeneratedKeys |
885 * |
964 * |
949 * @see java.sql.Statement#setPoolable(boolean) setPoolable(boolean) |
1028 * @see java.sql.Statement#setPoolable(boolean) setPoolable(boolean) |
950 */ |
1029 */ |
951 boolean isPoolable() |
1030 boolean isPoolable() |
952 throws SQLException; |
1031 throws SQLException; |
953 |
1032 |
|
1033 //--------------------------JDBC 4.1 ----------------------------- |
|
1034 |
|
1035 /** |
|
1036 * Specifies that this {@code Statement} will be closed when all its |
|
1037 * dependent result sets are closed. If execution of the {@code Statement} |
|
1038 * does not produce any result sets, this method has no effect. |
|
1039 * <p> |
|
1040 * <strong>Note:</strong> Multiple calls to {@code closeOnCompletion} do |
|
1041 * not toggle the effect on this {@code Statement}. However, a call to |
|
1042 * {@code closeOnCompletion} does effect both the subsequent execution of |
|
1043 * statements, and statements that currently have open, dependent, |
|
1044 * result sets. |
|
1045 * |
|
1046 * @throws SQLException if this method is called on a closed |
|
1047 * {@code Statement} |
|
1048 * @since 1.7 |
|
1049 */ |
|
1050 public void closeOnCompletion() throws SQLException; |
|
1051 |
|
1052 /** |
|
1053 * Returns a value indicating whether this {@code Statement} will be |
|
1054 * closed when all dependent objects such as resultsets are closed. |
|
1055 * @return {@code true} if the {@code Statement} will be closed when all |
|
1056 * of its dependent objects are closed; {@code false} otherwise |
|
1057 * @throws SQLException if this method is called on a closed |
|
1058 * {@code Statement} |
|
1059 * @since 1.7 |
|
1060 */ |
|
1061 public boolean isCloseOnCompletion() throws SQLException; |
|
1062 |
954 } |
1063 } |