java.sql
public interface PreparedStatement extends Statement
Note that in this class parameter indices start at 1, not 0.
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO
Modifier and Type | Method and Description |
---|---|
void |
addBatch()
This method adds a set of parameters to the batch for JDBC 2.0.
|
void |
clearParameters()
This method clears all of the input parameter that have been
set on this statement.
|
boolean |
execute()
This method executes a prepared SQL query.
|
ResultSet |
executeQuery()
This method executes a prepared SQL query and returns its ResultSet.
|
int |
executeUpdate()
This method executes an SQL INSERT, UPDATE or DELETE statement.
|
ResultSetMetaData |
getMetaData()
This method returns meta data for the result set from this statement.
|
ParameterMetaData |
getParameterMetaData()
Returns information about the parameters set on this
PreparedStatement (see ParameterMetaData for a
detailed description of the provided information). |
void |
setArray(int index,
Array value)
This method sets the specified parameter from the given Java
Array value. |
void |
setAsciiStream(int index,
InputStream stream,
int count)
This method sets the specified parameter from the given Java
ASCII
InputStream value. |
void |
setBigDecimal(int index,
BigDecimal value)
This method sets the specified parameter from the given Java
java.math.BigDecimal value. |
void |
setBinaryStream(int index,
InputStream stream,
int count)
This method sets the specified parameter from the given Java
binary
InputStream value. |
void |
setBlob(int index,
Blob value)
This method sets the specified parameter from the given Java
Blob value. |
void |
setBoolean(int index,
boolean value)
This method sets the specified parameter from the given Java
boolean value. |
void |
setByte(int index,
byte value)
This method sets the specified parameter from the given Java
byte value. |
void |
setBytes(int index,
byte[] value)
This method sets the specified parameter from the given Java
byte array value. |
void |
setCharacterStream(int index,
Reader reader,
int count)
This method sets the specified parameter from the given Java
character
Reader value. |
void |
setClob(int index,
Clob value)
This method sets the specified parameter from the given Java
Clob value. |
void |
setDate(int index,
Date value)
This method sets the specified parameter from the given Java
java.sql.Date value. |
void |
setDate(int index,
Date value,
Calendar cal)
This method sets the specified parameter from the given Java
java.sql.Date value. |
void |
setDouble(int index,
double value)
This method sets the specified parameter from the given Java
double value. |
void |
setFloat(int index,
float value)
This method sets the specified parameter from the given Java
float value. |
void |
setInt(int index,
int value)
This method sets the specified parameter from the given Java
int value. |
void |
setLong(int index,
long value)
This method sets the specified parameter from the given Java
long value. |
void |
setNull(int index,
int sqlType)
This method populates the specified parameter with a SQL NULL value
for the specified type.
|
void |
setNull(int index,
int sqlType,
String typeName)
This method populates the specified parameter with a SQL NULL value
for the specified type.
|
void |
setObject(int index,
Object value)
This method sets the specified parameter from the given Java
Object value. |
void |
setObject(int index,
Object value,
int sqlType)
This method sets the specified parameter from the given Java
Object value. |
void |
setObject(int index,
Object value,
int sqlType,
int scale)
This method sets the specified parameter from the given Java
Object value. |
void |
setRef(int index,
Ref value)
This method sets the specified parameter from the given Java
Ref value. |
void |
setShort(int index,
short value)
This method sets the specified parameter from the given Java
short value. |
void |
setString(int index,
String value)
This method sets the specified parameter from the given Java
String value. |
void |
setTime(int index,
Time value)
This method sets the specified parameter from the given Java
java.sql.Time value. |
void |
setTime(int index,
Time value,
Calendar cal)
This method sets the specified parameter from the given Java
java.sql.Time value. |
void |
setTimestamp(int index,
Timestamp value)
This method sets the specified parameter from the given Java
java.sql.Timestamp value. |
void |
setTimestamp(int index,
Timestamp value,
Calendar cal)
This method sets the specified parameter from the given Java
java.sql.Timestamp value. |
void |
setUnicodeStream(int index,
InputStream stream,
int count)
Deprecated.
|
void |
setURL(int index,
URL value)
This method sets the specified parameter from the given Java
java.net.URL value. |
addBatch, cancel, clearBatch, clearWarnings, close, execute, execute, execute, execute, executeBatch, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setQueryTimeout
ResultSet executeQuery() throws SQLException
SQLException
- If an error occurs.int executeUpdate() throws SQLException
SQLException
- If an error occurs.void setNull(int index, int sqlType) throws SQLException
index
- The index of the parameter to set.sqlType
- The SQL type identifier of the parameter from
Types
SQLException
- If an error occurs.void setBoolean(int index, boolean value) throws SQLException
boolean
value.index
- The index of the parameter value to set.value
- The value of the parameter.SQLException
- If an error occurs.void setByte(int index, byte value) throws SQLException
byte
value.index
- The index of the parameter value to set.value
- The value of the parameter.SQLException
- If an error occurs.void setShort(int index, short value) throws SQLException
short
value.index
- The index of the parameter value to set.value
- The value of the parameter.SQLException
- If an error occurs.void setInt(int index, int value) throws SQLException
int
value.index
- The index of the parameter value to set.value
- The value of the parameter.SQLException
- If an error occurs.void setLong(int index, long value) throws SQLException
long
value.index
- The index of the parameter value to set.value
- The value of the parameter.SQLException
- If an error occurs.void setFloat(int index, float value) throws SQLException
float
value.index
- The index of the parameter value to set.value
- The value of the parameter.SQLException
- If an error occurs.void setDouble(int index, double value) throws SQLException
double
value.index
- The index of the parameter value to set.value
- The value of the parameter.SQLException
- If an error occurs.void setBigDecimal(int index, BigDecimal value) throws SQLException
java.math.BigDecimal
value.index
- The index of the parameter value to set.value
- The value of the parameter.SQLException
- If an error occurs.void setString(int index, String value) throws SQLException
String
value.index
- The index of the parameter value to set.value
- The value of the parameter.SQLException
- If an error occurs.void setBytes(int index, byte[] value) throws SQLException
byte
array value.index
- The index of the parameter value to set.value
- The value of the parameter.SQLException
- If an error occurs.void setDate(int index, Date value) throws SQLException
java.sql.Date
value.index
- The index of the parameter value to set.value
- The value of the parameter.SQLException
- If an error occurs.void setTime(int index, Time value) throws SQLException
java.sql.Time
value.index
- The index of the parameter value to set.value
- The value of the parameter.SQLException
- If an error occurs.void setTimestamp(int index, Timestamp value) throws SQLException
java.sql.Timestamp
value.index
- The index of the parameter value to set.value
- The value of the parameter.SQLException
- If an error occurs.void setAsciiStream(int index, InputStream stream, int count) throws SQLException
InputStream
value.index
- The index of the parameter value to set.stream
- The stream from which the parameter value is read.count
- The number of bytes in the stream.SQLException
- If an error occurs.void setUnicodeStream(int index, InputStream stream, int count) throws SQLException
InputStream
value.index
- The index of the parameter value to set.stream
- The stream from which the parameter value is read.count
- The number of bytes in the stream.SQLException
- If an error occurs.void setBinaryStream(int index, InputStream stream, int count) throws SQLException
InputStream
value.index
- The index of the parameter value to set.stream
- The stream from which the parameter value is read.count
- The number of bytes in the stream.SQLException
- If an error occurs.void clearParameters() throws SQLException
SQLException
- If an error occurs.void setObject(int index, Object value, int sqlType, int scale) throws SQLException
Object
value. The specified SQL object type will be used.index
- The index of the parameter value to set.value
- The value of the parameter.sqlType
- The SQL type to use for the parameter, from
Types
scale
- The scale of the value, for numeric values only.SQLException
- If an error occurs.Types
void setObject(int index, Object value, int sqlType) throws SQLException
Object
value. The specified SQL object type will be used.index
- The index of the parameter value to set.value
- The value of the parameter.sqlType
- The SQL type to use for the parameter, from
Types
SQLException
- If an error occurs.Types
void setObject(int index, Object value) throws SQLException
Object
value. The default object type to SQL type mapping
will be used.index
- The index of the parameter value to set.value
- The value of the parameter.SQLException
- If an error occurs.boolean execute() throws SQLException
SQLException
- If an error occurs.void addBatch() throws SQLException
SQLException
- If an error occurs.void setCharacterStream(int index, Reader reader, int count) throws SQLException
Reader
value.index
- The index of the parameter value to set.reader
- The reader from which the parameter value is read.count
- The number of characters in the stream.SQLException
- If an error occurs.void setRef(int index, Ref value) throws SQLException
Ref
value. The default object type to SQL type mapping
will be used.index
- The index of the parameter value to set.value
- The Ref
used to set the value of the parameter.SQLException
- If an error occurs.void setBlob(int index, Blob value) throws SQLException
Blob
value. The default object type to SQL type mapping
will be used.index
- The index of the parameter value to set.value
- The Blob
used to set the
value of the parameter.SQLException
- If an error occurs.void setClob(int index, Clob value) throws SQLException
Clob
value. The default object type to SQL type mapping
will be used.index
- The index of the parameter value to set.value
- The Clob
used to set the
value of the parameter.SQLException
- If an error occurs.void setArray(int index, Array value) throws SQLException
Array
value. The default object type to SQL type mapping
will be used.index
- The index of the parameter value to set.value
- The value of the parameter.SQLException
- If an error occurs.ResultSetMetaData getMetaData() throws SQLException
SQLException
- If an error occurs.void setDate(int index, Date value, Calendar cal) throws SQLException
java.sql.Date
value.index
- The index of the parameter value to set.value
- The value of the parameter.cal
- The Calendar
to use for timezone and locale.SQLException
- If an error occurs.void setTime(int index, Time value, Calendar cal) throws SQLException
java.sql.Time
value.index
- The index of the parameter value to set.value
- The value of the parameter.cal
- The Calendar
to use for timezone and locale.SQLException
- If an error occurs.void setTimestamp(int index, Timestamp value, Calendar cal) throws SQLException
java.sql.Timestamp
value.index
- The index of the parameter value to set.value
- The value of the parameter.cal
- The Calendar
to use for timezone and locale.SQLException
- If an error occurs.void setNull(int index, int sqlType, String typeName) throws SQLException
index
- The index of the parameter to set.sqlType
- The SQL type identifier of the parameter from
Types
typeName
- The name of the data type, for user defined types.SQLException
- If an error occurs.void setURL(int index, URL value) throws SQLException
java.net.URL
value.index
- The index of the parameter to set.value
- The value of the parameter.SQLException
- If an error occurs.ParameterMetaData getParameterMetaData() throws SQLException
PreparedStatement
(see ParameterMetaData
for a
detailed description of the provided information).SQLException
ParameterMetaData