PreparedStatement

public interface PreparedStatement implements Statement
Known Indirect Subclasses

An object that represents a precompiled SQL statement.

A SQL statement is precompiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times.

Note: The setter methods (setShort, setString, and so on) for setting IN parameter values must specify types that are compatible with the defined SQL type of the input parameter. For instance, if the IN parameter has SQL type INTEGER, then the method setInt should be used.

If arbitrary parameter type conversions are required, the method setObject should be used with a target SQL type.

In the following example of setting a parameter, con represents an active connection:

   PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES
                                     SET SALARY = ? WHERE ID = ?");
   pstmt.setBigDecimal(1, 153833.00)
   pstmt.setInt(2, 110592)
 

Inherited Constant Summary

Public Method Summary

abstract void
addBatch()
Adds a set of parameters to this PreparedStatement object's batch of commands.
abstract void
clearParameters()
Clears the current parameter values immediately.
abstract boolean
execute()
Executes the SQL statement in this PreparedStatement object, which may be any kind of SQL statement.
abstract ResultSet
executeQuery()
Executes the SQL query in this PreparedStatement object and returns the ResultSet object generated by the query.
abstract int
executeUpdate()
Executes the SQL statement in this PreparedStatement object, which must be an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
abstract ResultSetMetaData
getMetaData()
Retrieves a ResultSetMetaData object that contains information about the columns of the ResultSet object that will be returned when this PreparedStatement object is executed.
abstract ParameterMetaData
getParameterMetaData()
Retrieves the number, types and properties of this PreparedStatement object's parameters.
abstract void
setArray(int parameterIndex, Array x)
Sets the designated parameter to the given java.sql.Array object.
abstract void
setAsciiStream(int parameterIndex, InputStream x, long length)
Sets the designated parameter to the given input stream, which will have the specified number of bytes.
abstract void
setAsciiStream(int parameterIndex, InputStream x)
Sets the designated parameter to the given input stream.
abstract void
setAsciiStream(int parameterIndex, InputStream x, int length)
Sets the designated parameter to the given input stream, which will have the specified number of bytes.
abstract void
setBigDecimal(int parameterIndex, BigDecimal x)
Sets the designated parameter to the given java.math.BigDecimal value.
abstract void
setBinaryStream(int parameterIndex, InputStream x, long length)
Sets the designated parameter to the given input stream, which will have the specified number of bytes.
abstract void
setBinaryStream(int parameterIndex, InputStream x)
Sets the designated parameter to the given input stream.
abstract void
setBinaryStream(int parameterIndex, InputStream x, int length)
Sets the designated parameter to the given input stream, which will have the specified number of bytes.
abstract void
setBlob(int parameterIndex, InputStream inputStream, long length)
Sets the designated parameter to a InputStream object.
abstract void
setBlob(int parameterIndex, InputStream inputStream)
Sets the designated parameter to a InputStream object.
abstract void
setBlob(int parameterIndex, Blob x)
Sets the designated parameter to the given java.sql.Blob object.
abstract void
setBoolean(int parameterIndex, boolean x)
Sets the designated parameter to the given Java boolean value.
abstract void
setByte(int parameterIndex, byte x)
Sets the designated parameter to the given Java byte value.
abstract void
setBytes(int parameterIndex, byte[] x)
Sets the designated parameter to the given Java array of bytes.
abstract void
setCharacterStream(int parameterIndex, Reader reader, long length)
Sets the designated parameter to the given Reader object, which is the given number of characters long.
abstract void
setCharacterStream(int parameterIndex, Reader reader, int length)
Sets the designated parameter to the given Reader object, which is the given number of characters long.
abstract void
setCharacterStream(int parameterIndex, Reader reader)
Sets the designated parameter to the given Reader object.
abstract void
setClob(int parameterIndex, Clob x)
Sets the designated parameter to the given java.sql.Clob object.
abstract void
setClob(int parameterIndex, Reader reader, long length)
Sets the designated parameter to a Reader object.
abstract void
setClob(int parameterIndex, Reader reader)
Sets the designated parameter to a Reader object.
abstract void
setDate(int parameterIndex, Date x)
Sets the designated parameter to the given java.sql.Date value using the default time zone of the virtual machine that is running the application.
abstract void
setDate(int parameterIndex, Date x, Calendar cal)
Sets the designated parameter to the given java.sql.Date value, using the given Calendar object.
abstract void
setDouble(int parameterIndex, double x)
Sets the designated parameter to the given Java double value.