public
interfacePreparedStatement
extends
Statement
Overview
Inheritance
Members
Usage
Source
Books
SinceNot specified.
VersionNot specified.
Author(s)Not specified.
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)
A SQL statement is precompiled and stored in a
PreparedStatementobject. 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 typeINTEGER, then the methodsetIntshould be used.If arbitrary parameter type conversions are required, the method
setObjectshould be used with a target SQL type.In the following example of setting a parameter,
conrepresents an active connection:PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES SET SALARY = ? WHERE ID = ?"); pstmt.setBigDecimal(1, 153833.00) pstmt.setInt(2, 110592)