151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/* 251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. 351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This code is free software; you can redistribute it and/or modify it 651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * under the terms of the GNU General Public License version 2 only, as 751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * published by the Free Software Foundation. Oracle designates this 851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * particular file as subject to the "Classpath" exception as provided 951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * by Oracle in the LICENSE file that accompanied this code. 1051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 1151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This code is distributed in the hope that it will be useful, but WITHOUT 1251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * version 2 for more details (a copy is included in the LICENSE file that 1551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * accompanied this code). 1651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 1751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * You should have received a copy of the GNU General Public License version 1851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 2 along with this work; if not, write to the Free Software Foundation, 1951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 2151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or visit www.oracle.com if you need additional information or have any 2351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * questions. 2451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 2551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 2651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipackage java.sql; 2751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 2851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/** 2951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P>The object used for executing a static SQL statement 3051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * and returning the results it produces. 3151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P> 3251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * By default, only one <code>ResultSet</code> object per <code>Statement</code> 3351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object can be open at the same time. Therefore, if the reading of one 3451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>ResultSet</code> object is interleaved 3551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * with the reading of another, each must have been generated by 3651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * different <code>Statement</code> objects. All execution methods in the 3751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement</code> interface implicitly close a statment's current 3851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>ResultSet</code> object if an open one exists. 3951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 4051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see Connection#createStatement 4151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see ResultSet 4251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 4351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipublic interface Statement extends Wrapper, AutoCloseable { 4451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 4551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 4651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Executes the given SQL statement, which returns a single 4751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>ResultSet</code> object. 4851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *<p> 4951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <strong>Note:</strong>This method cannot be called on a 5051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code>. 5151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param sql an SQL statement to be sent to the database, typically a 5251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * static SQL <code>SELECT</code> statement 5351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return a <code>ResultSet</code> object that contains the data produced 5451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * by the given query; never <code>null</code> 5551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 5651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code>, the given 5751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * SQL statement produces anything other than a single 5851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>ResultSet</code> object, the method is called on a 5951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code> 6051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLTimeoutException when the driver has determined that the 6151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * timeout value that was specified by the {@code setQueryTimeout} 6251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method has been exceeded and has at least attempted to cancel 6351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the currently running {@code Statement} 6451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 6551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski ResultSet executeQuery(String sql) throws SQLException; 6651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 6751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 6851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Executes the given SQL statement, which may be an <code>INSERT</code>, 6951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>UPDATE</code>, or <code>DELETE</code> statement or an 7051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * SQL statement that returns nothing, such as an SQL DDL statement. 7151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *<p> 7251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <strong>Note:</strong>This method cannot be called on a 7351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code>. 7451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param sql an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or 7551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>DELETE</code>; or an SQL statement that returns nothing, 7651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * such as a DDL statement. 7751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 7851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return either (1) the row count for SQL Data Manipulation Language (DML) statements 7951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or (2) 0 for SQL statements that return nothing 8051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 8151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 8251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code>, the given 8351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * SQL statement produces a <code>ResultSet</code> object, the method is called on a 8451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code> 8551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLTimeoutException when the driver has determined that the 8651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * timeout value that was specified by the {@code setQueryTimeout} 8751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method has been exceeded and has at least attempted to cancel 8851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the currently running {@code Statement} 8951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 9051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int executeUpdate(String sql) throws SQLException; 9151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 9251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 9351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Releases this <code>Statement</code> object's database 9451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * and JDBC resources immediately instead of waiting for 9551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this to happen when it is automatically closed. 9651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * It is generally good practice to release resources as soon as 9751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * you are finished with them to avoid tying up database 9851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * resources. 9951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P> 10051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Calling the method <code>close</code> on a <code>Statement</code> 10151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object that is already closed has no effect. 10251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P> 10351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <B>Note:</B>When a <code>Statement</code> object is 10451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * closed, its current <code>ResultSet</code> object, if one exists, is 10551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * also closed. 10651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 10751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs 10851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 10951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski void close() throws SQLException; 11051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 11151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski //---------------------------------------------------------------------- 11251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 11351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 11451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Retrieves the maximum number of bytes that can be 11551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * returned for character and binary column values in a <code>ResultSet</code> 11651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object produced by this <code>Statement</code> object. 11751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This limit applies only to <code>BINARY</code>, <code>VARBINARY</code>, 11851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>LONGVARBINARY</code>, <code>CHAR</code>, <code>VARCHAR</code>, 11951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>NCHAR</code>, <code>NVARCHAR</code>, <code>LONGNVARCHAR</code> 12051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * and <code>LONGVARCHAR</code> columns. If the limit is exceeded, the 12151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * excess data is silently discarded. 12251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 12351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return the current column size limit for columns storing character and 12451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * binary values; zero means there is no limit 12551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 12651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 12751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #setMaxFieldSize 12851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 12951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int getMaxFieldSize() throws SQLException; 13051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 13151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 13251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Sets the limit for the maximum number of bytes that can be returned for 13351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * character and binary column values in a <code>ResultSet</code> 13451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object produced by this <code>Statement</code> object. 13551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 13651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This limit applies 13751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * only to <code>BINARY</code>, <code>VARBINARY</code>, 13851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>LONGVARBINARY</code>, <code>CHAR</code>, <code>VARCHAR</code>, 13951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>NCHAR</code>, <code>NVARCHAR</code>, <code>LONGNVARCHAR</code> and 14051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>LONGVARCHAR</code> fields. If the limit is exceeded, the excess data 14151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is silently discarded. For maximum portability, use values 14251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * greater than 256. 14351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 14451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param max the new column size limit in bytes; zero means there is no limit 14551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 14651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 14751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or the condition max >= 0 is not satisfied 14851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getMaxFieldSize 14951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 15051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski void setMaxFieldSize(int max) throws SQLException; 15151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 15251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 15351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Retrieves the maximum number of rows that a 15451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>ResultSet</code> object produced by this 15551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement</code> object can contain. If this limit is exceeded, 15651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the excess rows are silently dropped. 15751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 15851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return the current maximum number of rows for a <code>ResultSet</code> 15951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object produced by this <code>Statement</code> object; 16051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * zero means there is no limit 16151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 16251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 16351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #setMaxRows 16451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 16551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int getMaxRows() throws SQLException; 16651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 16751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 16851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Sets the limit for the maximum number of rows that any 16951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>ResultSet</code> object generated by this <code>Statement</code> 17051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object can contain to the given number. 17151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If the limit is exceeded, the excess 17251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * rows are silently dropped. 17351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 17451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param max the new max rows limit; zero means there is no limit 17551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 17651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 17751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or the condition max >= 0 is not satisfied 17851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getMaxRows 17951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 18051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski void setMaxRows(int max) throws SQLException; 18151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 18251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 18351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Sets escape processing on or off. 18451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If escape scanning is on (the default), the driver will do 18551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * escape substitution before sending the SQL statement to the database. 18651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 18751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Note: Since prepared statements have usually been parsed prior 18851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * to making this call, disabling escape processing for 18951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatements</code> objects will have no effect. 19051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 19151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param enable <code>true</code> to enable escape processing; 19251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>false</code> to disable it 19351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 19451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 19551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 19651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski void setEscapeProcessing(boolean enable) throws SQLException; 19751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 19851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 19951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Retrieves the number of seconds the driver will 20051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * wait for a <code>Statement</code> object to execute. 20151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If the limit is exceeded, a 20251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>SQLException</code> is thrown. 20351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 20451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return the current query timeout limit in seconds; zero means there is 20551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * no limit 20651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 20751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 20851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #setQueryTimeout 20951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 21051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int getQueryTimeout() throws SQLException; 21151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 21251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 21351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Sets the number of seconds the driver will wait for a 21451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement</code> object to execute to the given number of seconds. 21551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *By default there is no limit on the amount of time allowed for a running 21651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * statement to complete. If the limit is exceeded, an 21751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>SQLTimeoutException</code> is thrown. 21851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * A JDBC driver must apply this limit to the <code>execute</code>, 21951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>executeQuery</code> and <code>executeUpdate</code> methods. 22051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 22151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <strong>Note:</strong> JDBC driver implementations may also apply this 22251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * limit to {@code ResultSet} methods 22351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (consult your driver vendor documentation for details). 22451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 22551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <strong>Note:</strong> In the case of {@code Statement} batching, it is 22651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * implementation defined as to whether the time-out is applied to 22751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * individual SQL commands added via the {@code addBatch} method or to 22851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the entire batch of SQL commands invoked by the {@code executeBatch} 22951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method (consult your driver vendor documentation for details). 23051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 23151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param seconds the new query timeout limit in seconds; zero means 23251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * there is no limit 23351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 23451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 23551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or the condition seconds >= 0 is not satisfied 23651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getQueryTimeout 23751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 23851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski void setQueryTimeout(int seconds) throws SQLException; 23951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 24051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 24151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Cancels this <code>Statement</code> object if both the DBMS and 24251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * driver support aborting an SQL statement. 24351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This method can be used by one thread to cancel a statement that 24451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is being executed by another thread. 24551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 24651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 24751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 24851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLFeatureNotSupportedException if the JDBC driver does not support 24951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method 25051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 25151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski void cancel() throws SQLException; 25251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 25351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 25451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Retrieves the first warning reported by calls on this <code>Statement</code> object. 25551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Subsequent <code>Statement</code> object warnings will be chained to this 25651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>SQLWarning</code> object. 25751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 25851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p>The warning chain is automatically cleared each time 25951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * a statement is (re)executed. This method may not be called on a closed 26051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement</code> object; doing so will cause an <code>SQLException</code> 26151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * to be thrown. 26251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 26351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P><B>Note:</B> If you are processing a <code>ResultSet</code> object, any 26451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * warnings associated with reads on that <code>ResultSet</code> object 26551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * will be chained on it rather than on the <code>Statement</code> 26651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object that produced it. 26751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 26851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return the first <code>SQLWarning</code> object or <code>null</code> 26951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * if there are no warnings 27051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 27151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 27251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 27351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski SQLWarning getWarnings() throws SQLException; 27451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 27551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 27651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Clears all the warnings reported on this <code>Statement</code> 27751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object. After a call to this method, 27851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the method <code>getWarnings</code> will return 27951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>null</code> until a new warning is reported for this 28051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement</code> object. 28151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 28251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 28351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 28451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 28551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski void clearWarnings() throws SQLException; 28651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 28751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 28851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Sets the SQL cursor name to the given <code>String</code>, which 28951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * will be used by subsequent <code>Statement</code> object 29051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>execute</code> methods. This name can then be 29151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * used in SQL positioned update or delete statements to identify the 29251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * current row in the <code>ResultSet</code> object generated by this 29351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * statement. If the database does not support positioned update/delete, 29451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is a noop. To insure that a cursor has the proper isolation 29551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * level to support updates, the cursor's <code>SELECT</code> statement 29651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * should have the form <code>SELECT FOR UPDATE</code>. If 29751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>FOR UPDATE</code> is not present, positioned updates may fail. 29851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 29951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P><B>Note:</B> By definition, the execution of positioned updates and 30051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * deletes must be done by a different <code>Statement</code> object than 30151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the one that generated the <code>ResultSet</code> object being used for 30251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * positioning. Also, cursor names must be unique within a connection. 30351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 30451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param name the new cursor name, which must be unique within 30551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * a connection 30651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 30751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 30851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method 30951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 31051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski void setCursorName(String name) throws SQLException; 31151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 31251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski //----------------------- Multiple Results -------------------------- 31351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 31451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 31551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Executes the given SQL statement, which may return multiple results. 31651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * In some (uncommon) situations, a single SQL statement may return 31751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * multiple result sets and/or update counts. Normally you can ignore 31851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this unless you are (1) executing a stored procedure that you know may 31951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * return multiple results or (2) you are dynamically executing an 32051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * unknown SQL string. 32151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P> 32251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The <code>execute</code> method executes an SQL statement and indicates the 32351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * form of the first result. You must then use the methods 32451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>getResultSet</code> or <code>getUpdateCount</code> 32551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * to retrieve the result, and <code>getMoreResults</code> to 32651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * move to any subsequent result(s). 32751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 32851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *<strong>Note:</strong>This method cannot be called on a 32951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code>. 33051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param sql any SQL statement 33151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return <code>true</code> if the first result is a <code>ResultSet</code> 33251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object; <code>false</code> if it is an update count or there are 33351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * no results 33451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 33551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code>, 33651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the method is called on a 33751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code> 33851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLTimeoutException when the driver has determined that the 33951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * timeout value that was specified by the {@code setQueryTimeout} 34051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method has been exceeded and has at least attempted to cancel 34151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the currently running {@code Statement} 34251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getResultSet 34351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getUpdateCount 34451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getMoreResults 34551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 34651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean execute(String sql) throws SQLException; 34751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 34851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 34951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Retrieves the current result as a <code>ResultSet</code> object. 35051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This method should be called only once per result. 35151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 35251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return the current result as a <code>ResultSet</code> object or 35351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>null</code> if the result is an update count or there are no more results 35451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 35551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 35651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #execute 35751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 35851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski ResultSet getResultSet() throws SQLException; 35951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 36051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 36151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Retrieves the current result as an update count; 36251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * if the result is a <code>ResultSet</code> object or there are no more results, -1 36351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is returned. This method should be called only once per result. 36451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 36551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return the current result as an update count; -1 if the current result is a 36651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>ResultSet</code> object or there are no more results 36751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 36851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 36951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #execute 37051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 37151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int getUpdateCount() throws SQLException; 37251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 37351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 37451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Moves to this <code>Statement</code> object's next result, returns 37551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>true</code> if it is a <code>ResultSet</code> object, and 37651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * implicitly closes any current <code>ResultSet</code> 37751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object(s) obtained with the method <code>getResultSet</code>. 37851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 37951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P>There are no more results when the following is true: 38051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <PRE> 38151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * // stmt is a Statement object 38251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * ((stmt.getMoreResults() == false) && (stmt.getUpdateCount() == -1)) 38351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * </PRE> 38451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 38551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return <code>true</code> if the next result is a <code>ResultSet</code> 38651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object; <code>false</code> if it is an update count or there are 38751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * no more results 38851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 38951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 39051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #execute 39151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 39251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean getMoreResults() throws SQLException; 39351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 39451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 39551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski //--------------------------JDBC 2.0----------------------------- 39651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 39751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 39851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 39951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Gives the driver a hint as to the direction in which 40051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * rows will be processed in <code>ResultSet</code> 40151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * objects created using this <code>Statement</code> object. The 40251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * default value is <code>ResultSet.FETCH_FORWARD</code>. 40351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P> 40451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Note that this method sets the default fetch direction for 40551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * result sets generated by this <code>Statement</code> object. 40651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Each result set has its own methods for getting and setting 40751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * its own fetch direction. 40851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 40951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param direction the initial direction for processing rows 41051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 41151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 41251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or the given direction 41351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is not one of <code>ResultSet.FETCH_FORWARD</code>, 41451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>ResultSet.FETCH_REVERSE</code>, or <code>ResultSet.FETCH_UNKNOWN</code> 41551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.2 41651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getFetchDirection 41751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 41851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski void setFetchDirection(int direction) throws SQLException; 41951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 42051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 42151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Retrieves the direction for fetching rows from 42251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * database tables that is the default for result sets 42351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * generated from this <code>Statement</code> object. 42451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If this <code>Statement</code> object has not set 42551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * a fetch direction by calling the method <code>setFetchDirection</code>, 42651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the return value is implementation-specific. 42751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 42851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return the default fetch direction for result sets generated 42951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * from this <code>Statement</code> object 43051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 43151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 43251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.2 43351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #setFetchDirection 43451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 43551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int getFetchDirection() throws SQLException; 43651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 43751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 43851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Gives the JDBC driver a hint as to the number of rows that should 43951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * be fetched from the database when more rows are needed for 44051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>ResultSet</code> objects genrated by this <code>Statement</code>. 44151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If the value specified is zero, then the hint is ignored. 44251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The default value is zero. 44351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 44451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param rows the number of rows to fetch 44551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 44651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> or the 44751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * condition <code>rows >= 0</code> is not satisfied. 44851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.2 44951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getFetchSize 45051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 45151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski void setFetchSize(int rows) throws SQLException; 45251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 45351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 45451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Retrieves the number of result set rows that is the default 45551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * fetch size for <code>ResultSet</code> objects 45651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * generated from this <code>Statement</code> object. 45751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If this <code>Statement</code> object has not set 45851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * a fetch size by calling the method <code>setFetchSize</code>, 45951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the return value is implementation-specific. 46051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 46151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return the default fetch size for result sets generated 46251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * from this <code>Statement</code> object 46351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 46451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 46551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.2 46651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #setFetchSize 46751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 46851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int getFetchSize() throws SQLException; 46951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 47051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 47151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Retrieves the result set concurrency for <code>ResultSet</code> objects 47251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * generated by this <code>Statement</code> object. 47351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 47451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return either <code>ResultSet.CONCUR_READ_ONLY</code> or 47551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>ResultSet.CONCUR_UPDATABLE</code> 47651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 47751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 47851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.2 47951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 48051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int getResultSetConcurrency() throws SQLException; 48151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 48251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 48351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Retrieves the result set type for <code>ResultSet</code> objects 48451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * generated by this <code>Statement</code> object. 48551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 48651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return one of <code>ResultSet.TYPE_FORWARD_ONLY</code>, 48751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or 48851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> 48951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 49051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 49151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.2 49251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 49351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int getResultSetType() throws SQLException; 49451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 49551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 49651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Adds the given SQL command to the current list of commmands for this 49751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement</code> object. The commands in this list can be 49851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * executed as a batch by calling the method <code>executeBatch</code>. 49951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P> 50051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *<strong>Note:</strong>This method cannot be called on a 50151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code>. 50251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param sql typically this is a SQL <code>INSERT</code> or 50351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>UPDATE</code> statement 50451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 50551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code>, the 50651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * driver does not support batch updates, the method is called on a 50751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code> 50851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #executeBatch 50951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see DatabaseMetaData#supportsBatchUpdates 51051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.2 51151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 51251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski void addBatch( String sql ) throws SQLException; 51351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 51451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 51551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Empties this <code>Statement</code> object's current list of 51651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * SQL commands. 51751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P> 51851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 51951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> or the 52051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * driver does not support batch updates 52151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #addBatch 52251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see DatabaseMetaData#supportsBatchUpdates 52351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.2 52451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 52551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski void clearBatch() throws SQLException; 52651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 52751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 52851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Submits a batch of commands to the database for execution and 52951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * if all commands execute successfully, returns an array of update counts. 53051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The <code>int</code> elements of the array that is returned are ordered 53151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * to correspond to the commands in the batch, which are ordered 53251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * according to the order in which they were added to the batch. 53351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The elements in the array returned by the method <code>executeBatch</code> 53451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * may be one of the following: 53551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <OL> 53651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <LI>A number greater than or equal to zero -- indicates that the 53751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * command was processed successfully and is an update count giving the 53851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * number of rows in the database that were affected by the command's 53951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * execution 54051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <LI>A value of <code>SUCCESS_NO_INFO</code> -- indicates that the command was 54151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * processed successfully but that the number of rows affected is 54251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * unknown 54351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P> 54451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * If one of the commands in a batch update fails to execute properly, 54551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method throws a <code>BatchUpdateException</code>, and a JDBC 54651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * driver may or may not continue to process the remaining commands in 54751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the batch. However, the driver's behavior must be consistent with a 54851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * particular DBMS, either always continuing to process commands or never 54951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * continuing to process commands. If the driver continues processing 55051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * after a failure, the array returned by the method 55151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>BatchUpdateException.getUpdateCounts</code> 55251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * will contain as many elements as there are commands in the batch, and 55351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * at least one of the elements will be the following: 55451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P> 55551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <LI>A value of <code>EXECUTE_FAILED</code> -- indicates that the command failed 55651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * to execute successfully and occurs only if a driver continues to 55751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * process commands after a command fails 55851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * </OL> 55951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P> 56051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The possible implementations and return values have been modified in 56151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the Java 2 SDK, Standard Edition, version 1.3 to 56251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * accommodate the option of continuing to proccess commands in a batch 56351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * update after a <code>BatchUpdateException</code> obejct has been thrown. 56451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 56551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return an array of update counts containing one element for each 56651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * command in the batch. The elements of the array are ordered according 56751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * to the order in which commands were added to the batch. 56851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 56951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> or the 57051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * driver does not support batch statements. Throws {@link BatchUpdateException} 57151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * (a subclass of <code>SQLException</code>) if one of the commands sent to the 57251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * database fails to execute properly or attempts to return a result set. 57351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLTimeoutException when the driver has determined that the 57451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * timeout value that was specified by the {@code setQueryTimeout} 57551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method has been exceeded and has at least attempted to cancel 57651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the currently running {@code Statement} 57751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 57851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #addBatch 57951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see DatabaseMetaData#supportsBatchUpdates 58051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.2 58151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 58251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int[] executeBatch() throws SQLException; 58351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 58451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 58551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Retrieves the <code>Connection</code> object 58651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * that produced this <code>Statement</code> object. 58751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return the connection that produced this statement 58851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 58951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 59051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.2 59151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 59251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski Connection getConnection() throws SQLException; 59351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 59451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski //--------------------------JDBC 3.0----------------------------- 59551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 59651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 59751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The constant indicating that the current <code>ResultSet</code> object 59851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * should be closed when calling <code>getMoreResults</code>. 59951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 60051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 60151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 60251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int CLOSE_CURRENT_RESULT = 1; 60351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 60451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 60551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The constant indicating that the current <code>ResultSet</code> object 60651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * should not be closed when calling <code>getMoreResults</code>. 60751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 60851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 60951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 61051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int KEEP_CURRENT_RESULT = 2; 61151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 61251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 61351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The constant indicating that all <code>ResultSet</code> objects that 61451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * have previously been kept open should be closed when calling 61551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>getMoreResults</code>. 61651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 61751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 61851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 61951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int CLOSE_ALL_RESULTS = 3; 62051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 62151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 62251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The constant indicating that a batch statement executed successfully 62351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * but that no count of the number of rows it affected is available. 62451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 62551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 62651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 62751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int SUCCESS_NO_INFO = -2; 62851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 62951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 63051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The constant indicating that an error occured while executing a 63151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * batch statement. 63251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 63351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 63451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 63551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int EXECUTE_FAILED = -3; 63651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 63751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 63851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The constant indicating that generated keys should be made 63951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * available for retrieval. 64051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 64151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 64251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 64351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int RETURN_GENERATED_KEYS = 1; 64451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 64551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 64651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The constant indicating that generated keys should not be made 64751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * available for retrieval. 64851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 64951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 65051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 65151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int NO_GENERATED_KEYS = 2; 65251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 65351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 65451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Moves to this <code>Statement</code> object's next result, deals with 65551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * any current <code>ResultSet</code> object(s) according to the instructions 65651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * specified by the given flag, and returns 65751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>true</code> if the next result is a <code>ResultSet</code> object. 65851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 65951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P>There are no more results when the following is true: 66051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <PRE> 66151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * // stmt is a Statement object 66251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * ((stmt.getMoreResults(current) == false) && (stmt.getUpdateCount() == -1)) 66351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * </PRE> 66451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 66551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param current one of the following <code>Statement</code> 66651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * constants indicating what should happen to current 66751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>ResultSet</code> objects obtained using the method 66851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>getResultSet</code>: 66951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement.CLOSE_CURRENT_RESULT</code>, 67051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement.KEEP_CURRENT_RESULT</code>, or 67151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement.CLOSE_ALL_RESULTS</code> 67251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return <code>true</code> if the next result is a <code>ResultSet</code> 67351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object; <code>false</code> if it is an update count or there are no 67451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * more results 67551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 67651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> or the argument 67751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * supplied is not one of the following: 67851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement.CLOSE_CURRENT_RESULT</code>, 67951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement.KEEP_CURRENT_RESULT</code> or 68051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement.CLOSE_ALL_RESULTS</code> 68151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *@exception SQLFeatureNotSupportedException if 68251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>DatabaseMetaData.supportsMultipleOpenResults</code> returns 68351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>false</code> and either 68451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement.KEEP_CURRENT_RESULT</code> or 68551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement.CLOSE_ALL_RESULTS</code> are supplied as 68651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the argument. 68751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 68851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #execute 68951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 69051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean getMoreResults(int current) throws SQLException; 69151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 69251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 69351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Retrieves any auto-generated keys created as a result of executing this 69451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement</code> object. If this <code>Statement</code> object did 69551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * not generate any keys, an empty <code>ResultSet</code> 69651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object is returned. 69751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 69851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *<p><B>Note:</B>If the columns which represent the auto-generated keys were not specified, 69951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the JDBC driver implementation will determine the columns which best represent the auto-generated keys. 70051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 70151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return a <code>ResultSet</code> object containing the auto-generated key(s) 70251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * generated by the execution of this <code>Statement</code> object 70351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 70451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 70551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method 70651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 70751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 70851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski ResultSet getGeneratedKeys() throws SQLException; 70951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 71051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 71151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Executes the given SQL statement and signals the driver with the 71251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * given flag about whether the 71351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * auto-generated keys produced by this <code>Statement</code> object 71451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * should be made available for retrieval. The driver will ignore the 71551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * flag if the SQL statement 71651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is not an <code>INSERT</code> statement, or an SQL statement able to return 71751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * auto-generated keys (the list of such statements is vendor-specific). 71851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *<p> 71951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <strong>Note:</strong>This method cannot be called on a 72051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code>. 72151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param sql an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or 72251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>DELETE</code>; or an SQL statement that returns nothing, 72351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * such as a DDL statement. 72451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 72551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param autoGeneratedKeys a flag indicating whether auto-generated keys 72651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * should be made available for retrieval; 72751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * one of the following constants: 72851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement.RETURN_GENERATED_KEYS</code> 72951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement.NO_GENERATED_KEYS</code> 73051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return either (1) the row count for SQL Data Manipulation Language (DML) statements 73151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or (2) 0 for SQL statements that return nothing 73251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 73351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 73451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code>, the given 73551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * SQL statement returns a <code>ResultSet</code> object, 73651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the given constant is not one of those allowed, the method is called on a 73751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code> 73851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLFeatureNotSupportedException if the JDBC driver does not support 73951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method with a constant of Statement.RETURN_GENERATED_KEYS 74051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLTimeoutException when the driver has determined that the 74151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * timeout value that was specified by the {@code setQueryTimeout} 74251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method has been exceeded and has at least attempted to cancel 74351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the currently running {@code Statement} 74451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 74551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 74651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException; 74751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 74851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 74951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Executes the given SQL statement and signals the driver that the 75051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * auto-generated keys indicated in the given array should be made available 75151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * for retrieval. This array contains the indexes of the columns in the 75251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * target table that contain the auto-generated keys that should be made 75351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * available. The driver will ignore the array if the SQL statement 75451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is not an <code>INSERT</code> statement, or an SQL statement able to return 75551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * auto-generated keys (the list of such statements is vendor-specific). 75651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *<p> 75751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <strong>Note:</strong>This method cannot be called on a 75851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code>. 75951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param sql an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or 76051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>DELETE</code>; or an SQL statement that returns nothing, 76151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * such as a DDL statement. 76251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 76351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param columnIndexes an array of column indexes indicating the columns 76451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * that should be returned from the inserted row 76551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return either (1) the row count for SQL Data Manipulation Language (DML) statements 76651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or (2) 0 for SQL statements that return nothing 76751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 76851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 76951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code>, the SQL 77051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * statement returns a <code>ResultSet</code> object,the second argument 77151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * supplied to this method is not an 77251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>int</code> array whose elements are valid column indexes, the method is called on a 77351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code> 77451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method 77551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLTimeoutException when the driver has determined that the 77651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * timeout value that was specified by the {@code setQueryTimeout} 77751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method has been exceeded and has at least attempted to cancel 77851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the currently running {@code Statement} 77951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 78051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 78151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int executeUpdate(String sql, int columnIndexes[]) throws SQLException; 78251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 78351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 78451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Executes the given SQL statement and signals the driver that the 78551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * auto-generated keys indicated in the given array should be made available 78651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * for retrieval. This array contains the names of the columns in the 78751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * target table that contain the auto-generated keys that should be made 78851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * available. The driver will ignore the array if the SQL statement 78951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is not an <code>INSERT</code> statement, or an SQL statement able to return 79051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * auto-generated keys (the list of such statements is vendor-specific). 79151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *<p> 79251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <strong>Note:</strong>This method cannot be called on a 79351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code>. 79451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param sql an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or 79551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>DELETE</code>; or an SQL statement that returns nothing, 79651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * such as a DDL statement. 79751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param columnNames an array of the names of the columns that should be 79851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * returned from the inserted row 79951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return either the row count for <code>INSERT</code>, <code>UPDATE</code>, 80051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or <code>DELETE</code> statements, or 0 for SQL statements 80151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * that return nothing 80251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 80351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code>, the SQL 80451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * statement returns a <code>ResultSet</code> object, the 80551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * second argument supplied to this method is not a <code>String</code> array 80651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * whose elements are valid column names, the method is called on a 80751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code> 80851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method 80951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLTimeoutException when the driver has determined that the 81051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * timeout value that was specified by the {@code setQueryTimeout} 81151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method has been exceeded and has at least attempted to cancel 81251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the currently running {@code Statement} 81351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 81451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 81551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int executeUpdate(String sql, String columnNames[]) throws SQLException; 81651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 81751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 81851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Executes the given SQL statement, which may return multiple results, 81951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * and signals the driver that any 82051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * auto-generated keys should be made available 82151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * for retrieval. The driver will ignore this signal if the SQL statement 82251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is not an <code>INSERT</code> statement, or an SQL statement able to return 82351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * auto-generated keys (the list of such statements is vendor-specific). 82451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P> 82551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * In some (uncommon) situations, a single SQL statement may return 82651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * multiple result sets and/or update counts. Normally you can ignore 82751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this unless you are (1) executing a stored procedure that you know may 82851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * return multiple results or (2) you are dynamically executing an 82951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * unknown SQL string. 83051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P> 83151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The <code>execute</code> method executes an SQL statement and indicates the 83251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * form of the first result. You must then use the methods 83351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>getResultSet</code> or <code>getUpdateCount</code> 83451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * to retrieve the result, and <code>getMoreResults</code> to 83551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * move to any subsequent result(s). 83651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *<p> 83751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *<strong>Note:</strong>This method cannot be called on a 83851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code>. 83951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param sql any SQL statement 84051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param autoGeneratedKeys a constant indicating whether auto-generated 84151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * keys should be made available for retrieval using the method 84251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>getGeneratedKeys</code>; one of the following constants: 84351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement.RETURN_GENERATED_KEYS</code> or 84451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement.NO_GENERATED_KEYS</code> 84551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return <code>true</code> if the first result is a <code>ResultSet</code> 84651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object; <code>false</code> if it is an update count or there are 84751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * no results 84851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 84951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code>, the second 85051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * parameter supplied to this method is not 85151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement.RETURN_GENERATED_KEYS</code> or 85251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement.NO_GENERATED_KEYS</code>, 85351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the method is called on a 85451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code> 85551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLFeatureNotSupportedException if the JDBC driver does not support 85651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method with a constant of Statement.RETURN_GENERATED_KEYS 85751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLTimeoutException when the driver has determined that the 85851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * timeout value that was specified by the {@code setQueryTimeout} 85951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method has been exceeded and has at least attempted to cancel 86051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the currently running {@code Statement} 86151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getResultSet 86251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getUpdateCount 86351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getMoreResults 86451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getGeneratedKeys 86551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 86651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 86751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 86851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean execute(String sql, int autoGeneratedKeys) throws SQLException; 86951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 87051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 87151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Executes the given SQL statement, which may return multiple results, 87251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * and signals the driver that the 87351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * auto-generated keys indicated in the given array should be made available 87451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * for retrieval. This array contains the indexes of the columns in the 87551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * target table that contain the auto-generated keys that should be made 87651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * available. The driver will ignore the array if the SQL statement 87751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is not an <code>INSERT</code> statement, or an SQL statement able to return 87851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * auto-generated keys (the list of such statements is vendor-specific). 87951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P> 88051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Under some (uncommon) situations, a single SQL statement may return 88151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * multiple result sets and/or update counts. Normally you can ignore 88251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this unless you are (1) executing a stored procedure that you know may 88351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * return multiple results or (2) you are dynamically executing an 88451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * unknown SQL string. 88551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P> 88651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The <code>execute</code> method executes an SQL statement and indicates the 88751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * form of the first result. You must then use the methods 88851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>getResultSet</code> or <code>getUpdateCount</code> 88951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * to retrieve the result, and <code>getMoreResults</code> to 89051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * move to any subsequent result(s). 89151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *<p> 89251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <strong>Note:</strong>This method cannot be called on a 89351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code>. 89451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param sql any SQL statement 89551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param columnIndexes an array of the indexes of the columns in the 89651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * inserted row that should be made available for retrieval by a 89751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * call to the method <code>getGeneratedKeys</code> 89851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return <code>true</code> if the first result is a <code>ResultSet</code> 89951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object; <code>false</code> if it is an update count or there 90051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * are no results 90151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 90251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code>, the 90351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * elements in the <code>int</code> array passed to this method 90451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * are not valid column indexes, the method is called on a 90551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code> 90651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method 90751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLTimeoutException when the driver has determined that the 90851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * timeout value that was specified by the {@code setQueryTimeout} 90951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method has been exceeded and has at least attempted to cancel 91051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the currently running {@code Statement} 91151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getResultSet 91251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getUpdateCount 91351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getMoreResults 91451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 91551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 91651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 91751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean execute(String sql, int columnIndexes[]) throws SQLException; 91851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 91951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 92051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Executes the given SQL statement, which may return multiple results, 92151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * and signals the driver that the 92251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * auto-generated keys indicated in the given array should be made available 92351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * for retrieval. This array contains the names of the columns in the 92451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * target table that contain the auto-generated keys that should be made 92551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * available. The driver will ignore the array if the SQL statement 92651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is not an <code>INSERT</code> statement, or an SQL statement able to return 92751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * auto-generated keys (the list of such statements is vendor-specific). 92851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P> 92951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * In some (uncommon) situations, a single SQL statement may return 93051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * multiple result sets and/or update counts. Normally you can ignore 93151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this unless you are (1) executing a stored procedure that you know may 93251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * return multiple results or (2) you are dynamically executing an 93351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * unknown SQL string. 93451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <P> 93551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The <code>execute</code> method executes an SQL statement and indicates the 93651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * form of the first result. You must then use the methods 93751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>getResultSet</code> or <code>getUpdateCount</code> 93851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * to retrieve the result, and <code>getMoreResults</code> to 93951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * move to any subsequent result(s). 94051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *<p> 94151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <strong>Note:</strong>This method cannot be called on a 94251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code>. 94351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param sql any SQL statement 94451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param columnNames an array of the names of the columns in the inserted 94551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * row that should be made available for retrieval by a call to the 94651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method <code>getGeneratedKeys</code> 94751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return <code>true</code> if the next result is a <code>ResultSet</code> 94851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * object; <code>false</code> if it is an update count or there 94951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * are no more results 95051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs, 95151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code>,the 95251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * elements of the <code>String</code> array passed to this 95351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method are not valid column names, the method is called on a 95451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>PreparedStatement</code> or <code>CallableStatement</code> 95551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method 95651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLTimeoutException when the driver has determined that the 95751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * timeout value that was specified by the {@code setQueryTimeout} 95851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method has been exceeded and has at least attempted to cancel 95951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the currently running {@code Statement} 96051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getResultSet 96151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getUpdateCount 96251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getMoreResults 96351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see #getGeneratedKeys 96451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 96551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 96651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 96751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean execute(String sql, String columnNames[]) throws SQLException; 96851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 96951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 97051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Retrieves the result set holdability for <code>ResultSet</code> objects 97151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * generated by this <code>Statement</code> object. 97251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 97351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return either <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or 97451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code> 97551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @exception SQLException if a database access error occurs or 97651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * this method is called on a closed <code>Statement</code> 97751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 97851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.4 97951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 98051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski int getResultSetHoldability() throws SQLException; 98151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 98251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 98351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Retrieves whether this <code>Statement</code> object has been closed. A <code>Statement</code> is closed if the 98451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * method close has been called on it, or if it is automatically closed. 98551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return true if this <code>Statement</code> object is closed; false if it is still open 98651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLException if a database access error occurs 98751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.6 98851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 98951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean isClosed() throws SQLException; 99051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 99151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 99251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Requests that a <code>Statement</code> be pooled or not pooled. The value 99351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * specified is a hint to the statement pool implementation indicating 99451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * whether the applicaiton wants the statement to be pooled. It is up to 99551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * the statement pool manager as to whether the hint is used. 99651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 99751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * The poolable value of a statement is applicable to both internal 99851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * statement caches implemented by the driver and external statement caches 99951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * implemented by application servers and other applications. 100051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 100151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * By default, a <code>Statement</code> is not poolable when created, and 100251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * a <code>PreparedStatement</code> and <code>CallableStatement</code> 100351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * are poolable when created. 100451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 100551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @param poolable requests that the statement be pooled if true and 100651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * that the statement not be pooled if false 100751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 100851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLException if this method is called on a closed 100951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement</code> 101051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 101151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.6 101251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 101351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski void setPoolable(boolean poolable) 101451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski throws SQLException; 101551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 101651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski /** 101751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Returns a value indicating whether the <code>Statement</code> 101851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is poolable or not. 101951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 102051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @return <code>true</code> if the <code>Statement</code> 102151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * is poolable; <code>false</code> otherwise 102251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 102351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @throws SQLException if this method is called on a closed 102451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <code>Statement</code> 102551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 102651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @since 1.6 102751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * <p> 102851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @see java.sql.Statement#setPoolable(boolean) setPoolable(boolean) 102951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */ 103051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski boolean isPoolable() 103151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski throws SQLException; 103251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski 103351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski} 1034