public class JDBCPreparedStatement extends JDBCStatement implements PreparedStatement
conn, maxrows, rs, updcntCLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO| Constructor and Description |
|---|
JDBCPreparedStatement(JDBCConnection conn,
String sql) |
| Modifier and Type | Method and Description |
|---|---|
void |
addBatch()
Add a set of parameters to the
PreparedStatement's command batch. |
void |
clearBatch()
Clears the current list of SQL commands for this statement.
|
void |
clearParameters()
Clear the current parameter values.
|
void |
close()
Releases this statement's database and JDBC driver resources.
|
boolean |
execute()
Executes the SQL statement in this
PreparedStatement. |
int[] |
executeBatch()
Submits a batch of SQL commands to the database.
|
ResultSet |
executeQuery()
Executes the SQL query in the
PreparedStatement and returns the
ResultSet generated by the query. |
int |
executeUpdate()
Invokes the SQL command contained within the prepared statement.
|
Array |
getArray(int parameterIndex) |
Array |
getArray(String parameterName) |
BigDecimal |
getBigDecimal(String parameterName) |
Blob |
getBlob(int parameterIndex) |
Blob |
getBlob(String parameterName) |
boolean |
getBoolean(String parameterName) |
byte |
getByte(String parameterName) |
byte[] |
getBytes(String parameterName) |
Clob |
getClob(int parameterIndex) |
Clob |
getClob(String parameterName) |
Date |
getDate(int parameterIndex,
Calendar cal) |
Date |
getDate(String parameterName) |
Date |
getDate(String parameterName,
Calendar cal) |
double |
getDouble(String parameterName) |
float |
getFloat(String parameterName) |
int |
getInt(String parameterName) |
long |
getLong(String parameterName) |
ResultSetMetaData |
getMetaData()
Returns a
ResultSetMetaData describing the ResultSet that would be produced by execution of the PreparedStatement. |
Object |
getObject(int parameterIndex) |
Object |
getObject(int parameterIndex,
Map map) |
Object |
getObject(String parameterName) |
Object |
getObject(String parameterName,
Map map) |
ParameterMetaData |
getParameterMetaData()
Gets information about the parameters of the
PreparedStatement. |
Ref |
getRef(int parameterIndex) |
Ref |
getRef(String parameterName) |
short |
getShort(String parameterName) |
String |
getString(String parameterName) |
Time |
getTime(int parameterIndex,
Calendar cal) |
Time |
getTime(String parameterName) |
Time |
getTime(String parameterName,
Calendar cal) |
Timestamp |
getTimestamp(int parameterIndex,
Calendar cal) |
Timestamp |
getTimestamp(String parameterName) |
Timestamp |
getTimestamp(String parameterName,
Calendar cal) |
URL |
getURL(int parameterIndex) |
URL |
getURL(String parameterName) |
void |
registerOutputParameter(String parameterName,
int sqlType) |
void |
registerOutputParameter(String parameterName,
int sqlType,
int scale) |
void |
registerOutputParameter(String parameterName,
int sqlType,
String typeName) |
void |
setArray(int i,
Array x)
Sets the value of a specified parameter to the supplied
Array. |
void |
setAsciiStream(int parameterIndex,
InputStream x)
Sets the value of the specified parameter to the bytes
from
inputStream. |
void |
setAsciiStream(int parameterIndex,
InputStream x,
int length)
Sets the value of a specified parameter to the content of a supplied
InputStream, which has a specified number of bytes. |
void |
setAsciiStream(int parameterIndex,
InputStream x,
long len)
Sets the value of the specified parameter to the next
length bytes
from inputStream. |
void |
setAsciiStream(String parameterName,
InputStream x) |
void |
setAsciiStream(String parameterName,
InputStream s,
int length) |
void |
setAsciiStream(String parameterName,
InputStream x,
long len) |
void |
setBigDecimal(int parameterIndex,
BigDecimal x)
Sets the value of a specified parameter to a supplied
java.math.BigDecimal value. |
void |
setBigDecimal(String parameterName,
BigDecimal val) |
void |
setBinaryStream(int parameterIndex,
InputStream x)
Sets the value of the specified parameter to the bytes
from
inputStream. |
void |
setBinaryStream(int parameterIndex,
InputStream x,
int length)
Sets the value of a specified parameter to the content of a supplied
binary
InputStream, which has a specified number of bytes. |
void |
setBinaryStream(int parameterIndex,
InputStream x,
long len)
Sets the value of the specified parameter to the next
length bytes
from inputStream. |
void |
setBinaryStream(String parameterName,
InputStream x) |
void |
setBinaryStream(String parameterName,
InputStream s,
int length) |
void |
setBinaryStream(String parameterName,
InputStream x,
long len) |
void |
setBlob(int i,
Blob x)
Sets the value of a specified parameter to the given
Blob object. |
void |
setBlob(int parameterIndex,
InputStream x)
Sets the value of the specified parameter to the bytes
from
inputStream. |
void |
setBlob(int parameterIndex,
InputStream x,
long len)
Sets the value of the specified parameter to the next
length bytes
from inputStream. |
void |
setBlob(String parameterName,
InputStream x) |
void |
setBlob(String parameterName,
InputStream x,
long len) |
void |
setBoolean(int parameterIndex,
boolean x)
Sets the value of a specified parameter to a supplied
boolean
value. |
void |
setBoolean(String parameterName,
boolean val) |
void |
setByte(int parameterIndex,
byte x)
Sets the value of a specified parameter to a supplied
byte value. |
void |
setByte(String parameterName,
byte val) |
void |
setBytes(int parameterIndex,
byte[] x)
Sets the value of a specified parameter to a supplied array of bytes.
|
void |
setBytes(String parameterName,
byte[] val) |
void |
setCharacterStream(int parameterIndex,
Reader x)
Sets the value of the specified parameter to the characters
from
reader. |
void |
setCharacterStream(int parameterIndex,
Reader reader,
int length)
Sets the value of a specified parameter to the character content of a
Reader object, with the specified length of character data. |
void |
setCharacterStream(int parameterIndex,
Reader x,
long len)
Sets the value of the specified parameter to the next
length characters
from reader. |
void |
setCharacterStream(String parameterName,
Reader x) |
void |
setCharacterStream(String parameterName,
Reader r,
int length) |
void |
setCharacterStream(String parameterName,
Reader x,
long len) |
void |
setClob(int i,
Clob x)
Sets the value of a specified parameter to the given
Clob object. |
void |
setClob(int parameterIndex,
Reader x)
Sets the value of the specified parameter to the characters
from
reader. |
void |
setClob(int parameterIndex,
Reader x,
long len)
Sets the value of the specified parameter to the next
length characters
from reader. |
void |
setClob(String parameterName,
Reader x) |
void |
setClob(String parameterName,
Reader x,
long len) |
void |
setDate(int parameterIndex,
Date x)
Sets the value of a specified parameter to a supplied
java.sql.Date value. |
void |
setDate(int parameterIndex,
Date x,
Calendar cal)
Sets the value of a specified parameter to a supplied
java.sql.Date value, using a supplied Calendar to map the Date. |
void |
setDate(String parameterName,
Date val) |
void |
setDate(String parameterName,
Date val,
Calendar cal) |
void |
setDouble(int parameterIndex,
double x)
Sets the value of a specified parameter to a supplied
double
value. |
void |
setDouble(String parameterName,
double val) |
void |
setFloat(int parameterIndex,
float x)
Sets the value of a specified parameter to to a supplied
float
value. |
void |
setFloat(String parameterName,
float val) |
void |
setInt(int parameterIndex,
int x)
Sets the value of a specified parameter to a supplied
int value. |
void |
setInt(String parameterName,
int val) |
void |
setLong(int parameterIndex,
long x)
Sets the value of a specified parameter to a supplied
long value. |
void |
setLong(String parameterName,
long val) |
void |
setNCharacterStream(int parameterIndex,
Reader x)
Sets the value of the specified parameter to the characters
from
reader. |
void |
setNCharacterStream(int parameterIndex,
Reader x,
long len)
Sets the value of the specified parameter to the next
length characters
from reader. |
void |
setNCharacterStream(String parameterName,
Reader x) |
void |
setNCharacterStream(String parameterName,
Reader x,
long len) |
void |
setNClob(int parameterIndex,
NClob value)
Sets the value of the specified parameter to
value. |
void |
setNClob(int parameterIndex,
Reader x)
Sets the value of the specified parameter to the characters
from
reader. |
void |
setNClob(int parameterIndex,
Reader x,
long len)
Sets the value of the specified parameter to the next
length characters
from reader. |
void |
setNClob(String parameterName,
NClob value) |
void |
setNClob(String parameterName,
Reader x) |
void |
setNClob(String parameterName,
Reader x,
long len) |
void |
setNString(int parameterIndex,
String value)
Sets the value of a specified parameter to a supplied string.
|
void |
setNString(String parameterName,
String value) |
void |
setNull(int parameterIndex,
int sqlType)
Sets the value of a specified parameter to SQL
NULL. |
void |
setNull(int parameterIndex,
int sqlType,
String typeName)
Sets the value of a specified parameter to SQL
NULL. |
void |
setNull(String parameterName,
int sqlType) |
void |
setNull(String parameterName,
int sqlType,
String typeName) |
void |
setObject(int parameterIndex,
Object x)
Sets the value of a specified parameter using a supplied object.
|
void |
setObject(int parameterIndex,
Object x,
int targetSqlType)
Sets the value of a specified parameter using a supplied object.
|
void |
setObject(int parameterIndex,
Object x,
int targetSqlType,
int scale)
Sets the value of a specified parameter using a supplied object.
|
void |
setObject(String parameterName,
Object val) |
void |
setObject(String parameterName,
Object val,
int targetSqlType) |
void |
setObject(String parameterName,
Object val,
int targetSqlType,
int scale) |
void |
setRef(int i,
Ref x)
Sets the value of a specified parameter to a supplied
REF(<structured-type>) value. |
void |
setRowId(int parameterIndex,
RowId x)
Sets the value of a specified parameter to a supplied
java.sql.RowId. |
void |
setRowId(String parameterName,
RowId x) |
void |
setShort(int parameterIndex,
short x)
Sets the value of a specified parameter to a supplied
short
value. |
void |
setShort(String parameterName,
short val) |
void |
setSQLXML(int parameterIndex,
SQLXML xml)
Sets the value of the specified parameter to the value of
xmlObject. |
void |
setSQLXML(String parameterName,
SQLXML xml) |
void |
setString(int parameterIndex,
String x)
Sets the value of a specified parameter to a supplied string.
|
void |
setString(String parameterName,
String val) |
void |
setTime(int parameterIndex,
Time x)
Sets the value of a specified parameter to a supplied
java.sql.Time value. |
void |
setTime(int parameterIndex,
Time x,
Calendar cal)
Sets the value of a specified parameter to a supplied
java.sql.Time value, using a supplied Calendar. |
void |
setTime(String parameterName,
Time val) |
void |
setTime(String parameterName,
Time val,
Calendar cal) |
void |
setTimestamp(int parameterIndex,
Timestamp x)
Sets the value of a specified parameter to a supplied java.sql.Timestamp
value.
|
void |
setTimestamp(int parameterIndex,
Timestamp x,
Calendar cal)
Sets the value of a specified parameter to a supplied
java.sql.Timestamp value, using the supplied Calendar. |
void |
setTimestamp(String parameterName,
Timestamp val) |
void |
setTimestamp(String parameterName,
Timestamp val,
Calendar cal) |
void |
setUnicodeStream(int parameterIndex,
InputStream x,
int length)
Deprecated.
|
void |
setURL(int parameterIndex,
URL url)
Sets the value of a specified parameter to a supplied
java.net.URL. |
addBatch, cancel, clearWarnings, execute, execute, execute, execute, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isPoolable, isWrapperFor, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout, unwrapclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddBatch, cancel, clearWarnings, execute, execute, execute, execute, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeoutisWrapperFor, unwrappublic JDBCPreparedStatement(JDBCConnection conn, String sql)
public ResultSet executeQuery() throws SQLException
PreparedStatementPreparedStatement and returns the
ResultSet generated by the query.executeQuery in interface PreparedStatementResultSet generated by the query, never null.SQLException - if a database error happens or if the SQL statement does not
produce a ResultSet.public int executeUpdate()
throws SQLException
PreparedStatementINSERT, UPDATE, DELETE, or a command that
returns nothing.executeUpdate in interface PreparedStatementINSERT, UPDATE or DELETE statements, 0 for statements that return nothing.SQLException - if a database error happens or if the SQL statement returns a
ResultSet.public void setNull(int parameterIndex,
int sqlType)
throws SQLException
PreparedStatementNULL. Don't use
this version of setNull for User Defined Types (UDT) or
for REF type parameters.setNull in interface PreparedStatementparameterIndex - 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.public void setBoolean(int parameterIndex,
boolean x)
throws SQLException
PreparedStatementboolean
value.setBoolean in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the boolean value to which the parameter at parameterIndex is set.SQLException - if a database error happens.public void setByte(int parameterIndex,
byte x)
throws SQLException
PreparedStatementbyte value.setByte in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the byte value to which the parameter at parameterIndex is set.SQLException - if a database error happens.public void setShort(int parameterIndex,
short x)
throws SQLException
PreparedStatementshort
value.setShort in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - a short value to which the parameter at parameterIndex is set.SQLException - if a database error happens.public void setInt(int parameterIndex,
int x)
throws SQLException
PreparedStatementint value.setInt in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the int value to which the parameter at parameterIndex is set.SQLException - if a database error happens.public void setLong(int parameterIndex,
long x)
throws SQLException
PreparedStatementlong value.setLong in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the long value to which the parameter at parameterIndex is set.SQLException - if a database error happens.public void setFloat(int parameterIndex,
float x)
throws SQLException
PreparedStatementfloat
value.setFloat in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the float value to update the parameter.SQLException - if a database error happens.public void setDouble(int parameterIndex,
double x)
throws SQLException
PreparedStatementdouble
value.setDouble in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the double value to which the parameter at parameterIndex is set.SQLException - if a database error happens.public void setBigDecimal(int parameterIndex,
BigDecimal x)
throws SQLException
PreparedStatementjava.math.BigDecimal value.setBigDecimal in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the value to which the parameter at parameterIndex is
set.SQLException - if a database error happens.BigDecimalpublic void setString(int parameterIndex,
String x)
throws SQLException
PreparedStatementsetString in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the value to which the parameter at parameterIndex is
set.SQLException - if a database error happens.public void setBytes(int parameterIndex,
byte[] x)
throws SQLException
PreparedStatementVARBINARY or LONGVARBINARY in the
database.setBytes in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the array of bytes to which the parameter at parameterIndex is set.SQLException - if a database error happens.public void setDate(int parameterIndex,
Date x)
throws SQLException
PreparedStatementjava.sql.Date value.setDate in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - a java.sql.Date to which the parameter at parameterIndex is set.SQLException - if a database error happens.public void setTime(int parameterIndex,
Time x)
throws SQLException
PreparedStatementjava.sql.Time value.setTime in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - a java.sql.Time value to which the parameter at
parameterIndex is set.SQLException - if a database error happens.public void setTimestamp(int parameterIndex,
Timestamp x)
throws SQLException
PreparedStatementsetTimestamp in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the java.sql.Timestamp value to which the parameter at parameterIndex is set.SQLException - if a database error happens.public void setAsciiStream(int parameterIndex,
InputStream x,
int length)
throws SQLException
PreparedStatementInputStream, 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.
setAsciiStream in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - 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.@Deprecated public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException
PreparedStatementInputStream, with a specified number of bytes.setUnicodeStream in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - 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.public void setBinaryStream(int parameterIndex,
InputStream x,
int length)
throws SQLException
PreparedStatementInputStream, which has a specified number of bytes.
Use this method when a large amount of data needs to be set into a
LONGVARBINARY parameter.
setBinaryStream in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - 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.public void clearParameters()
throws SQLException
PreparedStatement
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.
clearParameters in interface PreparedStatementSQLException - if a database error happens.public void setObject(int parameterIndex,
Object x,
int targetSqlType,
int scale)
throws SQLException
PreparedStatement
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.
setObject in interface PreparedStatementparameterIndex - the parameter index, where the first parameter has index 1.x - 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.public void setObject(int parameterIndex,
Object x,
int targetSqlType)
throws SQLException
PreparedStatement
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.
setObject in interface PreparedStatementparameterIndex - the parameter index, where the first parameter has index 1.x - 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.public void setObject(int parameterIndex,
Object x)
throws SQLException
PreparedStatement
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.
setObject in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the object containing the value to which the parameter at
parameterIndex is set.SQLException - if a database error happens.public boolean execute()
throws SQLException
PreparedStatementPreparedStatement.
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.
execute in interface PreparedStatementtrue 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.public void addBatch()
throws SQLException
PreparedStatementPreparedStatement's command batch.addBatch in interface PreparedStatementSQLException - if a database error happens.public int[] executeBatch()
throws SQLException
Statement
If one of the commands in the batch fails, this method can throw a
BatchUpdateException and the JDBC driver may or may not process
the remaining commands. The JDBC driver must behave consistently with the
underlying database, following the "all or nothing" principle. If the
driver continues processing, the array of results returned contains the
same number of elements as there are commands in the batch, with a
minimum of one of the elements having the EXECUTE_FAILED value.
executeBatch in interface StatementexecuteBatch in class JDBCStatement
SUCCESS_NO_INFO, the command
completed successfully but the number of rows affected is
unknown.
EXECUTE_FAILED, the command failed.
SQLException - if an error occurs accessing the database.public void clearBatch()
throws SQLException
StatementclearBatch in interface StatementclearBatch in class JDBCStatementSQLException - if an error occurs accessing the database or the database
does not support batch updates.public void close()
throws SQLException
StatementUsing this method to release these resources as soon as possible is strongly recommended.
One should not rely on the resources being automatically released when finalized during garbage collection. Doing so can result in unpredictable behavior for the application.
close in interface AutoCloseableclose in interface Statementclose in class JDBCStatementSQLException - if an error occurs accessing the database.public void setCharacterStream(int parameterIndex,
Reader reader,
int length)
throws SQLException
PreparedStatementReader 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.
setCharacterStream in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1reader - the java.io.Reader containing the character data.length - the number of characters to be read.SQLException - if a database error happens.public void setRef(int i,
Ref x)
throws SQLException
PreparedStatementREF(<structured-type>) value. This is stored as an SQL REF.setRef in interface PreparedStatementi - the parameter number index, where the first parameter has
index 1.x - a java.sql.Ref value to which the parameter at parameterIndex is set.SQLException - if a database error happens.Refpublic void setBlob(int i,
Blob x)
throws SQLException
PreparedStatementBlob object.setBlob in interface PreparedStatementi - the parameter number index, where the first parameter has
index 1.x - the java.sql.Blob to which the parameter at parameterIndex is set.SQLException - if a database error happens.Blobpublic void setClob(int i,
Clob x)
throws SQLException
PreparedStatementClob object.setClob in interface PreparedStatementi - the parameter number index, where the first parameter has
index 1.x - a java.sql.Clob holding the data to which the
parameter at parameterIndex is set.SQLException - if a database error happens.public void setArray(int i,
Array x)
throws SQLException
PreparedStatementArray.setArray in interface PreparedStatementi - the parameter number index, where the first parameter has
index 1.x - a java.sql.Array giving the new value of the parameter at parameterIndex.SQLException - if a database error happens.Arraypublic ResultSetMetaData getMetaData() throws SQLException
PreparedStatementResultSetMetaData 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.
getMetaData in interface PreparedStatementResultSetMetaData 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.public void setDate(int parameterIndex,
Date x,
Calendar cal)
throws SQLException
PreparedStatementjava.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 VM defaults.
See "Be wary of the default locale".setDate in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - 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.Date,
Calendarpublic void setTime(int parameterIndex,
Time x,
Calendar cal)
throws SQLException
PreparedStatementjava.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 VM defaults.
See "Be wary of the default locale".
setTime in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - 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.Time,
Calendarpublic void setTimestamp(int parameterIndex,
Timestamp x,
Calendar cal)
throws SQLException
PreparedStatementjava.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 VM defaults.
See "Be wary of the default locale".
setTimestamp in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the java.sql.Timestamp value to which the parameter at
parameterIndex is set.cal - a Calendar to use to construct the SQL TIMESTAMP valueSQLException - if a database error happens.Timestamp,
Calendarpublic void setNull(int parameterIndex,
int sqlType,
String typeName)
throws SQLException
PreparedStatementNULL. 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.
setNull in interface PreparedStatementparameterIndex - 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.Typespublic ParameterMetaData getParameterMetaData() throws SQLException
PreparedStatementPreparedStatement.getParameterMetaData in interface PreparedStatementParameterMetaData object which holds information about
the number, type, and properties of the parameters of this PreparedStatement.SQLException - if a database error happens.public void registerOutputParameter(String parameterName, int sqlType) throws SQLException
SQLExceptionpublic void registerOutputParameter(String parameterName, int sqlType, int scale) throws SQLException
SQLExceptionpublic void registerOutputParameter(String parameterName, int sqlType, String typeName) throws SQLException
SQLExceptionpublic URL getURL(int parameterIndex) throws SQLException
SQLExceptionpublic void setURL(int parameterIndex,
URL url)
throws SQLException
PreparedStatementjava.net.URL.setURL in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.url - the URL to which the parameter at parameterIndex is set.SQLException - if a database error happens.URLpublic void setNull(String parameterName, int sqlType) throws SQLException
SQLExceptionpublic void setBoolean(String parameterName, boolean val) throws SQLException
SQLExceptionpublic void setByte(String parameterName, byte val) throws SQLException
SQLExceptionpublic void setShort(String parameterName, short val) throws SQLException
SQLExceptionpublic void setInt(String parameterName, int val) throws SQLException
SQLExceptionpublic void setLong(String parameterName, long val) throws SQLException
SQLExceptionpublic void setFloat(String parameterName, float val) throws SQLException
SQLExceptionpublic void setDouble(String parameterName, double val) throws SQLException
SQLExceptionpublic void setBigDecimal(String parameterName, BigDecimal val) throws SQLException
SQLExceptionpublic void setString(String parameterName, String val) throws SQLException
SQLExceptionpublic void setBytes(String parameterName, byte[] val) throws SQLException
SQLExceptionpublic void setDate(String parameterName, Date val) throws SQLException
SQLExceptionpublic void setTime(String parameterName, Time val) throws SQLException
SQLExceptionpublic void setTimestamp(String parameterName, Timestamp val) throws SQLException
SQLExceptionpublic void setAsciiStream(String parameterName, InputStream s, int length) throws SQLException
SQLExceptionpublic void setBinaryStream(String parameterName, InputStream s, int length) throws SQLException
SQLExceptionpublic void setObject(String parameterName, Object val, int targetSqlType, int scale) throws SQLException
SQLExceptionpublic void setObject(String parameterName, Object val, int targetSqlType) throws SQLException
SQLExceptionpublic void setObject(String parameterName, Object val) throws SQLException
SQLExceptionpublic void setCharacterStream(String parameterName, Reader r, int length) throws SQLException
SQLExceptionpublic void setDate(String parameterName, Date val, Calendar cal) throws SQLException
SQLExceptionpublic void setTime(String parameterName, Time val, Calendar cal) throws SQLException
SQLExceptionpublic void setTimestamp(String parameterName, Timestamp val, Calendar cal) throws SQLException
SQLExceptionpublic void setNull(String parameterName, int sqlType, String typeName) throws SQLException
SQLExceptionpublic String getString(String parameterName) throws SQLException
SQLExceptionpublic boolean getBoolean(String parameterName) throws SQLException
SQLExceptionpublic byte getByte(String parameterName) throws SQLException
SQLExceptionpublic short getShort(String parameterName) throws SQLException
SQLExceptionpublic int getInt(String parameterName) throws SQLException
SQLExceptionpublic long getLong(String parameterName) throws SQLException
SQLExceptionpublic float getFloat(String parameterName) throws SQLException
SQLExceptionpublic double getDouble(String parameterName) throws SQLException
SQLExceptionpublic byte[] getBytes(String parameterName) throws SQLException
SQLExceptionpublic Date getDate(String parameterName) throws SQLException
SQLExceptionpublic Time getTime(String parameterName) throws SQLException
SQLExceptionpublic Timestamp getTimestamp(String parameterName) throws SQLException
SQLExceptionpublic Object getObject(String parameterName) throws SQLException
SQLExceptionpublic Object getObject(int parameterIndex) throws SQLException
SQLExceptionpublic BigDecimal getBigDecimal(String parameterName) throws SQLException
SQLExceptionpublic Object getObject(String parameterName, Map map) throws SQLException
SQLExceptionpublic Object getObject(int parameterIndex, Map map) throws SQLException
SQLExceptionpublic Ref getRef(int parameterIndex) throws SQLException
SQLExceptionpublic Ref getRef(String parameterName) throws SQLException
SQLExceptionpublic Blob getBlob(String parameterName) throws SQLException
SQLExceptionpublic Blob getBlob(int parameterIndex) throws SQLException
SQLExceptionpublic Clob getClob(String parameterName) throws SQLException
SQLExceptionpublic Clob getClob(int parameterIndex) throws SQLException
SQLExceptionpublic Array getArray(String parameterName) throws SQLException
SQLExceptionpublic Array getArray(int parameterIndex) throws SQLException
SQLExceptionpublic Date getDate(String parameterName, Calendar cal) throws SQLException
SQLExceptionpublic Date getDate(int parameterIndex, Calendar cal) throws SQLException
SQLExceptionpublic Time getTime(String parameterName, Calendar cal) throws SQLException
SQLExceptionpublic Time getTime(int parameterIndex, Calendar cal) throws SQLException
SQLExceptionpublic Timestamp getTimestamp(String parameterName, Calendar cal) throws SQLException
SQLExceptionpublic Timestamp getTimestamp(int parameterIndex, Calendar cal) throws SQLException
SQLExceptionpublic URL getURL(String parameterName) throws SQLException
SQLExceptionpublic void setRowId(int parameterIndex,
RowId x)
throws SQLException
PreparedStatementjava.sql.RowId.setRowId in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the RowId to which the parameter at parameterIndex is set.SQLException - if a database error happens.public void setRowId(String parameterName, RowId x) throws SQLException
SQLExceptionpublic void setNString(int parameterIndex,
String value)
throws SQLException
PreparedStatementsetNString in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.value - the String to which the parameter at parameterIndex is set.SQLException - if a database error happens.public void setNString(String parameterName, String value) throws SQLException
SQLExceptionpublic void setNCharacterStream(int parameterIndex,
Reader x,
long len)
throws SQLException
PreparedStatementlength characters
from reader.setNCharacterStream in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the Readerlen - character countSQLException - if a database error happens.public void setNCharacterStream(String parameterName, Reader x, long len) throws SQLException
SQLExceptionpublic void setNClob(int parameterIndex,
NClob value)
throws SQLException
PreparedStatementvalue.setNClob in interface PreparedStatementparameterIndex - 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.public void setNClob(String parameterName, NClob value) throws SQLException
SQLExceptionpublic void setClob(int parameterIndex,
Reader x,
long len)
throws SQLException
PreparedStatementlength characters
from reader.setClob in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the Readerlen - character countSQLException - if a database error happens.public void setClob(String parameterName, Reader x, long len) throws SQLException
SQLExceptionpublic void setBlob(int parameterIndex,
InputStream x,
long len)
throws SQLException
PreparedStatementlength bytes
from inputStream.setBlob in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the InputStreamlen - character countSQLException - if a database error happens.public void setBlob(String parameterName, InputStream x, long len) throws SQLException
SQLExceptionpublic void setNClob(int parameterIndex,
Reader x,
long len)
throws SQLException
PreparedStatementlength characters
from reader.setNClob in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the Readerlen - character countSQLException - if a database error happens.public void setNClob(String parameterName, Reader x, long len) throws SQLException
SQLExceptionpublic void setSQLXML(int parameterIndex,
SQLXML xml)
throws SQLException
PreparedStatementxmlObject.setSQLXML in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.xml - the SQLXMLSQLException - if a database error happens.public void setSQLXML(String parameterName, SQLXML xml) throws SQLException
SQLExceptionpublic void setAsciiStream(int parameterIndex,
InputStream x,
long len)
throws SQLException
PreparedStatementlength bytes
from inputStream.setAsciiStream in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the InputStreamlen - character countSQLException - if a database error happens.public void setAsciiStream(String parameterName, InputStream x, long len) throws SQLException
SQLExceptionpublic void setBinaryStream(int parameterIndex,
InputStream x,
long len)
throws SQLException
PreparedStatementlength bytes
from inputStream.setBinaryStream in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the InputStreamlen - character countSQLException - if a database error happens.public void setBinaryStream(String parameterName, InputStream x, long len) throws SQLException
SQLExceptionpublic void setCharacterStream(int parameterIndex,
Reader x,
long len)
throws SQLException
PreparedStatementlength characters
from reader.setCharacterStream in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the Readerlen - character countSQLException - if a database error happens.public void setCharacterStream(String parameterName, Reader x, long len) throws SQLException
SQLExceptionpublic void setAsciiStream(int parameterIndex,
InputStream x)
throws SQLException
PreparedStatementinputStream.setAsciiStream in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the InputStreamSQLException - if a database error happens.public void setAsciiStream(String parameterName, InputStream x) throws SQLException
SQLExceptionpublic void setBinaryStream(int parameterIndex,
InputStream x)
throws SQLException
PreparedStatementinputStream.setBinaryStream in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the InputStreamSQLException - if a database error happens.public void setBinaryStream(String parameterName, InputStream x) throws SQLException
SQLExceptionpublic void setCharacterStream(int parameterIndex,
Reader x)
throws SQLException
PreparedStatementreader.setCharacterStream in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the ReaderSQLException - if a database error happens.public void setCharacterStream(String parameterName, Reader x) throws SQLException
SQLExceptionpublic void setNCharacterStream(int parameterIndex,
Reader x)
throws SQLException
PreparedStatementreader.setNCharacterStream in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the ReaderSQLException - if a database error happens.public void setNCharacterStream(String parameterName, Reader x) throws SQLException
SQLExceptionpublic void setClob(int parameterIndex,
Reader x)
throws SQLException
PreparedStatementreader.setClob in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the ReaderSQLException - if a database error happens.public void setClob(String parameterName, Reader x) throws SQLException
SQLExceptionpublic void setBlob(int parameterIndex,
InputStream x)
throws SQLException
PreparedStatementinputStream.setBlob in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the InputStreamSQLException - if a database error happens.public void setBlob(String parameterName, InputStream x) throws SQLException
SQLExceptionpublic void setNClob(int parameterIndex,
Reader x)
throws SQLException
PreparedStatementreader.setNClob in interface PreparedStatementparameterIndex - the parameter number index, where the first parameter has
index 1.x - the ReaderSQLException - if a database error happens.public void setNClob(String parameterName, Reader x) throws SQLException
SQLException