PreparedStatement

Represents a prepared statement.

Methods
void addBatch(String sql)
Calling this method is not legal on a PreparedStatement.
void addBatch()
Adds the current settings to the batch.
void clearBatch()
Clears the batch.
void clearParameters()
Clears all parameters.
void close()
Closes this statement.
boolean execute()
Executes an arbitrary statement.
boolean execute(String sql)
Calling this method is not legal on a PreparedStatement.
boolean execute(String sql, int autoGeneratedKeys)
Calling this method is not legal on a PreparedStatement.
boolean execute(String sql, int[] columnIndexes)
Calling this method is not legal on a PreparedStatement.
boolean execute(String sql, String[] columnNames)
Calling this method is not legal on a PreparedStatement.
int[] executeBatch()
Executes the batch.
ResultSet executeQuery()
Executes a query (select statement) and returns the result set.
ResultSet executeQuery(String sql)
Calling this method is not legal on a PreparedStatement.
int executeUpdate()
Executes a statement (insert, update, delete, create, drop, commit, rollback) and returns the update count.
int executeUpdate(String sql)
Calling this method is not legal on a PreparedStatement.
int executeUpdate(String sql, int autoGeneratedKeys)
Calling this method is not legal on a PreparedStatement.
int executeUpdate(String sql, int[] columnIndexes)
Calling this method is not legal on a PreparedStatement.
int executeUpdate(String sql, String[] columnNames)
Calling this method is not legal on a PreparedStatement.
ResultSetMetaData getMetaData()
Gets the result set metadata of the query returned when the statement is executed.
ParameterMetaData getParameterMetaData()
Get the parameter meta data of this prepared statement.
void setArray(int parameterIndex, Array x)
[Not supported] Sets the value of a parameter as a Array.
void setAsciiStream(int parameterIndex, InputStream x, int length)
Sets the value of a parameter as an ASCII stream.
void setAsciiStream(int parameterIndex, InputStream x, long length)
Sets the value of a parameter as an ASCII stream.
void setAsciiStream(int parameterIndex, InputStream x)
Sets the value of a parameter as an ASCII stream.
void setBigDecimal(int parameterIndex, BigDecimal x)
Sets the value of a parameter.
void setBinaryStream(int parameterIndex, InputStream x, long length)
Sets the value of a parameter as an input stream.
void setBinaryStream(int parameterIndex, InputStream x, int length)
Sets the value of a parameter as an input stream.
void setBinaryStream(int parameterIndex, InputStream x)
Sets the value of a parameter as an input stream.
void setBlob(int parameterIndex, Blob x)
Sets the value of a parameter as a Blob.
void setBlob(int parameterIndex, InputStream x)
Sets the value of a parameter as a Blob.
void setBlob(int parameterIndex, InputStream x, long length)
Sets the value of a parameter as a Blob.
void setBoolean(int parameterIndex, boolean x)
Sets the value of a parameter.
void setByte(int parameterIndex, byte x)
Sets the value of a parameter.
void setBytes(int parameterIndex, byte[] x)
Sets the value of a parameter as a byte array.
void setCharacterStream(int parameterIndex, Reader x, int length)
Sets the value of a parameter as a character stream.
void setCharacterStream(int parameterIndex, Reader x)
Sets the value of a parameter as a character stream.
void setCharacterStream(int parameterIndex, Reader x, long length)
Sets the value of a parameter as a character stream.
void setClob(int parameterIndex, Clob x)
Sets the value of a parameter as a Clob.
void setClob(int parameterIndex, Reader x)
Sets the value of a parameter as a Clob.
void setClob(int parameterIndex, Reader x, long length)
Sets the value of a parameter as a Clob.
void setDate(int parameterIndex, Date x)
Sets the value of a parameter.
void setDate(int parameterIndex, Date x, Calendar calendar)
Sets the date using a specified time zone.
void setDouble(int parameterIndex, double x)
Sets the value of a parameter.
void setFloat(int parameterIndex, float x)
Sets the value of a parameter.
void setInt(int parameterIndex, int x)
Sets the value of a parameter.
void setLong(int parameterIndex, long x)
Sets the value of a parameter.
void setNCharacterStream(int parameterIndex, Reader x, long length)
Sets the value of a parameter as a character stream.
void setNCharacterStream(int parameterIndex, Reader x)
Sets the value of a parameter as a character stream.
void setNClob(int parameterIndex, Reader x)
Sets the value of a parameter as a Clob.
void setNClob(int parameterIndex, Reader x, long length)
Sets the value of a parameter as a Clob.
void setNString(int parameterIndex, String x)
Sets the value of a parameter.
void setNull(int parameterIndex, int sqlType)
Sets a parameter to null.
void setNull(int parameterIndex, int sqlType, String typeName)
Sets a parameter to null.
void setObject(int parameterIndex, Object x)
Sets the value of a parameter.
void setObject(int parameterIndex, Object x, int targetSqlType)
Sets the value of a parameter.
void setObject(int parameterIndex, Object x, int targetSqlType, int scale)
Sets the value of a parameter.
void setRef(int parameterIndex, Ref x)
[Not supported] Sets the value of a column as a reference.
void setShort(int parameterIndex, short x)
Sets the value of a parameter.
void setString(int parameterIndex, String x)
Sets the value of a parameter.
void setTime(int parameterIndex, Time x)
Sets the value of a parameter.
void setTime(int parameterIndex, Time x, Calendar calendar)
Sets the time using a specified time zone.
void setTimestamp(int parameterIndex, Timestamp x)
Sets the value of a parameter.
void setTimestamp(int parameterIndex, Timestamp x, Calendar calendar)
Sets the timestamp using a specified time zone.
void setURL(int parameterIndex, URL x)
[Not supported]
void setUnicodeStream(int parameterIndex, InputStream x, int length)
[Not supported] This feature is deprecated and not supported.

