Name

Statement

Synopsis

The Statement interface is used to execute SQL statements. Statement objects are returned by the createStatement() method of Connection. The execute(), executeUpdate(), and executeQuery() methods each take a String parameter that contains a SQL statement. execute() returns a boolean value that indicates whether there is a ResultSet available. The ResultSet can then be retrieved with getResultSet(). executeUpdate() returns an update count and is used for INSERT, UPDATE, DELETE and other data manipulation statements. executeQuery() is used for SELECT statements, so it returns a ResultSet. JDBC 3.0 provides additional methods to retrieve generated keys and to provide better handling of multiple result sets. The getMoreResults() method (which takes an int), in conjunction with the new constants defined in the class, can be used to keep multiple ResultSet objects open per connection

public interface Statement {
// Public Constants
   public static final int CLOSE_ALL_RESULTS;                    // =3, 1.4
   public static final int CLOSE_CURRENT_RESULT;                 // =1, 1.4
   public static final int EXECUTE_FAILED;                       // =-3, 1.4
   public static final int KEEP_CURRENT_RESULT;                  // =2, 1.4
   public static final int NO_GENERATED_KEYS;                    // =2, 1.4
   public static final int RETURN_GENERATED_KEYS;                // =1, 1.4
   public static final int SUCCESS_NO_INFO;                      // =-2, 1.4
                  // Property Accessor Methods (by property name)
   public abstract java.sql.Connection getConnection(            // 1.2
        ) throws SQLException;  
   public abstract void setCursorName ...

Get Java Enterprise in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.