PreparedStatement

Represents a prepared statement.

Methods
void addBatch(String sql)
Calling this method is not legal on a PreparedStatement.
void addBatch(String sql) throws SQLException
Calling this method is not legal on a PreparedStatement.
Parameters:
sql - ignored
Throws:
SQLException - Unsupported Feature
void addBatch()
Adds the current settings to the batch.
void addBatch() throws SQLException
Adds the current settings to the batch.
boolean checkClosed(boolean write)
boolean checkClosed(boolean write)
void clearBatch()
Clears the batch.
void clearBatch() throws SQLException
Clears the batch.
void clearParameters()
Clears all parameters.
void clearParameters() throws SQLException
Clears all parameters.
Throws:
SQLException - if this object is closed or invalid
void close()
Closes this statement.
void close() throws SQLException
Closes this statement. All result sets that where created by this statement become invalid after calling this method.
boolean execute()
Executes an arbitrary statement.
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)
Calling this method is not legal on a PreparedStatement.
boolean execute(String sql) throws SQLException
Calling this method is not legal on a PreparedStatement.
Parameters:
sql - ignored
Throws:
SQLException - Unsupported Feature
boolean execute(String sql, int autoGeneratedKeys)
Calling this method is not legal on a PreparedStatement.
boolean execute(String sql, int autoGeneratedKeys) throws SQLException
Calling this method is not legal on a PreparedStatement.
Parameters:
sql - ignored
autoGeneratedKeys - ignored
Throws:
SQLException - Unsupported Feature
boolean execute(String sql, int[] columnIndexes)
Calling this method is not legal on a PreparedStatement.
boolean execute(String sql, int[] columnIndexes) throws SQLException
Calling this method is not legal on a PreparedStatement.
Parameters:
sql - ignored
columnIndexes - ignored
Throws:
SQLException - Unsupported Feature
boolean execute(String sql, String[] columnNames)
Calling this method is not legal on a PreparedStatement.
boolean execute(String sql, String[] columnNames) throws SQLException
Calling this method is not legal on a PreparedStatement.
Parameters:
sql - ignored
columnNames - ignored
Throws:
SQLException - Unsupported Feature
int[] executeBatch()
Executes the batch.
int[] executeBatch() throws SQLException
Executes the batch. If one of the batched statements fails, this database will continue.
Returns:
the array of update counts
ResultSet executeQuery()
Executes a query (select statement) and returns the result set.
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)
Calling this method is not legal on a PreparedStatement.
ResultSet executeQuery(String sql) throws SQLException
Calling this method is not legal on a PreparedStatement.
Parameters:
sql - ignored
Throws:
SQLException - Unsupported Feature
int executeUpdate()
Executes a statement (insert, update, delete, create, drop) and returns the update count.
int executeUpdate() throws SQLException
Executes a statement (insert, update, delete, create, drop) and returns the update count. If another result set exists for this statement, this will be closed (even if this statement fails). If auto commit is on, this statement will be committed. If the statement is a DDL statement (create, drop, alter) and does not throw an exception, the current transaction (if any) is committed after executing the statement.
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)
Calling this method is not legal on a PreparedStatement.
int executeUpdate(String sql) throws SQLException
Calling this method is not legal on a PreparedStatement.
Parameters:
sql - ignored
Throws:
SQLException - Unsupported Feature
int executeUpdate(String sql, int autoGeneratedKeys)
Calling this method is not legal on a PreparedStatement.
int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
Calling this method is not legal on a PreparedStatement.
Parameters:
sql - ignored
autoGeneratedKeys - ignored
Throws:
SQLException - Unsupported Feature
int executeUpdate(String sql, int[] columnIndexes)
Calling this method is not legal on a PreparedStatement.
int executeUpdate(String sql, int[] columnIndexes) throws SQLException
Calling this method is not legal on a PreparedStatement.
Parameters:
sql - ignored
columnIndexes - ignored
Throws:
SQLException - Unsupported Feature
int executeUpdate(String sql, String[] columnNames)
Calling this method is not legal on a PreparedStatement.
int executeUpdate(String sql, String[] columnNames) throws SQLException
Calling this method is not legal on a PreparedStatement.
Parameters:
sql - ignored
columnNames - ignored
Throws:
SQLException - Unsupported Feature
ResultSet getGeneratedKeys()
ResultSet getGeneratedKeys() throws SQLException
ResultSetMetaData getMetaData()
Gets the result set metadata of the query returned when the statement is executed.
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()
Get the parameter meta data of this prepared statement.
ParameterMetaData getParameterMetaData() throws SQLException
Get the parameter meta data of this prepared statement.
Returns:
the meta data
void setArray(int parameterIndex, Array x)
Sets the value of a parameter as an Array.
void setArray(int parameterIndex, Array x) throws SQLException
Sets the value of a parameter as an Array.
Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed
void setAsciiStream(int parameterIndex, InputStream x, int length)
Sets the value of a parameter as an ASCII stream.
void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException
Sets the value of a parameter as an ASCII stream. This method does not close the stream. The stream may be closed after executing the statement.
Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the maximum number of bytes
Throws:
SQLException - if this object is closed
void setAsciiStream(int parameterIndex, InputStream x, long length)
Sets the value of a parameter as an ASCII stream.
void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException
Sets the value of a parameter as an ASCII stream. This method does not close the stream. The stream may be closed after executing the statement.
Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the maximum number of bytes
Throws:
SQLException - if this object is closed
void setAsciiStream(int parameterIndex, InputStream x)
Sets the value of a parameter as an ASCII stream.
void setAsciiStream(int parameterIndex, InputStream x) throws SQLException
Sets the value of a parameter as an ASCII stream. This method does not close the stream. The stream may be closed after executing the statement.
Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed
void setBigDecimal(int parameterIndex, BigDecimal x)
Sets the value of a parameter.
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)
Sets the value of a parameter as an input stream.
void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException
Sets the value of a parameter as an input stream. This method does not close the stream. The stream may be closed after executing the statement.
Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the maximum number of bytes
Throws:
SQLException - if this object is closed
void setBinaryStream(int parameterIndex, InputStream x, int length)
Sets the value of a parameter as an input stream.
void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException
Sets the value of a parameter as an input stream. This method does not close the stream. The stream may be closed after executing the statement.
Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the maximum number of bytes
Throws:
SQLException - if this object is closed
void setBinaryStream(int parameterIndex, InputStream x)
Sets the value of a parameter as an input stream.
void setBinaryStream(int parameterIndex, InputStream x) throws SQLException
Sets the value of a parameter as an input stream. This method does not close the stream. The stream may be closed after executing the statement.
Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed
void setBlob(int parameterIndex, Blob x)
Sets the value of a parameter as a Blob.
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)
Sets the value of a parameter as a Blob.
void setBlob(int parameterIndex, InputStream x) throws SQLException
Sets the value of a parameter as a Blob. This method does not close the stream. The stream may be closed after executing the statement.
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)
Sets the value of a parameter as a Blob.
void setBlob(int parameterIndex, InputStream x, long length) throws SQLException
Sets the value of a parameter as a Blob. This method does not close the stream. The stream may be closed after executing the statement.
Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the maximum number of bytes
Throws:
SQLException - if this object is closed
void setBoolean(int parameterIndex, boolean x)
Sets the value of a parameter.
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)
Sets the value of a parameter.
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)
Sets the value of a parameter as a byte array.
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)
Sets the value of a parameter as a character stream.
void setCharacterStream(int parameterIndex, Reader x, int length) throws SQLException
Sets the value of a parameter as a character stream. This method does not close the reader. The reader may be closed after executing the statement.
Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the maximum number of characters
Throws:
SQLException - if this object is closed
void setCharacterStream(int parameterIndex, Reader x)
Sets the value of a parameter as a character stream.
void setCharacterStream(int parameterIndex, Reader x) throws SQLException
Sets the value of a parameter as a character stream. This method does not close the reader. The reader may be closed after executing the statement.
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)
Sets the value of a parameter as a character stream.
void setCharacterStream(int parameterIndex, Reader x, long length) throws SQLException
Sets the value of a parameter as a character stream. This method does not close the reader. The reader may be closed after executing the statement.
Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the maximum number of characters
Throws:
SQLException - if this object is closed
void setClob(int parameterIndex, Clob x)
Sets the value of a parameter as a Clob.
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)
Sets the value of a parameter as a Clob.
void setClob(int parameterIndex, Reader x) throws SQLException
Sets the value of a parameter as a Clob. This method does not close the reader. The reader may be closed after executing the statement.
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)
Sets the value of a parameter as a Clob.
void setClob(int parameterIndex, Reader x, long length) throws SQLException
Sets the value of a parameter as a Clob. This method does not close the reader. The reader may be closed after executing the statement.
Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the maximum number of characters
Throws:
SQLException - if this object is closed
void setDate(int parameterIndex, Date x)
Sets the value of a parameter.
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)
Sets the date using a specified time zone.
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)
Sets the value of a parameter.
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)
Sets the value of a parameter.
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)
Sets the value of a parameter.
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)
Sets the value of a parameter.
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)
Sets the value of a parameter as a character stream.
void setNCharacterStream(int parameterIndex, Reader x, long length) throws SQLException
Sets the value of a parameter as a character stream. This method does not close the reader. The reader may be closed after executing the statement.
Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the maximum number of characters
Throws:
SQLException - if this object is closed
void setNCharacterStream(int parameterIndex, Reader x)
Sets the value of a parameter as a character stream.
void setNCharacterStream(int parameterIndex, Reader x) throws SQLException
Sets the value of a parameter as a character stream. This method does not close the reader. The reader may be closed after executing the statement.
Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
Throws:
SQLException - if this object is closed
void setNClob(int parameterIndex, NClob x)
Sets the value of a parameter as a Clob.
void setNClob(int parameterIndex, NClob 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)
Sets the value of a parameter as a Clob.
void setNClob(int parameterIndex, Reader x) throws SQLException
Sets the value of a parameter as a Clob. This method does not close the reader. The reader may be closed after executing the statement.
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)
Sets the value of a parameter as a Clob.
void setNClob(int parameterIndex, Reader x, long length) throws SQLException
Sets the value of a parameter as a Clob. This method does not close the reader. The reader may be closed after executing the statement.
Parameters:
parameterIndex - the parameter index (1, 2, ...)
x - the value
length - the maximum number of characters
Throws:
SQLException - if this object is closed
void setNString(int parameterIndex, String x)
Sets the value of a parameter.
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)
Sets a parameter to null.
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)
Sets a parameter to null.
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)
Sets the value of a parameter.
void setObject(int parameterIndex, Object x) throws SQLException
Sets the value of a parameter. Objects of unknown classes are serialized (on the client side).
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)
Sets the value of a parameter.
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. Objects of unknown classes are serialized (on the client side).
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)
Sets the value of a parameter.
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. Objects of unknown classes are serialized (on the client side).
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)
[Not supported] Sets the value of a column as a reference.
void setRef(int parameterIndex, Ref x) throws SQLException
[Not supported] Sets the value of a column as a reference.
void setRowId(int parameterIndex, RowId x)
[Not supported] Sets the value of a parameter as a row id.
void setRowId(int parameterIndex, RowId x) throws SQLException
[Not supported] Sets the value of a parameter as a row id.
void setSQLXML(int parameterIndex, SQLXML x)
[Not supported] Sets the value of a parameter as a SQLXML object.
void setSQLXML(int parameterIndex, SQLXML x) throws SQLException
[Not supported] Sets the value of a parameter as a SQLXML object.
void setShort(int parameterIndex, short x)
Sets the value of a parameter.
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)
Sets the value of a parameter.
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)
Sets the value of a parameter.
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)
Sets the time using a specified time zone.
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)
Sets the value of a parameter.
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)
Sets the timestamp using a specified time zone.
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)
[Not supported]
void setURL(int parameterIndex, URL x) throws SQLException
[Not supported]
void setUnicodeStream(int parameterIndex, InputStream x, int length)
[Not supported] This feature is deprecated and not supported.
void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException
[Not supported] This feature is deprecated and not supported.