java.sql.PreparedStatement |
Known Indirect Subclasses |
An interface for a precompiled SQL Statement.
An SQL Statement is put into a PreparedStatement
and is precompiled
so that it can be executed efficiently multiple times.
Setter methods are supplied in the PreparedStatement
interface for
the setting of IN
parameters for the statement. The setter method
used for each IN
parameter must match the parameter's type.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
java.sql.Statement
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add a set of parameters to the
PreparedStatement 's command batch. | |||||||||||
Clear the current parameter values.
| |||||||||||
Executes the SQL statement in this
PreparedStatement . | |||||||||||
Executes the SQL query in the
PreparedStatement and returns the
ResultSet generated by the query. | |||||||||||
Invokes the SQL command contained within the prepared statement.
| |||||||||||
Returns a
ResultSetMetaData describing the ResultSet that would be produced by execution of the PreparedStatement . | |||||||||||
Gets information about the parameters of the
PreparedStatement . | |||||||||||
Sets the value of a specified parameter to the supplied
Array . | |||||||||||
Sets the value of a specified parameter to the content of a supplied
InputStream , which has a specified number of bytes. | |||||||||||
Sets the value of the specified parameter to the bytes
from
inputStream . | |||||||||||
Sets the value of the specified parameter to the next
length bytes
from inputStream . | |||||||||||
Sets the value of a specified parameter to a supplied
java.math.BigDecimal value. | |||||||||||
Sets the value of the specified parameter to the bytes
from
inputStream . | |||||||||||
Sets the value of the specified parameter to the next
length bytes
from inputStream . | |||||||||||
Sets the value of a specified parameter to the content of a supplied
binary
InputStream , which has a specified number of bytes. | |||||||||||
Sets the value of the specified parameter to the next
length bytes
from inputStream . | |||||||||||
Sets the value of the specified parameter to the bytes
from
inputStream . | |||||||||||
Sets the value of a specified parameter to the given
Blob object. | |||||||||||
Sets the value of a specified parameter to a supplied
boolean
value. | |||||||||||
Sets the value of a specified parameter to a supplied
byte value. | |||||||||||
Sets the value of a specified parameter to a supplied array of bytes.
| |||||||||||
Sets the value of the specified parameter to the characters
from
reader . | |||||||||||
Sets the value of a specified parameter to the character content of a
Reader object, with the specified length of character data. | |||||||||||
Sets the value of the specified parameter to the next
length characters
from reader . | |||||||||||
Sets the value of the specified parameter to the characters
from
reader . | |||||||||||
Sets the value of the specified parameter to the next
length characters
from reader . | |||||||||||
Sets the value of a specified parameter to the given
Clob object. | |||||||||||
Sets the value of a specified parameter to a supplied
java.sql.Date value, using a supplied Calendar to map the Date. | |||||||||||
Sets the value of a specified parameter to a supplied
java.sql.Date value. | |||||||||||
Sets the value of a specified parameter to a supplied
double
value. | |||||||||||
Sets the value of a specified parameter to to a supplied
float
value. | |||||||||||
Sets the value of a specified parameter to a supplied
int value. | |||||||||||
Sets the value of a specified parameter to a supplied
long value. | |||||||||||
Sets the value of the specified parameter to the characters
from
reader . | |||||||||||
Sets the value of the specified parameter to the next
length characters
from reader . | |||||||||||
Sets the value of the specified parameter to the characters
from
reader . | |||||||||||
Sets the value of the specified parameter to
value . | |||||||||||
Sets the value of the specified parameter to the next
length characters
from reader . | |||||||||||
Sets the value of a specified parameter to a supplied string.
| |||||||||||
Sets the value of a specified parameter to SQL
NULL . | |||||||||||
Sets the value of a specified parameter to SQL
NULL . | |||||||||||
Sets the value of a specified parameter using a supplied object.
| |||||||||||
Sets the value of a specified parameter using a supplied object.
| |||||||||||
Sets the value of a specified parameter using a supplied object.
| |||||||||||
Sets the value of a specified parameter to a supplied
REF( value. | |||||||||||
Sets the value of a specified parameter to a supplied
java.sql.RowId . | |||||||||||
Sets the value of the specified parameter to the value of
xmlObject . | |||||||||||
Sets the value of a specified parameter to a supplied
short
value. | |||||||||||
Sets the value of a specified parameter to a supplied string.
| |||||||||||
Sets the value of a specified parameter to a supplied
java.sql.Time value. | |||||||||||
Sets the value of a specified parameter to a supplied
java.sql.Time value, using a supplied Calendar . | |||||||||||
Sets the value of a specified parameter to a supplied
java.sql.Timestamp value, using the supplied Calendar . | |||||||||||
Sets the value of a specified parameter to a supplied java.sql.Timestamp
value.
| |||||||||||
Sets the value of a specified parameter to a supplied
java.net.URL . | |||||||||||
This method is deprecated.
Use
setCharacterStream(int, Reader, int) |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
java.sql.Statement
| |||||||||||
From interface
java.sql.Wrapper
|
Add a set of parameters to the PreparedStatement
's command batch.
SQLException | if a database error happens. |
---|
Clear the current parameter values.
Typically, parameter values are retained for multiple executions of the
Statement
. Setting a parameter value replaces the previous value. This
method clears the values for all parameters, releasing all resources used
by those parameters.
SQLException | if a database error happens. |
---|
Executes the SQL statement in this PreparedStatement
.
A PreparedStatement
may return multiple results. The execute
method executes the PreparedStatement
and returns a flag
indicating the kind of result produced by the action. The methods
getResultSet
or getUpdateCount
are used to retrieve
the first result, and the second and subsequent results are
retrieved with getMoreResults
.
true
if the result of the execution is a ResultSet
, false
if there is no result or if the result
is an update count.SQLException | if a database error happens. |
---|
Executes the SQL query in the PreparedStatement
and returns the
ResultSet
generated by the query.
ResultSet
generated by the query, never null
.SQLException | if a database error happens or if the SQL statement does not
produce a ResultSet .
|
---|
Invokes the SQL command contained within the prepared statement. This
must be INSERT
, UPDATE
, DELETE
, or a command that
returns nothing.
INSERT
, UPDATE
or DELETE
statements, 0
for statements that return nothing.SQLException | if a database error happens or if the SQL statement returns a
ResultSet .
|
---|
Returns a ResultSetMetaData
describing the ResultSet
that would be produced by execution of the PreparedStatement
.
It is possible to know the metadata for the ResultSet
without
executing the PreparedStatement
, because the PreparedStatement
is precompiled. As a result the metadata can be
queried ahead of time without actually executing the statement.
ResultSetMetaData
object with the information about the
columns of the ResultSet
, if the driver can return a
ResultSetMetaData
. null
otherwise.SQLException | if there is a database error. |
---|
Gets information about the parameters of the PreparedStatement
.
ParameterMetaData
object which holds information about
the number, type, and properties of the parameters of this PreparedStatement
.SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to the supplied Array
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theArray | a java.sql.Array giving the new value of the parameter at parameterIndex . |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to the content of a supplied
InputStream
, which has a specified number of bytes.
This is a good method for setting an SQL LONGVARCHAR
parameter
where the length of the data is large. Data is read from the InputStream
until end-of-file is reached or the specified number of
bytes is copied.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theInputStream | the ASCII InputStream carrying the data to which the
parameter at parameterIndex is set. |
length | the number of bytes in the InputStream to copy to the
parameter. |
SQLException | if a database error happens. |
---|
Sets the value of the specified parameter to the bytes
from inputStream
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
inputStream | the InputStream |
SQLException | if a database error happens. |
---|
Sets the value of the specified parameter to the next length
bytes
from inputStream
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
inputStream | the InputStream |
length | character count |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied java.math.BigDecimal
value.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theBigDecimal | the value to which the parameter at parameterIndex is
set. |
SQLException | if a database error happens. |
---|
Sets the value of the specified parameter to the bytes
from inputStream
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
inputStream | the InputStream |
SQLException | if a database error happens. |
---|
Sets the value of the specified parameter to the next length
bytes
from inputStream
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
inputStream | the InputStream |
length | character count |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to the content of a supplied
binary InputStream
, which has a specified number of bytes.
Use this method when a large amount of data needs to be set into a
LONGVARBINARY
parameter.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theInputStream | the binary InputStream carrying the data to update the
parameter. |
length | the number of bytes in the InputStream to copy to the
parameter. |
SQLException | if a database error happens. |
---|
Sets the value of the specified parameter to the next length
bytes
from inputStream
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
inputStream | the InputStream |
length | character count |
SQLException | if a database error happens. |
---|
Sets the value of the specified parameter to the bytes
from inputStream
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
inputStream | the InputStream |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to the given Blob
object.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theBlob | the java.sql.Blob to which the parameter at parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied boolean
value.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theBoolean | the boolean value to which the parameter at parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied byte
value.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theByte | the byte value to which the parameter at parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied array of bytes. The
array is mapped to a VARBINARY
or LONGVARBINARY
in the
database.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theBytes | the array of bytes to which the parameter at parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of the specified parameter to the characters
from reader
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
reader | the Reader |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to the character content of a
Reader
object, with the specified length of character data.
Data is read from the Reader
until end-of-file is reached or the specified number of
characters are copied.
parameterIndex | the parameter number index, where the first parameter has index 1 |
---|---|
reader | the java.io.Reader containing the character data. |
length | the number of characters to be read. |
SQLException | if a database error happens. |
---|
Sets the value of the specified parameter to the next length
characters
from reader
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
reader | the Reader |
length | character count |
SQLException | if a database error happens. |
---|
Sets the value of the specified parameter to the characters
from reader
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
reader | the Reader |
SQLException | if a database error happens. |
---|
Sets the value of the specified parameter to the next length
characters
from reader
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
reader | the Reader |
length | character count |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to the given Clob
object.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theClob | a java.sql.Clob holding the data to which the
parameter at parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied java.sql.Date
value, using a supplied Calendar
to map the Date.
The Calendar
allows the application to control the timezone used
to compute the SQL DATE
in the database - without the supplied
Calendar
, the driver uses the default timezone of the Java
virtual machine.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theDate | a java.sql.Date to which the parameter at parameterIndex is set. |
cal | a Calendar to use to construct the SQL DATE
value. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied java.sql.Date
value.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theDate | a java.sql.Date to which the parameter at parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied double
value.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theDouble | the double value to which the parameter at parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to to a supplied float
value.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theFloat | the float value to update the parameter. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied int
value.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theInt | the int value to which the parameter at parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied long
value.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theLong | the long value to which the parameter at parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of the specified parameter to the characters
from reader
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
reader | the Reader |
SQLException | if a database error happens. |
---|
Sets the value of the specified parameter to the next length
characters
from reader
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
reader | the Reader |
length | character count |
SQLException | if a database error happens. |
---|
Sets the value of the specified parameter to the characters
from reader
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
reader | the Reader |
SQLException | if a database error happens. |
---|
Sets the value of the specified parameter to value
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
value | the NClob to which the parameter at parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of the specified parameter to the next length
characters
from reader
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
reader | the Reader |
length | character count |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied string.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theString | the String to which the parameter at parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to SQL NULL
. Don't use
this version of setNull
for User Defined Types (UDT) or
for REF type parameters.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
sqlType | the SQL type of the parameter, as defined in java.sql.Types . |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to SQL NULL
. This version
of setNull
should be used for User Defined Types (UDTs)
and also REF types. UDTs can be STRUCT
, DISTINCT
, JAVA_OBJECT
and named array types.
Applications must provide the SQL type code and also a fully qualified
SQL type name when supplying a NULL
UDT or REF. For a UDT, the
type name is the type name of the parameter itself, but for a REF
parameter the type name is the type name of the referenced type.
paramIndex | the parameter number index, where the first parameter has index 1. |
---|---|
sqlType | the SQL type of the parameter, as defined in java.sql.Types . |
typeName | the fully qualified name of a UDT or REF type - ignored if the parameter is not a UDT. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter using a supplied object.
There is a standard mapping from Java types to SQL types, defined in the
JDBC specification. The passed object is then transformed into the
appropriate SQL type, and then transferred to the database. setObject
can be used to pass abstract data types unique to the
database, by using a JDBC driver specific Java type. If the object's
class implements the interface SQLData
, the JDBC driver calls
SQLData.writeSQL
to write it to the SQL data stream. If the
object's class implements Ref
, Blob
, Clob
,
Struct
, or Array
, the driver passes it to the database as
a value of the corresponding SQL type.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theObject | the object containing the value to which the parameter at
parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter using a supplied object.
The object is converted to the given targetSqlType
before it is
sent to the database. If the object has a custom mapping (its class
implements the interface SQLData
), the JDBC driver will call the method
SQLData.writeSQL
to write it to the SQL data stream. If the
object's class implements Ref
, Blob
, Clob
,
Struct
, or Array
, the driver will pass it to the database
in the form of the relevant SQL type.
parameterIndex | the parameter index, where the first parameter has index 1. |
---|---|
theObject | the Object containing the value to which the parameter at
parameterIndex is set. |
targetSqlType | the SQL type to send to the database, as defined in java.sql.Types . |
scale | the number of digits after the decimal point - only applies to
the types java.sql.Types.DECIMAL and java.sql.Types.NUMERIC - ignored for all other types. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter using a supplied object.
The object is converted to the given targetSqlType
before it is
sent to the database. If the object has a custom mapping (its class
implements the interface SQLData
), the JDBC driver will call the method
SQLData.writeSQL
to write it to the SQL data stream. If the
object's class implements Ref
, Blob
, Clob
,
Struct
, or Array
, the driver will pass it to the database
in the form of the relevant SQL type.
parameterIndex | the parameter index, where the first parameter has index 1. |
---|---|
theObject | the Object containing the value to which the parameter at
parameterIndex is set. |
targetSqlType | the SQL type to send to the database, as defined in java.sql.Types . |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied REF(
value. This is stored as an SQL REF
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theRef | a java.sql.Ref value to which the parameter at parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied java.sql.RowId
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theRowId | the RowId to which the parameter at parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of the specified parameter to the value of xmlObject
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
xmlObject | the SQLXML |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied short
value.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theShort | a short value to which the parameter at parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied string.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theString | the value to which the parameter at parameterIndex is
set. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied java.sql.Time
value.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theTime | a java.sql.Time value to which the parameter at
parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied java.sql.Time
value, using a supplied Calendar
.
The driver uses the supplied Calendar
to create the SQL TIME
value, which allows it to use a custom timezone - otherwise the
driver uses the default timezone of the Java virtual machine.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theTime | a java.sql.Time value to which the parameter at
parameterIndex is set. |
cal | a Calendar to use to construct the SQL TIME
value. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied java.sql.Timestamp
value, using the supplied Calendar
.
The driver uses the supplied Calendar
to create the SQL TIMESTAMP
value, which allows it to use a custom timezone - otherwise
the driver uses the default timezone of the Java virtual machine.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theTimestamp | the java.sql.Timestamp value to which the parameter at
parameterIndex is set. |
cal | a Calendar to use to construct the SQL TIMESTAMP value |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied java.sql.Timestamp value.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theTimestamp | the java.sql.Timestamp value to which the parameter at parameterIndex is set. |
SQLException | if a database error happens. |
---|
Sets the value of a specified parameter to a supplied java.net.URL
.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theURL | the URL to which the parameter at parameterIndex is set. |
SQLException | if a database error happens. |
---|
This method is deprecated.
Use setCharacterStream(int, Reader, int)
Sets the value of a specified parameter to the characters from a supplied
InputStream
, with a specified number of bytes.
parameterIndex | the parameter number index, where the first parameter has index 1. |
---|---|
theInputStream | the InputStream with the character data to which the
parameter at parameterIndex is set. |
length | the number of bytes to read from the InputStream . |
SQLException | if a database error happens. |
---|