Class DbPreparedStatement
- All Implemented Interfaces:
AutoCloseable,Cloneable
PreparedStatement
class. It can only be instantiated by calling the
getPreparedStatement method on an existing
DbConnection instance.
This class hooks into the database connection pool and cleans up as much
as possible in case of errors. The thrown DatabaseException
exceptions should thus only be used for error reporting and not for
releasing resources used by the framework.
The executeQuery method stores its resultset in the
executing DbPreparedStatement instance. It's recommended to
use the DbQueryManager's fetch method to process
the result set. If needed, one can also use the getResultSet
method to manually process the results through plain JDBC. However, when
exceptions are thrown during this procedure, it's also the responsability
of the user to correctly clean up all resources.
Additional methods have been implemented to take advantage of information that is present when one uses query builders to construct the database queries. In this case, parameter values can be set by using column names instead of column numbers and automatic population of a statement from bean property values is also supported.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddBatch()Adds a set of parameters to thisDbPreparedStatementobject's batch of commands.voidClears the current parameter values immediately.voidclose()Releases thisDbPreparedStatementobject's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.voidExecutes the SQL query in thisDbPreparedStatementobject.intExecutes the SQL statement in thisDbPreparedStatementobject, which must be an SQLINSERT,UPDATEorDELETEstatement; or a SQL statement that returns nothing, such as a DDL statement.Retrieves aResultSetMetaDataobject that contains information about the columns of theResultSetobject that will be returned when thisPDbreparedStatementobject is executed.int[]getParameterIndices(String parameterName) Retrieves all the parameter indices that correspond to the name of a parameter of theParametrizedQueryobject that is used by thisDbPreparedStatementinstance.Retrieves the number, types and properties of thisDbPreparedStatementobject's parameters.getQuery()Returns the query builder that provides the SQL query that will be executed by this prepared statement.getSql()Returns the SQL query that will be executed by this prepared statement.getVirtualParameterValue(int parameterIndex) Get the value of a specific virtual parameter.Get the value of a specific virtual parameter.Sets the designated parameter to the givenArrayobject.Sets the named parameters to the givenArrayobject.setAsciiStream(int parameterIndex, InputStream x, int length) Sets the designated parameter to the given input stream, which will have the specified number of bytes.setAsciiStream(String parameterName, InputStream x, int length) Sets the named parameter to the given input stream, which will have the specified number of bytes.Automatically retrieves all the values of a bean's properties and sets them for the parameters that have been defined by theParametrizedQueryobject of thisDbPrepareStatementinstance.setBigDecimal(int parameterIndex, BigDecimal x) Sets the designated parameter to the givenjava.math.BigDecimalvalue.setBigDecimal(String parameterName, BigDecimal x) Sets the named parameters to the givenjava.math.BigDecimalvalue.setBigDecimals(int[] parameterIndices, BigDecimal x) Sets the designated parameters to the givenjava.math.BigDecimalvalue.setBinaryStream(int parameterIndex, InputStream x, int length) Sets the designated parameter to the given input stream, which will have the specified number of bytes.setBinaryStream(String parameterName, InputStream x, int length) Sets the named parameter to the given input stream, which will have the specified number of bytes.Sets the designated parameter to the givenBlobobject.Sets the named parameter to the givenBlobobject.setBoolean(int parameterIndex, boolean x) Sets the designated parameter to the given Javabooleanvalue.setBoolean(String parameterName, boolean x) Sets the named parameters to the given Javabooleanvalue.setBooleans(int[] parameterIndices, boolean x) Sets the designated parameters to the given Javabooleanvalue.setByte(int parameterIndex, byte x) Sets the designated parameter to the given Javabytevalue.Sets the named parameters to the given Javabytevalue.setBytes(int[] parameterIndices, byte x) Sets the designated parameters to the given Javabytevalue.setBytes(int[] parameterIndices, byte[] x) Sets the designated parameters to the given Java array of bytes.setBytes(int parameterIndex, byte[] x) Sets the designated parameter to the given Java array of bytes.Sets the named parameters to the given Java array of bytes.setCharacterStream(int parameterIndex, Reader x, int length) Sets the designated parameter to the givenReaderobject, which is the given number of characters long.setCharacterStream(String parameterName, Reader x, int length) Sets the named parameter to the givenReaderobject, which is the given number of characters long.Sets the designated parameter to the givenClobobject.Sets the named parameter to the givenClobobject.Sets the designated parameter to the givenjava.sql.Datevalue.Sets the designated parameter to the givenjava.sql.Datevalue, using the givenCalendarobject.Sets the named parameters to the givenjava.sql.Datevalue.Sets the named parameters to the givenjava.sql.Datevalue, using the givenCalendarobject.Sets the designated parameters to the givenjava.sql.Datevalue.Sets the designated parameters to the givenjava.sql.Datevalue, using the givenCalendarobject.setDouble(int parameterIndex, double x) Sets the designated parameter to the given Javadoublevalue.Sets the named parameters to the given Javadoublevalue.setDoubles(int[] parameterIndices, double x) Sets the designated parameters to the given Javadoublevalue.setFloat(int parameterIndex, float x) Sets the designated parameter to the given Javafloatvalue.Sets the named parameters to the given Javafloatvalue.setFloats(int[] parameterIndices, float x) Sets the designated parameters to the given Javafloatvalue.setInt(int parameterIndex, int x) Sets the designated parameter to the given Javaintvalue.Sets the named parameter to the given Javaintvalue.setInts(int[] parameterIndices, int x) Sets the designated parameters to the given Javaintvalue.setLong(int parameterIndex, long x) Sets the designated parameter to the given Javalongvalue.Sets the named parameters to the given Javalongvalue.setLongs(int[] parameterIndices, long x) Sets the designated parameters to the given Javalongvalue.setNull(int parameterIndex, int sqlType) Sets the designated parameter to SQLNULL.Sets the designated parameter to SQLNULL.Sets the named parameters to SQLNULL.Sets the named parameters to SQLNULL.setNulls(int[] parameterIndices, int sqlType) Sets the designated parameters to SQLNULL.Sets the designated parameters to SQLNULL.Sets the value of the designated parameter using the given object.Sets the value of the designated parameter with the given object.Sets the value of the designated parameter with the given object.Sets the value of the named parameters using the given object.Sets the value of the named parameters with the given object.Sets the value of the named parameters with the given object.setObjects(int[] parameterIndices, Object x) Sets the value of the designated parameters using the given object.setObjects(int[] parameterIndices, Object x, int targetSqlType) Sets the value of the designated parameters with the given object.setObjects(int[] parameterIndices, Object x, int targetSqlType, int scale) Sets the value of the designated parameters with the given object.Sets the designated parameter to the givenREF(<structured-type>)value.Sets the named parameter to the givenREF(<structured-type>)value.setShort(int parameterIndex, short x) Sets the designated parameter to the given Javashortvalue.Sets the named parameters to the given Javashortvalue.setShorts(int[] parameterIndices, short x) Sets the designated parameters to the given Javashortvalue.Sets the designated parameter to the given JavaStringvalue.Sets the named parameters to the given JavaStringvalue.setStrings(int[] parameterIndices, String x) Sets the designated parameters to the given JavaStringvalue.Sets the designated parameter to the givenjava.sql.Timevalue.Sets the designated parameter to the givenjava.sql.Timevalue, using the givenCalendarobject.Sets the named parameters to the givenjava.sql.Timevalue.Sets the named parameters to the givenjava.sql.Timevalue, using the givenCalendarobject.Sets the designated parameters to the givenjava.sql.Timevalue.Sets the designated parameters to the givenjava.sql.Timevalue, using the givenCalendarobject.setTimestamp(int parameterIndex, Timestamp x) Sets the designated parameter to the givenjava.sql.Timestampvalue.setTimestamp(int parameterIndex, Timestamp x, Calendar cal) Sets the designated parameter to the givenjava.sql.Timestampvalue, using the givenCalendarobject.setTimestamp(String parameterName, Timestamp x) Sets the named parameters to the givenjava.sql.Timestampvalue.setTimestamp(String parameterName, Timestamp x, Calendar cal) Sets the named parameters to the givenjava.sql.Timestampvalue, using the givenCalendarobject.setTimestamps(int[] parameterIndices, Timestamp x) Sets the designated parameters to the givenjava.sql.Timestampvalue.setTimestamps(int[] parameterIndices, Timestamp x, Calendar cal) Sets the designated parameters to the givenjava.sql.Timestampvalue, using the givenCalendarobject.Sets the designated parameter to the givenjava.net.URLvalue.Sets the named parameters to the givenjava.net.URLvalue.Sets the designated parameters to the givenjava.net.URLvalue.voidsetVirtualParameters(VirtualParameters parameters) Sets the parameters that should be handled as virtual parameters.Methods inherited from class rife.database.DbStatement
addBatch, cancel, clearBatch, clearWarnings, clone, execute, execute, execute, execute, executeBatch, executeQuery, executeQuery, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getFirstGeneratedIntKey, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, handleException, outputTrace, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setQueryTimeout, setResultset, startTrace, traceBatch, wasNull
-
Method Details
-
getSql
Returns the SQL query that will be executed by this prepared statement.- Returns:
- a
Stringwith the SQL query of this prepared statement - Since:
- 1.0
-
getQuery
Returns the query builder that provides the SQL query that will be executed by this prepared statement.- Returns:
- a
Queryobject with the query builder instance; ornullif the prepared statement was initialized from a string SQL query - Since:
- 1.0
-
executeQuery
Executes the SQL query in thisDbPreparedStatementobject. TheResultSetobject generated by the query is stored and can be retrieved with thegetResultSetmethod.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Throws:
DatabaseException- if a database access error occurs or the SQL statement does not return aResultSetobject- Since:
- 1.0
- See Also:
-
executeUpdate
Executes the SQL statement in thisDbPreparedStatementobject, which must be an SQLINSERT,UPDATEorDELETEstatement; or a SQL statement that returns nothing, such as a DDL statement.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Returns:
- the row count for
INSERT,UPDATE, orDELETEstatements; or0 for SQL statements that return nothing
- Throws:
DatabaseException- if a database access error occurs or the SQL statement returns aResultSetobject- Since:
- 1.0
-
addBatch
Adds a set of parameters to thisDbPreparedStatementobject's batch of commands.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
close
Releases thisDbPreparedStatementobject's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed. It is generally good practice to release resources as soon as you are finished with them to avoid tying up database resources.Calling the method
closeon aDbPreparedStatementobject that is already closed has no effect.Note: A
DbPreparedStatementobject is automatically closed when it is garbage collected. When aDbPreparedStatementobject is closed, its currentResultSetobject, if one exists, is also closed.- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classDbStatement- Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
-
getMetaData
Retrieves aResultSetMetaDataobject that contains information about the columns of theResultSetobject that will be returned when thisPDbreparedStatementobject is executed.Because a
DbPreparedStatementobject is precompiled, it is possible to know about theResultSetobject that it will return without having to execute it. Consequently, it is possible to invoke the methodgetMetaDataon aDbPreparedStatementobject rather than waiting to execute it and then invoking theResultSet.getMetaDatamethod on theResultSetobject that is returned.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.NOTE: Using this method may be expensive for some drivers due to the lack of underlying DBMS support.
- Returns:
- the description of a
ResultSetobject's columns; ornullif the driver cannot return aResultSetMetaDataobject - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
-
getParameterMetaData
Retrieves the number, types and properties of thisDbPreparedStatementobject's parameters.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Returns:
- a
ParameterMetaDataobject that contains information about the number, types and properties of thisDbPreparedStatementobject's parameters. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
getVirtualParameterValue
Get the value of a specific virtual parameter.- Parameters:
name- the name of the parameter whose value should be retrieved- Returns:
- the requested value
- Throws:
DatabaseException- when an error occurred during the retrieval of the parameter's valueUndefinedVirtualParameterException- Since:
- 1.0
-
getVirtualParameterValue
Get the value of a specific virtual parameter.- Parameters:
parameterIndex- the index of the parameter whose value should be retrieved- Returns:
- the requested value
- Throws:
DatabaseException- when an error occurred during the retrieval of the parameter's value- Since:
- 1.0
-
setBean
Automatically retrieves all the values of a bean's properties and sets them for the parameters that have been defined by theParametrizedQueryobject of thisDbPrepareStatementinstance.- Parameters:
bean- the bean whose properties should be assigned to the query's parameters.- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if an error occurred during the manipulation of the bean's properties.- Since:
- 1.0
-
setVirtualParameters
Sets the parameters that should be handled as virtual parameters. These parameters are not sent to the backend, but their values will be stored in thisDbPreparedStatementinstance for retrieval by other functionalities like capabilities.- Parameters:
parameters- theVirtualParametersinstance that will determine the virtual parameters- Since:
- 1.0
-
getParameterIndices
Retrieves all the parameter indices that correspond to the name of a parameter of theParametrizedQueryobject that is used by thisDbPreparedStatementinstance.- Parameters:
parameterName- the name of the parameter that should be looked up- Returns:
- an
intarray with all the corresponding indices - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found.- Since:
- 1.0
-
setDouble
Sets the named parameters to the given Javadoublevalue. The driver converts this to a SQLDOUBLEvalue when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setDoubles
Sets the designated parameters to the given Javadoublevalue. The driver converts this to a SQLDOUBLEvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setDouble
Sets the designated parameter to the given Javadoublevalue. The driver converts this to a SQLDOUBLEvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setShort
Sets the named parameters to the given Javashortvalue. The driver converts this to a SQLSMALLINTvalue when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setShorts
Sets the designated parameters to the given Javashortvalue. The driver converts this to a SQLSMALLINTvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setShort
Sets the designated parameter to the given Javashortvalue. The driver converts this to a SQLSMALLINTvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setNull
Sets the named parameters to SQLNULL.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.Note: You must specify the parameter's SQL type.
- Parameters:
parameterName- the name of the parameters that have to be setsqlType- the SQL type code defined injava.sql.Types- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setNulls
Sets the designated parameters to SQLNULL.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.Note: You must specify the parameter's SQL type.
- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...sqlType- the SQL type code defined injava.sql.Types- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setNull
Sets the designated parameter to SQLNULL.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.Note: You must specify the parameter's SQL type.
- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...sqlType- the SQL type code defined injava.sql.Types- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setNull
public DbPreparedStatement setNull(String parameterName, int sqlType, String typeName) throws DatabaseException Sets the named parameters to SQLNULL. This version of the methodsetNullshould be used for user-defined types and REF type parameters. Examples of user-defined types include: STRUCT, DISTINCT, JAVA_OBJECT, and named array types.Note: To be portable, applications must give the SQL type code and the fully-qualified SQL type name when specifying a NULL user-defined or REF parameter. In the case of a user-defined type the name is the type name of the parameter itself. For a REF parameter, the name is the type name of the referenced type. If a JDBC driver does not need the type code or type name information, it may ignore it.
Although it is intended for user-defined and Ref parameters, this method may be used to set a null parameter of any JDBC type. If the parameter does not have a user-defined or REF type, the given typeName is ignored.
If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setsqlType- a value fromjava.sql.TypestypeName- the fully-qualified name of an SQL user-defined type; ignored if the parameter is not a user-defined type or REF- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setNulls
public DbPreparedStatement setNulls(int[] parameterIndices, int sqlType, String typeName) throws DatabaseException Sets the designated parameters to SQLNULL. This version of the methodsetNullshould be used for user-defined types and REF type parameters. Examples of user-defined types include: STRUCT, DISTINCT, JAVA_OBJECT, and named array types.Note: To be portable, applications must give the SQL type code and the fully-qualified SQL type name when specifying a NULL user-defined or REF parameter. In the case of a user-defined type the name is the type name of the parameter itself. For a REF parameter, the name is the type name of the referenced type. If a JDBC driver does not need the type code or type name information, it may ignore it.
Although it is intended for user-defined and Ref parameters, this method may be used to set a null parameter of any JDBC type. If the parameter does not have a user-defined or REF type, the given typeName is ignored.
If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...sqlType- a value fromjava.sql.TypestypeName- the fully-qualified name of an SQL user-defined type; ignored if the parameter is not a user-defined type or REF- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setNull
public DbPreparedStatement setNull(int parameterIndex, int sqlType, String typeName) throws DatabaseException Sets the designated parameter to SQLNULL. This version of the methodsetNullshould be used for user-defined types and REF type parameters. Examples of user-defined types include: STRUCT, DISTINCT, JAVA_OBJECT, and named array types.Note: To be portable, applications must give the SQL type code and the fully-qualified SQL type name when specifying a NULL user-defined or REF parameter. In the case of a user-defined type the name is the type name of the parameter itself. For a REF parameter, the name is the type name of the referenced type. If a JDBC driver does not need the type code or type name information, it may ignore it.
Although it is intended for user-defined and Ref parameters, this method may be used to set a null parameter of any JDBC type. If the parameter does not have a user-defined or REF type, the given typeName is ignored.
If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...sqlType- a value fromjava.sql.TypestypeName- the fully-qualified name of an SQL user-defined type; ignored if the parameter is not a user-defined type or REF- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setBoolean
Sets the named parameters to the given Javabooleanvalue. The driver converts this to a SQLBITvalue when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setBooleans
Sets the designated parameters to the given Javabooleanvalue. The driver converts this to a SQLBITvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setBoolean
Sets the designated parameter to the given Javabooleanvalue. The driver converts this to a SQLBITvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setByte
Sets the named parameters to the given Javabytevalue. The driver converts this to a SQLTINYINTvalue when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setBytes
Sets the designated parameters to the given Javabytevalue. The driver converts this to a SQLTINYINTvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setByte
Sets the designated parameter to the given Javabytevalue. The driver converts this to a SQLTINYINTvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setDate
Sets the named parameters to the givenjava.sql.Datevalue. The driver converts this to a SQLDATEvalue when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setDates
Sets the designated parameters to the givenjava.sql.Datevalue. The driver converts this to a SQLDATEvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setDate
Sets the designated parameter to the givenjava.sql.Datevalue. The driver converts this to a SQLDATEvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setDate
public DbPreparedStatement setDate(String parameterName, Date x, Calendar cal) throws DatabaseException Sets the named parameters to the givenjava.sql.Datevalue, using the givenCalendarobject. The driver uses theCalendarobject to construct an SQLDATEvalue, which the driver then sends to the database. With aCalendarobject, the driver can calculate the date taking into account a custom timezone. If noCalendarobject is specified, the driver uses the default timezone, which is that of the virtual machine running the application.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the parameter valuecal- theCalendarobject the driver will use to construct the date- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setDates
public DbPreparedStatement setDates(int[] parameterIndices, Date x, Calendar cal) throws DatabaseException Sets the designated parameters to the givenjava.sql.Datevalue, using the givenCalendarobject. The driver uses theCalendarobject to construct an SQLDATEvalue, which the driver then sends to the database. With aCalendarobject, the driver can calculate the date taking into account a custom timezone. If noCalendarobject is specified, the driver uses the default timezone, which is that of the virtual machine running the application.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the parameter valuecal- theCalendarobject the driver will use to construct the date- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setDate
public DbPreparedStatement setDate(int parameterIndex, Date x, Calendar cal) throws DatabaseException Sets the designated parameter to the givenjava.sql.Datevalue, using the givenCalendarobject. The driver uses theCalendarobject to construct an SQLDATEvalue, which the driver then sends to the database. With aCalendarobject, the driver can calculate the date taking into account a custom timezone. If noCalendarobject is specified, the driver uses the default timezone, which is that of the virtual machine running the application.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the parameter valuecal- theCalendarobject the driver will use to construct the date- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setInt
Sets the named parameter to the given Javaintvalue. The driver converts this to a SQLINTEGERvalue when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setInts
Sets the designated parameters to the given Javaintvalue. The driver converts this to a SQLINTEGERvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setInt
Sets the designated parameter to the given Javaintvalue. The driver converts this to a SQLINTEGERvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setLong
Sets the named parameters to the given Javalongvalue. The driver converts this to a SQLBIGINTvalue when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setLongs
Sets the designated parameters to the given Javalongvalue. The driver converts this to a SQLBIGINTvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setLong
Sets the designated parameter to the given Javalongvalue. The driver converts this to a SQLBIGINTvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setFloat
Sets the named parameters to the given Javafloatvalue. The driver converts this to a SQLFLOATvalue when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setFloats
Sets the designated parameters to the given Javafloatvalue. The driver converts this to a SQLFLOATvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setFloat
Sets the designated parameter to the given Javafloatvalue. The driver converts this to a SQLFLOATvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setBigDecimal
public DbPreparedStatement setBigDecimal(String parameterName, BigDecimal x) throws DatabaseException Sets the named parameters to the givenjava.math.BigDecimalvalue. The driver converts this to a SQLNUMERICvalue when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setBigDecimals
public DbPreparedStatement setBigDecimals(int[] parameterIndices, BigDecimal x) throws DatabaseException Sets the designated parameters to the givenjava.math.BigDecimalvalue. The driver converts this to a SQLNUMERICvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setBigDecimal
Sets the designated parameter to the givenjava.math.BigDecimalvalue. The driver converts this to a SQLNUMERICvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setString
Sets the named parameters to the given JavaStringvalue. The driver converts this to a SQLVARCHARorLONGVARCHARvalue (depending on the argument's size relative to the driver's limits onVARCHARvalues) when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setStrings
Sets the designated parameters to the given JavaStringvalue. The driver converts this to a SQLVARCHARorLONGVARCHARvalue (depending on the argument's size relative to the driver's limits onVARCHARvalues) when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setString
Sets the designated parameter to the given JavaStringvalue. The driver converts this to a SQLVARCHARorLONGVARCHARvalue (depending on the argument's size relative to the driver's limits onVARCHARvalues) when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setBytes
Sets the named parameters to the given Java array of bytes. The driver converts this to a SQLVARBINARYorLONGVARBINARY(depending on the argument's size relative to the driver's limits onVARBINARYvalues) when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setBytes
Sets the designated parameters to the given Java array of bytes. The driver converts this to a SQLVARBINARYorLONGVARBINARY(depending on the argument's size relative to the driver's limits onVARBINARYvalues) when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setBytes
Sets the designated parameter to the given Java array of bytes. The driver converts this to a SQLVARBINARYorLONGVARBINARY(depending on the argument's size relative to the driver's limits onVARBINARYvalues) when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setObject
public DbPreparedStatement setObject(String parameterName, Object x, int targetSqlType, int scale) throws DatabaseException Sets the value of the named parameters with the given object. The second argument must be an object type; for integral values, thejava.langequivalent objects should be used.The given Java object will be converted to the given targetSqlType before being sent to the database.
If the object has a custom mapping (is of a class implementing the interface
SQLData), the JDBC driver should call the methodSQLData.writeSQLto write it to the SQL data stream. If, on the other hand, the object is of a class implementingRef,Blob,Clob,Struct, orArray, the driver should pass it to the database as a value of the corresponding SQL type.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.Note that this method may be used to pass database-specific abstract data types.
- Parameters:
parameterName- the name of the parameters that have to be setx- the object containing the input parameter valuetargetSqlType- the SQL type (as defined in java.sql.Types) to be sent to the database. The scale argument may further qualify this type.scale- for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types, this is the number of digits after the decimal point. For all other types, this value will be ignored.- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setObjects
public DbPreparedStatement setObjects(int[] parameterIndices, Object x, int targetSqlType, int scale) throws DatabaseException Sets the value of the designated parameters with the given object. The second argument must be an object type; for integral values, thejava.langequivalent objects should be used.The given Java object will be converted to the given targetSqlType before being sent to the database.
If the object has a custom mapping (is of a class implementing the interface
SQLData), the JDBC driver should call the methodSQLData.writeSQLto write it to the SQL data stream. If, on the other hand, the object is of a class implementingRef,Blob,Clob,Struct, orArray, the driver should pass it to the database as a value of the corresponding SQL type.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.Note that this method may be used to pass database-specific abstract data types.
- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the object containing the input parameter valuetargetSqlType- the SQL type (as defined in java.sql.Types) to be sent to the database. The scale argument may further qualify this type.scale- for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types, this is the number of digits after the decimal point. For all other types, this value will be ignored.- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setObject
public DbPreparedStatement setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws DatabaseException Sets the value of the designated parameter with the given object. The second argument must be an object type; for integral values, thejava.langequivalent objects should be used.The given Java object will be converted to the given targetSqlType before being sent to the database.
If the object has a custom mapping (is of a class implementing the interface
SQLData), the JDBC driver should call the methodSQLData.writeSQLto write it to the SQL data stream. If, on the other hand, the object is of a class implementingRef,Blob,Clob,Struct, orArray, the driver should pass it to the database as a value of the corresponding SQL type.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.Note that this method may be used to pass database-specific abstract data types.
- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the object containing the input parameter valuetargetSqlType- the SQL type (as defined in java.sql.Types) to be sent to the database. The scale argument may further qualify this type.scale- for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types, this is the number of digits after the decimal point. For all other types, this value will be ignored.- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setObject
public DbPreparedStatement setObject(String parameterName, Object x, int targetSqlType) throws DatabaseException Sets the value of the named parameters with the given object. This method is like the methodsetObjectabove, except that it assumes a scale of zero.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the object containing the input parameter valuetargetSqlType- the SQL type (as defined in java.sql.Types) to be sent to the database- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setObjects
public DbPreparedStatement setObjects(int[] parameterIndices, Object x, int targetSqlType) throws DatabaseException Sets the value of the designated parameters with the given object. This method is like the methodsetObjectabove, except that it assumes a scale of zero.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the object containing the input parameter valuetargetSqlType- the SQL type (as defined in java.sql.Types) to be sent to the database- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setObject
public DbPreparedStatement setObject(int parameterIndex, Object x, int targetSqlType) throws DatabaseException Sets the value of the designated parameter with the given object. This method is like the methodsetObjectabove, except that it assumes a scale of zero.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the object containing the input parameter valuetargetSqlType- the SQL type (as defined in java.sql.Types) to be sent to the database- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setTime
Sets the named parameters to the givenjava.sql.Timevalue. The driver converts this to a SQLTIMEvalue when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setTimes
Sets the designated parameters to the givenjava.sql.Timevalue. The driver converts this to a SQLTIMEvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setTime
Sets the designated parameter to the givenjava.sql.Timevalue. The driver converts this to a SQLTIMEvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setTime
public DbPreparedStatement setTime(String parameterName, Time x, Calendar cal) throws DatabaseException Sets the named parameters to the givenjava.sql.Timevalue, using the givenCalendarobject. The driver uses theCalendarobject to construct an SQLTIMEvalue, which the driver then sends to the database. With aCalendarobject, the driver can calculate the time taking into account a custom timezone. If noCalendarobject is specified, the driver uses the default timezone, which is that of the virtual machine running the application.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the parameter valuecal- theCalendarobject the driver will use to construct the time- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setTimes
public DbPreparedStatement setTimes(int[] parameterIndices, Time x, Calendar cal) throws DatabaseException Sets the designated parameters to the givenjava.sql.Timevalue, using the givenCalendarobject. The driver uses theCalendarobject to construct an SQLTIMEvalue, which the driver then sends to the database. With aCalendarobject, the driver can calculate the time taking into account a custom timezone. If noCalendarobject is specified, the driver uses the default timezone, which is that of the virtual machine running the application.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the parameter valuecal- theCalendarobject the driver will use to construct the time- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setTime
public DbPreparedStatement setTime(int parameterIndex, Time x, Calendar cal) throws DatabaseException Sets the designated parameter to the givenjava.sql.Timevalue, using the givenCalendarobject. The driver uses theCalendarobject to construct an SQLTIMEvalue, which the driver then sends to the database. With aCalendarobject, the driver can calculate the time taking into account a custom timezone. If noCalendarobject is specified, the driver uses the default timezone, which is that of the virtual machine running the application.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the parameter valuecal- theCalendarobject the driver will use to construct the time- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setTimestamp
Sets the named parameters to the givenjava.sql.Timestampvalue. The driver converts this to a SQLTIMESTAMPvalue when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setTimestamps
public DbPreparedStatement setTimestamps(int[] parameterIndices, Timestamp x) throws DatabaseException Sets the designated parameters to the givenjava.sql.Timestampvalue. The driver converts this to a SQLTIMESTAMPvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setTimestamp
Sets the designated parameter to the givenjava.sql.Timestampvalue. The driver converts this to a SQLTIMESTAMPvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setTimestamp
public DbPreparedStatement setTimestamp(String parameterName, Timestamp x, Calendar cal) throws DatabaseException Sets the named parameters to the givenjava.sql.Timestampvalue, using the givenCalendarobject. The driver uses theCalendarobject to construct an SQLTIMESTAMPvalue, which the driver then sends to the database. With aCalendarobject, the driver can calculate the timestamp taking into account a custom timezone. If noCalendarobject is specified, the driver uses the default timezone, which is that of the virtual machine running the application.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- the parameter valuecal- theCalendarobject the driver will use to construct the timestamp- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setTimestamps
public DbPreparedStatement setTimestamps(int[] parameterIndices, Timestamp x, Calendar cal) throws DatabaseException Sets the designated parameters to the givenjava.sql.Timestampvalue, using the givenCalendarobject. The driver uses theCalendarobject to construct an SQLTIMESTAMPvalue, which the driver then sends to the database. With aCalendarobject, the driver can calculate the timestamp taking into account a custom timezone. If noCalendarobject is specified, the driver uses the default timezone, which is that of the virtual machine running the application.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the parameter valuecal- theCalendarobject the driver will use to construct the timestamp- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setTimestamp
public DbPreparedStatement setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws DatabaseException Sets the designated parameter to the givenjava.sql.Timestampvalue, using the givenCalendarobject. The driver uses theCalendarobject to construct an SQLTIMESTAMPvalue, which the driver then sends to the database. With aCalendarobject, the driver can calculate the timestamp taking into account a custom timezone. If noCalendarobject is specified, the driver uses the default timezone, which is that of the virtual machine running the application.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the parameter valuecal- theCalendarobject the driver will use to construct the timestamp- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setAsciiStream
public DbPreparedStatement setAsciiStream(String parameterName, InputStream x, int length) throws DatabaseException Sets the named parameter to the given input stream, which will have the specified number of bytes. When a very large ASCII value is input to aLONGVARCHARparameter, it may be more practical to send it via ajava.io.InputStream. Data will be read from the stream as needed until end-of-file is reached. The JDBC driver will do any necessary conversion from ASCII to the database char format.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
- Parameters:
parameterName- the name of the parameter that will be set (the first parameter with the name will be used)x- the Java input stream that contains the ASCII parameter valuelength- the number of bytes in the stream- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setAsciiStream
public DbPreparedStatement setAsciiStream(int parameterIndex, InputStream x, int length) throws DatabaseException Sets the designated parameter to the given input stream, which will have the specified number of bytes. When a very large ASCII value is input to aLONGVARCHARparameter, it may be more practical to send it via ajava.io.InputStream. Data will be read from the stream as needed until end-of-file is reached. The JDBC driver will do any necessary conversion from ASCII to the database char format.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the Java input stream that contains the ASCII parameter valuelength- the number of bytes in the stream- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setCharacterStream
public DbPreparedStatement setCharacterStream(String parameterName, Reader x, int length) throws DatabaseException Sets the named parameter to the givenReaderobject, which is the given number of characters long. When a very large UNICODE value is input to aLONGVARCHARparameter, it may be more practical to send it via ajava.io.Readerobject. The data will be read from the stream as needed until end-of-file is reached. The JDBC driver will do any necessary conversion from UNICODE to the database char format.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
- Parameters:
parameterName- the name of the parameter that will be set (the first parameter with the name will be used)x- thejava.io.Readerobject that contains the Unicode datalength- the number of characters in the stream- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setCharacterStream
public DbPreparedStatement setCharacterStream(int parameterIndex, Reader x, int length) throws DatabaseException Sets the designated parameter to the givenReaderobject, which is the given number of characters long. When a very large UNICODE value is input to aLONGVARCHARparameter, it may be more practical to send it via ajava.io.Readerobject. The data will be read from the stream as needed until end-of-file is reached. The JDBC driver will do any necessary conversion from UNICODE to the database char format.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- thejava.io.Readerobject that contains the Unicode datalength- the number of characters in the stream- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setBinaryStream
public DbPreparedStatement setBinaryStream(String parameterName, InputStream x, int length) throws DatabaseException Sets the named parameter to the given input stream, which will have the specified number of bytes. When a very large binary value is input to aLONGVARBINARYparameter, it may be more practical to send it via ajava.io.InputStreamobject. The data will be read from the stream as needed until end-of-file is reached.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
- Parameters:
parameterName- the name of the parameter that will be set (the first parameter with the name will be used)x- the java input stream which contains the binary parameter valuelength- the number of bytes in the stream- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setBinaryStream
public DbPreparedStatement setBinaryStream(int parameterIndex, InputStream x, int length) throws DatabaseException Sets the designated parameter to the given input stream, which will have the specified number of bytes. When a very large binary value is input to aLONGVARBINARYparameter, it may be more practical to send it via ajava.io.InputStreamobject. The data will be read from the stream as needed until end-of-file is reached.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.
- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the java input stream which contains the binary parameter valuelength- the number of bytes in the stream- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setArray
Sets the named parameters to the givenArrayobject. The driver converts this to a SQLARRAYvalue when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameter that will be setx- anArrayobject that maps an SQLARRAYvalue- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setArray
Sets the designated parameter to the givenArrayobject. The driver converts this to a SQLARRAYvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- anArrayobject that maps an SQLARRAYvalue- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setObject
Sets the value of the named parameters using the given object. The second parameter must be of typeObject; therefore, thejava.langequivalent objects should be used for built-in types.The JDBC specification specifies a standard mapping from Java
Objecttypes to SQL types. The given argument will be converted to the corresponding SQL type before being sent to the database.Note that this method may be used to pass datatabase-specific abstract data types, by using a driver-specific Java type.
If the object is of a class implementing the interface
SQLData, the JDBC driver should call the methodSQLData.writeSQLto write it to the SQL data stream. If, on the other hand, the object is of a class implementingRef,Blob,Clob,Struct, orArray, the driver should pass it to the database as a value of the corresponding SQL type.This method throws an exception if there is an ambiguity, for example, if the object is of a class implementing more than one of the interfaces named above.
If such an ambiquity exception is thrown or if a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameter that will be setx- the object containing the input parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs, or if the type of the given object is ambiguous.- Since:
- 1.0
- See Also:
-
setObjects
Sets the value of the designated parameters using the given object. The second parameter must be of typeObject; therefore, thejava.langequivalent objects should be used for built-in types.The JDBC specification specifies a standard mapping from Java
Objecttypes to SQL types. The given argument will be converted to the corresponding SQL type before being sent to the database.Note that this method may be used to pass datatabase-specific abstract data types, by using a driver-specific Java type.
If the object is of a class implementing the interface
SQLData, the JDBC driver should call the methodSQLData.writeSQLto write it to the SQL data stream. If, on the other hand, the object is of a class implementingRef,Blob,Clob,Struct, orArray, the driver should pass it to the database as a value of the corresponding SQL type.This method throws an exception if there is an ambiguity, for example, if the object is of a class implementing more than one of the interfaces named above.
If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- the object containing the input parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs or the type of the given object is ambiguous- Since:
- 1.0
- See Also:
-
setObject
Sets the value of the designated parameter using the given object. The second parameter must be of typeObject; therefore, thejava.langequivalent objects should be used for built-in types.The JDBC specification specifies a standard mapping from Java
Objecttypes to SQL types. The given argument will be converted to the corresponding SQL type before being sent to the database.Note that this method may be used to pass datatabase-specific abstract data types, by using a driver-specific Java type.
If the object is of a class implementing the interface
SQLData, the JDBC driver should call the methodSQLData.writeSQLto write it to the SQL data stream. If, on the other hand, the object is of a class implementingRef,Blob,Clob,Struct, orArray, the driver should pass it to the database as a value of the corresponding SQL type.This method throws an exception if there is an ambiguity, for example, if the object is of a class implementing more than one of the interfaces named above.
If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- the object containing the input parameter value- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs or the type of the given object is ambiguous- Since:
- 1.0
- See Also:
-
setRef
Sets the named parameter to the givenREF(<structured-type>)value. The driver converts this to a SQLREFvalue when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameter that will be set (the first parameter with the name will be used)x- an SQLREFvalue- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setRef
Sets the designated parameter to the givenREF(<structured-type>)value. The driver converts this to a SQLREFvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- an SQLREFvalue- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setBlob
Sets the named parameter to the givenBlobobject. The driver converts this to a SQLBLOBvalue when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameter that will be set (the first parameter with the name will be used)x- aBlobobject that maps an SQLBLOBvalue- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setBlob
Sets the designated parameter to the givenBlobobject. The driver converts this to a SQLBLOBvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- aBlobobject that maps an SQLBLOBvalue- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setClob
Sets the named parameter to the givenClobobject. The driver converts this to a SQLCLOBvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterName- the name of the parameter that will be set (the first parameter with the name will be used)x- aClobobject that maps an SQLCLOBvalue- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setClob
Sets the designated parameter to the givenClobobject. The driver converts this to a SQLCLOBvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- aClobobject that maps an SQLCLOBvalue- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setURL
Sets the named parameters to the givenjava.net.URLvalue. The driver converts this to a SQLDATALINKvalue when it sends it to the database.If a database access error occurs, this
DbPreparedStatementinstance is automatically closed.- Parameters:
parameterName- the name of the parameters that have to be setx- thejava.net.URLobject to be set- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- when thisDbPrepareStatementinstance wasn't defined by aParametrizedQuerybut by a regular sql string, or if theParametrizedQuerydoesn't contain any parameters, or if no parameters with this name could be found, or if a database access error occurs.- Since:
- 1.0
- See Also:
-
setURLs
Sets the designated parameters to the givenjava.net.URLvalue. The driver converts this to a SQLDATALINKvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndices- the first parameter is 1, the second is 2, ...x- thejava.net.URLobject to be set- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
setURL
Sets the designated parameter to the givenjava.net.URLvalue. The driver converts this to a SQLDATALINKvalue when it sends it to the database.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Parameters:
parameterIndex- the first parameter is 1, the second is 2, ...x- thejava.net.URLobject to be set- Returns:
- this
DbPreparedStatementinstance. - Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
- See Also:
-
clearParameters
Clears the current parameter values immediately.In general, parameter values remain in force for repeated use of a statement. Setting a parameter value automatically clears its previous value. However, in some cases it is useful to immediately release the resources used by the current parameter values; this can be done by calling the method
clearParameters.If an exception is thrown, this
DbPreparedStatementis automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.- Throws:
DatabaseException- if a database access error occurs- Since:
- 1.0
-