void addBatch(String sql) throws SQLException

Calling this method is not legal on a PreparedStatement.

Throws:
SQLException - Unsupported Feature

void addBatch() throws SQLException

Adds the current settings to the batch.

void clearBatch() throws SQLException

Clears the batch.

void clearParameters() throws SQLException

Clears all parameters.

Throws:
SQLException - if this object is closed or invalid

void close() throws SQLException

Closes this statement. All result sets that where created by this statement become invalid after calling this method.

boolean execute() throws SQLException

Executes an arbitrary statement. If another result set exists for this statement, this will be closed (even if this statement fails). If auto commit is on, and the statement is not a select, this statement will be committed.

Returns:
true if a result set is available, false if not
Throws:
SQLException - if this object is closed or invalid

boolean execute(String sql) throws SQLException

Calling this method is not legal on a PreparedStatement.

Throws:
SQLException - Unsupported Feature

boolean execute(String sql, int autoGeneratedKeys) throws SQLException

Calling this method is not legal on a PreparedStatement.

Throws:
SQLException - Unsupported Feature

boolean execute(String sql, int[] columnIndexes) throws SQLException

Calling this method is not legal on a PreparedStatement.

Throws:
SQLException - Unsupported Feature

boolean execute(String sql, String[] columnNames) throws SQLException

Calling this method is not legal on a PreparedStatement.

Throws:
SQLException - Unsupported Feature

int[] executeBatch() throws SQLException

Executes the batch.

Returns:
the array of update counts

ResultSet executeQuery() throws SQLException

Executes a query (select statement) and returns the result set. If another result set exists for this statement, this will be closed (even if this statement fails).

Returns:
the result set
Throws:
SQLException - if this object is closed or invalid

ResultSet executeQuery(String sql) throws SQLException

Calling this method is not legal on a PreparedStatement.

Throws:
SQLException - Unsupported Feature

int executeUpdate() throws SQLException

Executes a statement (insert, update, delete, create, drop, commit, rollback) and returns the update count. If another result set exists for this statement, this will be closed (even if this statement fails). If the statement is a create or drop and does not throw an exception, the current transaction (if any) is committed after executing the statement. If auto commit is on, this statement will be committed.

Returns:
the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
SQLException - if this object is closed or invalid

int executeUpdate(String sql) throws SQLException

Calling this method is not legal on a PreparedStatement.

Throws:
SQLException - Unsupported Feature

int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException

Calling this method is not legal on a PreparedStatement.

Throws:
SQLException - Unsupported Feature

int executeUpdate(String sql, int[] columnIndexes) throws SQLException

Calling this method is not legal on a PreparedStatement.

Throws:
SQLException - Unsupported Feature

int executeUpdate(String sql, String[] columnNames) throws SQLException

Calling this method is not legal on a PreparedStatement.

Throws:
SQLException - Unsupported Feature

ResultSetMetaData getMetaData() throws SQLException

Gets the result set metadata of the query returned when the statement is executed. If this is not a query, this method returns null.

Returns:
the meta data or null if this is not a query
Throws:
SQLException - if this object is closed

ParameterMetaData getParameterMetaData() throws SQLException

Get the parameter meta data of this prepared statement.

Returns:
the meta data

void setArray(int parameterIndex, Array x) throws SQLException

[Not supported] Sets the value of a parameter as a Array.

void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException

Sets the value of a parameter as an ASCII stream.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the number of bytes
Throws:
SQLException - if this object is closed

void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException

Sets the value of a parameter as an ASCII stream.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the number of bytes
Throws:
SQLException - if this object is closed

void setAsciiStream(int parameterIndex, InputStream x) throws SQLException

Sets the value of a parameter as an ASCII stream.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException

Sets the value of a parameter.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException

Sets the value of a parameter as an input stream.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the number of bytes
Throws:
SQLException - if this object is closed

