Methods Summary |
---|
public void | addBatch()Add a set of parameters to the {@code PreparedStatement}'s command batch.
|
public void | clearParameters()Clear the current parameter values.
Typically, parameter values are retained for multiple executions of the
{@code Statement}. Setting a parameter value replaces the previous value. This
method clears the values for all parameters, releasing all resources used
by those parameters.
|
public boolean | execute()Executes the SQL statement in this {@code PreparedStatement}.
A {@code PreparedStatement} may return multiple results. The execute
method executes the {@code PreparedStatement} and returns a flag
indicating the kind of result produced by the action. The methods
{@code getResultSet} or {@code getUpdateCount} are used to retrieve
the first result, and the second and subsequent results are
retrieved with {@code getMoreResults}.
|
public java.sql.ResultSet | executeQuery()Executes the SQL query in the {@code PreparedStatement} and returns the
{@code ResultSet} generated by the query.
|
public int | executeUpdate()Invokes the SQL command contained within the prepared statement. This
must be {@code INSERT}, {@code UPDATE}, {@code DELETE}, or a command that
returns nothing.
|
public java.sql.ResultSetMetaData | getMetaData()Returns a {@code ResultSetMetaData} describing the {@code
ResultSet} that would be produced by execution of the {@code PreparedStatement}.
It is possible to know the metadata for the {@code ResultSet} without
executing the {@code PreparedStatement}, because the {@code
PreparedStatement} is precompiled. As a result the metadata can be
queried ahead of time without actually executing the statement.
|
public java.sql.ParameterMetaData | getParameterMetaData()Gets information about the parameters of the {@code PreparedStatement}.
|
public void | setArray(int parameterIndex, java.sql.Array theArray)Sets the value of a specified parameter to the supplied {@code Array}.
|
public void | setAsciiStream(int parameterIndex, java.io.InputStream theInputStream, int length)Sets the value of a specified parameter to the content of a supplied
{@code InputStream}, which has a specified number of bytes.
This is a good method for setting an SQL {@code LONVARCHAR} parameter
where the length of the data is large. Data is read from the {@code
InputStream} until end-of-file is reached or the specified number of
bytes is copied.
|
public void | setBigDecimal(int parameterIndex, java.math.BigDecimal theBigDecimal)Sets the value of a specified parameter to a supplied {@code
java.math.BigDecimal} value.
|
public void | setBinaryStream(int parameterIndex, java.io.InputStream theInputStream, int length)Sets the value of a specified parameter to the content of a supplied
binary {@code InputStream}, which has a specified number of bytes.
Use this method when a large amount of data needs to be set into a
{@code LONGVARBINARY} parameter.
|
public void | setBlob(int parameterIndex, java.sql.Blob theBlob)Sets the value of a specified parameter to the given {@code Blob} object.
|
public void | setBoolean(int parameterIndex, boolean theBoolean)Sets the value of a specified parameter to a supplied {@code boolean}
value.
|
public void | setByte(int parameterIndex, byte theByte)Sets the value of a specified parameter to a supplied {@code byte} value.
|
public void | setBytes(int parameterIndex, byte[] theBytes)Sets the value of a specified parameter to a supplied array of bytes. The
array is mapped to a {@code VARBINARY} or {@code LONGVARBINARY} in the
database.
|
public void | setCharacterStream(int parameterIndex, java.io.Reader reader, int length)Sets the value of a specified parameter to the character content of a
{@code Reader} object, with the specified length of character data.
Data is read from the {@code
Reader} until end-of-file is reached or the specified number of
characters are copied.
|
public void | setClob(int parameterIndex, java.sql.Clob theClob)Sets the value of a specified parameter to the given {@code Clob} object.
|
public void | setDate(int parameterIndex, java.sql.Date theDate)Sets the value of a specified parameter to a supplied {@code
java.sql.Date} value.
|
public void | setDate(int parameterIndex, java.sql.Date theDate, java.util.Calendar cal)Sets the value of a specified parameter to a supplied {@code
java.sql.Date} value, using a supplied {@code Calendar} to map the Date.
The {@code Calendar} allows the application to control the timezone used
to compute the SQL {@code DATE} in the database - without the supplied
{@code Calendar}, the driver uses the default timezone of the Java
virtual machine.
|
public void | setDouble(int parameterIndex, double theDouble)Sets the value of a specified parameter to a supplied {@code double}
value.
|
public void | setFloat(int parameterIndex, float theFloat)Sets the value of a specified parameter to to a supplied {@code float}
value.
|
public void | setInt(int parameterIndex, int theInt)Sets the value of a specified parameter to a supplied {@code int} value.
|
public void | setLong(int parameterIndex, long theLong)Sets the value of a specified parameter to a supplied {@code long} value.
|
public void | setNull(int parameterIndex, int sqlType)Sets the value of a specified parameter to SQL {@code NULL}. Don't use
this version of {@code setNull} for User Defined Types (UDT) or
for REF type parameters.
|
public void | setNull(int paramIndex, int sqlType, java.lang.String typeName)Sets the value of a specified parameter to SQL {@code NULL}. This version
of {@code setNull} should be used for User Defined Types (UDTs)
and also REF types. UDTs can be {@code STRUCT}, {@code DISTINCT}, {@code
JAVA_OBJECT} and named array types.
Applications must provide the SQL type code and also a fully qualified
SQL type name when supplying a {@code 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.
|
public void | setObject(int parameterIndex, java.lang.Object theObject)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. {@code
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 {@code SQLData}, the JDBC driver calls
{@code SQLData.writeSQL} to write it to the SQL data stream. If the
object's class implements {@code Ref}, {@code Blob}, {@code Clob},
{@code Struct}, or {@code Array}, the driver passes it to the database as
a value of the corresponding SQL type.
|
public void | setObject(int parameterIndex, java.lang.Object theObject, int targetSqlType)Sets the value of a specified parameter using a supplied object.
The object is converted to the given {@code targetSqlType} before it is
sent to the database. If the object has a custom mapping (its class
implements the interface {@code SQLData}), the JDBC driver will call the method
{@code SQLData.writeSQL} to write it to the SQL data stream. If the
object's class implements {@code Ref}, {@code Blob}, {@code Clob},
{@code Struct}, or {@code Array}, the driver will pass it to the database
in the form of the relevant SQL type.
|
public void | setObject(int parameterIndex, java.lang.Object theObject, int targetSqlType, int scale)Sets the value of a specified parameter using a supplied object.
The object is converted to the given {@code targetSqlType} before it is
sent to the database. If the object has a custom mapping (its class
implements the interface {@code SQLData}), the JDBC driver will call the method
{@code SQLData.writeSQL} to write it to the SQL data stream. If the
object's class implements {@code Ref}, {@code Blob}, {@code Clob},
{@code Struct}, or {@code Array}, the driver will pass it to the database
in the form of the relevant SQL type.
|
public void | setRef(int parameterIndex, java.sql.Ref theRef)Sets the value of a specified parameter to a supplied {@code
REF()} value. This is stored as an SQL {@code REF}.
|
public void | setShort(int parameterIndex, short theShort)Sets the value of a specified parameter to a supplied {@code short}
value.
|
public void | setString(int parameterIndex, java.lang.String theString)Sets the value of a specified parameter to a supplied string.
|
public void | setTime(int parameterIndex, java.sql.Time theTime)Sets the value of a specified parameter to a supplied {@code
java.sql.Time} value.
|
public void | setTime(int parameterIndex, java.sql.Time theTime, java.util.Calendar cal)Sets the value of a specified parameter to a supplied {@code
java.sql.Time} value, using a supplied {@code Calendar}.
The driver uses the supplied {@code Calendar} to create the SQL {@code
TIME} value, which allows it to use a custom timezone - otherwise the
driver uses the default timezone of the Java virtual machine.
|
public void | setTimestamp(int parameterIndex, java.sql.Timestamp theTimestamp)Sets the value of a specified parameter to a supplied java.sql.Timestamp
value.
|
public void | setTimestamp(int parameterIndex, java.sql.Timestamp theTimestamp, java.util.Calendar cal)Sets the value of a specified parameter to a supplied {@code
java.sql.Timestamp} value, using the supplied {@code Calendar}.
The driver uses the supplied {@code Calendar} to create the SQL {@code
TIMESTAMP} value, which allows it to use a custom timezone - otherwise
the driver uses the default timezone of the Java virtual machine.
|
public void | setURL(int parameterIndex, java.net.URL theURL)Sets the value of a specified parameter to a supplied {@code
java.net.URL}.
|
public void | setUnicodeStream(int parameterIndex, java.io.InputStream theInputStream, int length)Sets the value of a specified parameter to the characters from a supplied
{@code InputStream}, with a specified number of bytes.
|