Name

PreparedStatement

Synopsis

The PreparedStatement interface allows programs to precompile SQL statements for increased performance. You obtain a PreparedStatement object with the prepareStatement() method of Connection. Parameters in the statement are denoted by ? characters in the SQL string and indexed from 1 to n. Individual parameter values are set using the setXXX() methods, while the clearParameters() method clears all the parameters. Note that some JDBC drivers do not implement setObject() properly when dealing with null field types. Once all parameters have been set, the statement is executed using execute(), executeQuery(), or executeUpdate(). Unlike with the Statement object, the execution methods take no parameters.

                  Returned By
public interface PreparedStatement extends java.sql.Statement {
// Public Instance Methods
   public abstract void addBatch() throws SQLException;          // 1.2
   public abstract void clearParameters(
        ) throws SQLException;  
   public abstract boolean execute() throws SQLException;  
   public abstract java.sql.ResultSet executeQuery(
        ) throws SQLException;  
   public abstract int executeUpdate() throws SQLException;  
   public abstract ResultSetMetaData getMetaData(                // 1.2
        ) throws SQLException;  
   public abstract ParameterMetaData getParameterMetaData(       // 1.4
        ) throws SQLException;  
   public abstract void setArray(int i,                          // 1.2
        java.sql.Array x) throws SQLException; public abstract void ...

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.