|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||


public interface PreparedStatement

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)
Connection.prepareStatement(java.lang.String)
,
ResultSet

| Field Summary |
|---|
Fields inherited from interface java.sql.Statement ![]() |
|---|
CLOSE_ALL_RESULTS |
| Method Summary | |
|---|---|
void |
addBatch
Adds a set of parameters to this PreparedStatement
object's batch of commands. |
void |
clearParameters
Clears the current parameter values immediately. |
boolean |
execute
Executes the SQL statement in this PreparedStatement object,
which may be any kind of SQL statement. |
ResultSet |
executeQuery
Executes the SQL query in this PreparedStatement object
and returns the ResultSet object generated by the query. |
int |
executeUpdate
Executes the SQL statement in this PreparedStatement object,
which must be an SQL INSERT, UPDATE or
DELETE statement; or an SQL statement that returns nothing,
such as a DDL statement. |
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. |
ParameterMetaData |
getParameterMetaData
Retrieves the number, types and properties of this PreparedStatement object's parameters. |
void |
setArray
Sets the designated parameter to the given Array object. |
void |
setAsciiStream
Sets the designated parameter to the given input stream, which will have the specified number of bytes. |
void |
setBigDecimal
Sets the designated parameter to the given java.math.BigDecimal value. |
void |
setBinaryStream
Sets the designated parameter to the given input stream, which will have the specified number of bytes. |
void |
setBlob
Sets the designated parameter to the given Blob object. |
void |
setBoolean
Sets the designated parameter to the given Java boolean value. |
void |
setByte
Sets the designated parameter to the given Java byte value. |
void |
setBytes
Sets the designated parameter to the given Java array of bytes. |
void |
setCharacterStream
Sets the designated parameter to the given Reader
object, which is the given number of characters long. |
void |
setClob
Sets the designated parameter to the given Clob object. |
void |
setDate
Sets the designated parameter to the given java.sql.Date value. |
void |
setDate
Sets the designated parameter to the given java.sql.Date value,
using the given Calendar object. |
void |
setDouble
Sets the designated parameter to the given Java double value. |
void |
setFloat
Sets the designated parameter to the given Java float value. |
void |
setInt
Sets the designated parameter to the given Java int value. |
void |
setLong
Sets the designated parameter to the given Java long value. |
void |
setNull
Sets the designated parameter to SQL NULL. |
void |
setNull
Sets the designated parameter to SQL NULL. |
void |
setObject
Sets the value of the designated parameter using the given object. |
void |
setObject
Sets the value of the designated parameter with the given object. |
void |
setObject
Sets the value of the designated parameter with the given object. |
void |
setRef
Sets the designated parameter to the given REF(<structured-type>) value. |
void |
setShort
Sets the designated parameter to the given Java short value. |
void |
setString
Sets the designated parameter to the given Java String value. |
void |
setTime
Sets the designated parameter to the given java.sql.Time value. |
void |
setTime
Sets the designated parameter to the given java.sql.Time value,
using the given Calendar object. |
void |
setTimestamp
Sets the designated parameter to the given java.sql.Timestamp value. |
void |
setTimestamp
Sets the designated parameter to the given java.sql.Timestamp value,
using the given Calendar object. |
void |
setUnicodeStream
Deprecated. |
void |
setURL
Sets the designated parameter to the given java.net.URL value. |
Methods inherited from interface java.sql.Statement ![]() |
|---|
addBatch |
| Method Detail |
|---|

ResultSet![]()
![]()
executeQuery() throws SQLException
![]()
![]()
PreparedStatement object
and returns the ResultSet object generated by the query.
ResultSet object that contains the data produced by the
query; never null
SQLException

- if a database access error occurs or the SQL
statement does not return a ResultSet object

int executeUpdate()
throws SQLException

PreparedStatement object,
which must be an SQL INSERT, UPDATE or
DELETE statement; or an SQL statement that returns nothing,
such as a DDL statement.
INSERT, UPDATE,
or DELETE statements
or (2) 0 for SQL statements that return nothing
SQLException

- if a database access error occurs or the SQL
statement returns a ResultSet object

void setNull(int parameterIndex,
int sqlType)
throws SQLException

NULL.
Note: You must specify the parameter's SQL type.
parameterIndex - the first parameter is 1, the second is 2, ...sqlType - the SQL type code defined in java.sql.Types
SQLException

- if a database access error occurs

void setBoolean(int parameterIndex,
boolean x)
throws SQLException

boolean value.
The driver converts this
to an SQL BIT value when it sends it to the database.
parameterIndex - the first parameter is 1, the second is 2, ...x - the parameter value
SQLException

- if a database access error occurs

void setByte(int parameterIndex,
byte x)
throws SQLException

byte value.
The driver converts this
to an SQL TINYINT value when it sends it to the database.
parameterIndex - the first parameter is 1, the second is 2, ...x - the parameter value
SQLException

- if a database access error occurs

void setShort(int parameterIndex,
short x)
throws SQLException

short value.
The driver converts this
to an SQL SMALLINT value when it sends it to the database.
parameterIndex - the first parameter is 1, the second is 2, ...x - the parameter value
SQLException

- if a database access error occurs

void setInt(int parameterIndex,
int x)
throws SQLException

int value.
The driver converts this
to an SQL INTEGER value when it sends it to the database.
parameterIndex - the first parameter is 1, the second is 2, ...x - the parameter value
SQLException

- if a database access error occurs

void setLong(int parameterIndex,
long x)
throws SQLException

long value.
The driver converts this
to an SQL BIGINT value when it sends it to the database.
parameterIndex - the first parameter is 1, the second is 2, ...x - the parameter value
SQLException

- if a database access error occurs

void setFloat(int parameterIndex,
float x)
throws SQLException

float value.
The driver converts this
to an SQL FLOAT value when it sends it to the database.
parameterIndex - the first parameter is 1, the second is 2, ...x - the parameter value
SQLException

- if a database access error occurs

void setDouble(int parameterIndex,
double x)
throws SQLException

double value.
The driver converts this
to an SQL DOUBLE value when it sends it to the database.
parameterIndex - the first parameter is 1, the second is 2, ...x - the parameter value
SQLException

- if a database access error occurs

void setBigDecimal(int parameterIndex,
BigDecimal
x)
throws SQLException

java.math.BigDecimal value.
The driver converts this to an SQL NUMERIC value when
it sends it to the database.
parameterIndex - the first parameter is 1, the second is 2, ...x - the parameter value
SQLException

- if a database access error occurs

void setString(int parameterIndex,
String
x)
throws SQLException

String value.
The driver converts this
to an SQL VARCHAR or LONGVARCHAR value
(depending on the argument's
size relative to the driver's limits on VARCHAR values)
when it sends it to the database.
parameterIndex - the first parameter is 1, the second is 2, ...x - the parameter value
SQLException

- if a database access error occurs

void setBytes(int parameterIndex,
byte[] x)
throws SQLException

VARBINARY or LONGVARBINARY
(depending on the argument's size relative to the driver's limits on
VARBINARY values) when it sends it to the database.
parameterIndex - the first parameter is 1, the second is 2, ...x - the parameter value
SQLException

- if a database access error occurs