void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException

Sets the value of a parameter as an input stream.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the number of bytes
Throws:
SQLException - if this object is closed

void setBinaryStream(int parameterIndex, InputStream x) throws SQLException

Sets the value of a parameter as an input stream.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setBlob(int parameterIndex, Blob x) throws SQLException

Sets the value of a parameter as a Blob.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setBlob(int parameterIndex, InputStream x) throws SQLException

Sets the value of a parameter as a Blob.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setBlob(int parameterIndex, InputStream x, long length) throws SQLException

Sets the value of a parameter as a Blob.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setBoolean(int parameterIndex, boolean x) throws SQLException

Sets the value of a parameter.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setByte(int parameterIndex, byte x) throws SQLException

Sets the value of a parameter.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

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

Sets the value of a parameter as a byte array.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setCharacterStream(int parameterIndex, Reader x, int length) throws SQLException

Sets the value of a parameter as a character stream.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the number of bytes
Throws:
SQLException - if this object is closed

void setCharacterStream(int parameterIndex, Reader x) throws SQLException

Sets the value of a parameter as a character stream.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setCharacterStream(int parameterIndex, Reader x, long length) throws SQLException

Sets the value of a parameter as a character stream.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the number of bytes
Throws:
SQLException - if this object is closed

void setClob(int parameterIndex, Clob x) throws SQLException

Sets the value of a parameter as a Clob.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setClob(int parameterIndex, Reader x) throws SQLException

Sets the value of a parameter as a Clob.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setClob(int parameterIndex, Reader x, long length) throws SQLException

Sets the value of a parameter as a Clob.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setDate(int parameterIndex, Date x) throws SQLException

Sets the value of a parameter.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setDate(int parameterIndex, Date x, Calendar calendar) throws SQLException

Sets the date using a specified time zone. The value will be converted to the local time zone.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
calendar - the calendar
Throws:
SQLException - if this object is closed

void setDouble(int parameterIndex, double x) throws SQLException

Sets the value of a parameter.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setFloat(int parameterIndex, float x) throws SQLException

Sets the value of a parameter.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setInt(int parameterIndex, int x) throws SQLException

Sets the value of a parameter.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setLong(int parameterIndex, long x) throws SQLException

Sets the value of a parameter.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setNCharacterStream(int parameterIndex, Reader x, long length) throws SQLException

Sets the value of a parameter as a character stream.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the number of bytes
Throws:
SQLException - if this object is closed

void setNCharacterStream(int parameterIndex, Reader x) throws SQLException

Sets the value of a parameter as a character stream.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setNClob(int parameterIndex, Reader x) throws SQLException

Sets the value of a parameter as a Clob.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setNClob(int parameterIndex, Reader x, long length) throws SQLException

Sets the value of a parameter as a Clob.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setNString(int parameterIndex, String x) throws SQLException

Sets the value of a parameter.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setNull(int parameterIndex, int sqlType) throws SQLException

Sets a parameter to null.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
sqlType - the data type (Types.x)
Throws:
SQLException - if this object is closed

void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException

Sets a parameter to null.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
sqlType - the data type (Types.x)
typeName - this parameter is ignored
Throws:
SQLException - if this object is closed

void setObject(int parameterIndex, Object x) throws SQLException

Sets the value of a parameter.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException

Sets the value of a parameter. The object is converted, if required, to the specified data type before sending to the database.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value, null is allowed
targetSqlType - the type as defined in java.sql.Types
Throws:
SQLException - if this object is closed

void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException

Sets the value of a parameter. The object is converted, if required, to the specified data type before sending to the database.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value, null is allowed
targetSqlType - the type as defined in java.sql.Types
scale - is ignored
Throws:
SQLException - if this object is closed

void setRef(int parameterIndex, Ref x) throws SQLException

[Not supported] Sets the value of a column as a reference.

void setShort(int parameterIndex, short x) throws SQLException

Sets the value of a parameter.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setString(int parameterIndex, String x) throws SQLException

Sets the value of a parameter.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setTime(int parameterIndex, Time x) throws SQLException

Sets the value of a parameter.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setTime(int parameterIndex, Time x, Calendar calendar) throws SQLException

Sets the time using a specified time zone. The value will be converted to the local time zone.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
calendar - the calendar
Throws:
SQLException - if this object is closed

void setTimestamp(int parameterIndex, Timestamp x) throws SQLException

Sets the value of a parameter.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed

void setTimestamp(int parameterIndex, Timestamp x, Calendar calendar) throws SQLException

Sets the timestamp using a specified time zone. The value will be converted to the local time zone.

Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
calendar - the calendar
Throws:
SQLException - if this object is closed

void setURL(int parameterIndex, URL x) throws SQLException

[Not supported]

void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException

[Not supported] This feature is deprecated and not supported.