com.uwyn.rife.database
Class DbPreparedStatement

java.lang.Object
  extended by com.uwyn.rife.database.DbStatement
      extended by com.uwyn.rife.database.DbPreparedStatement
All Implemented Interfaces:
Cloneable

public class DbPreparedStatement
extends DbStatement

Provides a wrapper around the regular JDBC 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.

Since:
1.0
Version:
$Revision: 3657 $
Author:
Geert Bevin (gbevin[remove] at uwyn dot com)
See Also:
executeQuery(), DbStatement.getResultSet(), DbConnection.getPreparedStatement(String), DbQueryManager.fetch(ResultSet, DbRowProcessor), Delete, Insert, Select, Update, PreparedStatement, ResultSet

Method Summary
 void addBatch()
          Adds a set of parameters to this DbPreparedStatement object's batch of commands.
 void clearParameters()
          Clears the current parameter values immediately.
 void close()
          Releases this DbPreparedStatement object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.
 void executeQuery()
          Executes the SQL query in this DbPreparedStatement object.
 int executeUpdate()
          Executes the SQL statement in this DbPreparedStatement object, which must be an SQL INSERT, UPDATE or DELETE statement; or a SQL statement that returns nothing, such as a DDL statement.
 ResultSetMetaData getMetaData()
          Retrieves a ResultSetMetaData object that contains information about the columns of the ResultSet object that will be returned when this PDbreparedStatement object is executed.
 int[] getParameterIndices(String parameterName)
          Retrieves all the parameter indices that correspond to the name of a parameter of the ParametrizedQuery object that is used by this DbPreparedStatement instance.
 ParameterMetaData getParameterMetaData()
          Retrieves the number, types and properties of this DbPreparedStatement object's parameters.
 Query getQuery()
          Returns the query builder that provides the SQL query that will be executed by this prepared statement.
 String getSql()
          Returns the SQL query that will be executed by this prepared statement.
 Object getVirtualParameterValue(int parameterIndex)
          Get the value of a specific virtual parameter.
 Object getVirtualParameterValue(String name)
          Get the value of a specific virtual parameter.
 DbPreparedStatement setArray(int parameterIndex, Array x)
          Sets the designated parameter to the given Array object.
 DbPreparedStatement setArray(String parameterName, Array x)
          Sets the named parameters to the given Array object.
 DbPreparedStatement setAsciiStream(int parameterIndex, InputStream x, int length)
          Sets the designated parameter to the given input stream, which will have the specified number of bytes.
 DbPreparedStatement setAsciiStream(String parameterName, InputStream x, int length)
          Sets the named parameter to the given input stream, which will have the specified number of bytes.
 DbPreparedStatement setBean(Object bean)
          Automatically retrieves all the values of a bean's properties and sets them for the parameters that have been defined by the ParametrizedQuery object of this DbPrepareStatement instance.
 DbPreparedStatement setBigDecimal(int parameterIndex, BigDecimal x)
          Sets the designated parameter to the given java.math.BigDecimal value.
 DbPreparedStatement setBigDecimal(String parameterName, BigDecimal x)
          Sets the named parameters to the given java.math.BigDecimal value.
 DbPreparedStatement setBigDecimals(int[] parameterIndices, BigDecimal x)
          Sets the designated parameters to the given java.math.BigDecimal value.
 DbPreparedStatement setBinaryStream(int parameterIndex, InputStream x, int length)
          Sets the designated parameter to the given input stream, which will have the specified number of bytes.
 DbPreparedStatement setBinaryStream(String parameterName, InputStream x, int length)
          Sets the named parameter to the given input stream, which will have the specified number of bytes.
 DbPreparedStatement setBlob(int parameterIndex, Blob x)
          Sets the designated parameter to the given Blob object.
 DbPreparedStatement setBlob(String parameterName, Blob x)
          Sets the named parameter to the given Blob object.
 DbPreparedStatement setBoolean(int parameterIndex, boolean x)
          Sets the designated parameter to the given Java boolean value.
 DbPreparedStatement setBoolean(String parameterName, boolean x)
          Sets the named parameters to the given Java boolean value.
 DbPreparedStatement setBooleans(int[] parameterIndices, boolean x)
          Sets the designated parameters to the given Java boolean value.
 DbPreparedStatement setByte(int parameterIndex, byte x)
          Sets the designated parameter to the given Java byte value.
 DbPreparedStatement setByte(String parameterName, byte x)
          Sets the named parameters to the given Java byte value.
 DbPreparedStatement setBytes(int[] parameterIndices, byte x)
          Sets the designated parameters to the given Java byte value.
 DbPreparedStatement setBytes(int[] parameterIndices, byte[] x)
          Sets the designated parameters to the given Java array of bytes.
 DbPreparedStatement setBytes(int parameterIndex, byte[] x)
          Sets the designated parameter to the given Java array of bytes.
 DbPreparedStatement setBytes(String parameterName, byte[] x)
          Sets the named parameters to the given Java array of bytes.
 DbPreparedStatement setCharacterStream(int parameterIndex, Reader x, int length)
          Sets the designated parameter to the given Reader object, which is the given number of characters long.
 DbPreparedStatement setCharacterStream(String parameterName, Reader x, int length)
          Sets the named parameter to the given Reader object, which is the given number of characters long.
 DbPreparedStatement setClob(int parameterIndex, Clob x)
          Sets the designated parameter to the given Clob object.
 DbPreparedStatement setClob(String parameterName, Clob x)
          Sets the named parameter to the given Clob object.
 DbPreparedStatement setDate(int parameterIndex, Date x)
          Sets the designated parameter to the given java.sql.Date value.
 DbPreparedStatement setDate(int parameterIndex, Date x, Calendar cal)
          Sets the designated parameter to the given java.sql.Date value, using the given Calendar object.
 DbPreparedStatement setDate(String parameterName, Date x)
          Sets the named parameters to the given java.sql.Date value.
 DbPreparedStatement setDate(String parameterName, Date x, Calendar cal)
          Sets the named parameters to the given java.sql.Date value, using the given Calendar object.
 DbPreparedStatement setDates(int[] parameterIndices, Date x)
          Sets the designated parameters to the given java.sql.Date value.
 DbPreparedStatement setDates(int[] parameterIndices, Date x, Calendar cal)
          Sets the designated parameters to the given java.sql.Date value, using the given Calendar object.
 DbPreparedStatement setDouble(int parameterIndex, double x)
          Sets the designated parameter to the given Java double value.
 DbPreparedStatement setDouble(String parameterName, double x)
          Sets the named parameters to the given Java double value.
 DbPreparedStatement setDoubles(int[] parameterIndices, double x)
          Sets the designated parameters to the given Java double value.
 DbPreparedStatement setFloat(int parameterIndex, float x)
          Sets the designated parameter to the given Java float value.
 DbPreparedStatement setFloat(String parameterName, float x)
          Sets the named parameters to the given Java float value.
 DbPreparedStatement setFloats(int[] parameterIndices, float x)
          Sets the designated parameters to the given Java float value.
 DbPreparedStatement setInt(int parameterIndex, int x)
          Sets the designated parameter to the given Java int value.
 DbPreparedStatement setInt(String parameterName, int x)
          Sets the named parameter to the given Java int value.
 DbPreparedStatement setInts(int[] parameterIndices, int x)
          Sets the designated parameters to the given Java int value.
 DbPreparedStatement setLong(int parameterIndex, long x)
          Sets the designated parameter to the given Java long value.
 DbPreparedStatement setLong(String parameterName, long x)
          Sets the named parameters to the given Java long value.
 DbPreparedStatement setLongs(int[] parameterIndices, long x)
          Sets the designated parameters to the given Java long value.
 DbPreparedStatement setNull(int parameterIndex, int sqlType)
          Sets the designated parameter to SQL NULL.
 DbPreparedStatement setNull(int parameterIndex, int sqlType, String typeName)
          Sets the designated parameter to SQL NULL.
 DbPreparedStatement setNull(String parameterName, int sqlType)
          Sets the named parameters to SQL NULL.
 DbPreparedStatement setNull(String parameterName, int sqlType, String typeName)
          Sets the named parameters to SQL NULL.
 DbPreparedStatement setNulls(int[] parameterIndices, int sqlType)
          Sets the designated parameters to SQL NULL.
 DbPreparedStatement setNulls(int[] parameterIndices, int sqlType, String typeName)
          Sets the designated parameters to SQL NULL.
 DbPreparedStatement setObject(int parameterIndex, Object x)
          Sets the value of the designated parameter using the given object.
 DbPreparedStatement setObject(int parameterIndex, Object x, int targetSqlType)
          Sets the value of the designated parameter with the given object.
 DbPreparedStatement setObject(int parameterIndex, Object x, int targetSqlType, int scale)
          Sets the value of the designated parameter with the given object.
 DbPreparedStatement setObject(String parameterName, Object x)
          Sets the value of the named parameters using the given object.
 DbPreparedStatement setObject(String parameterName, Object x, int targetSqlType)
          Sets the value of the named parameters with the given object.
 DbPreparedStatement setObject(String parameterName, Object x, int targetSqlType, int scale)
          Sets the value of the named parameters with the given object.
 DbPreparedStatement setObjects(int[] parameterIndices, Object x)
          Sets the value of the designated parameters using the given object.
 DbPreparedStatement setObjects(int[] parameterIndices, Object x, int targetSqlType)
          Sets the value of the designated parameters with the given object.
 DbPreparedStatement setObjects(int[] parameterIndices, Object x, int targetSqlType, int scale)
          Sets the value of the designated parameters with the given object.
 DbPreparedStatement setRef(int parameterIndex, Ref x)
          Sets the designated parameter to the given REF(<structured-type>) value.
 DbPreparedStatement setRef(String parameterName, Ref x)
          Sets the named parameter to the given REF(<structured-type>) value.
 DbPreparedStatement setShort(int parameterIndex, short x)
          Sets the designated parameter to the given Java short value.
 DbPreparedStatement setShort(String parameterName, short x)
          Sets the named parameters to the given Java short value.
 DbPreparedStatement setShorts(int[] parameterIndices, short x)
          Sets the designated parameters to the given Java short value.
 DbPreparedStatement setString(int parameterIndex, String x)
          Sets the designated parameter to the given Java String value.
 DbPreparedStatement setString(String parameterName, String x)
          Sets the named parameters to the given Java String value.
 DbPreparedStatement setStrings(int[] parameterIndices, String x)
          Sets the designated parameters to the given Java String value.
 DbPreparedStatement setTime(int parameterIndex, Time x)
          Sets the designated parameter to the given java.sql.Time value.
 DbPreparedStatement setTime(int parameterIndex, Time x, Calendar cal)
          Sets the designated parameter to the given java.sql.Time value, using the given Calendar object.
 DbPreparedStatement setTime(String parameterName, Time x)
          Sets the named parameters to the given java.sql.Time value.
 DbPreparedStatement setTime(String parameterName, Time x, Calendar cal)
          Sets the named parameters to the given java.sql.Time value, using the given Calendar object.
 DbPreparedStatement setTimes(int[] parameterIndices, Time x)
          Sets the designated parameters to the given java.sql.Time value.
 DbPreparedStatement setTimes(int[] parameterIndices, Time x, Calendar cal)
          Sets the designated parameters to the given java.sql.Time value, using the given Calendar object.
 DbPreparedStatement setTimestamp(int parameterIndex, Timestamp x)
          Sets the designated parameter to the given java.sql.Timestamp value.
 DbPreparedStatement setTimestamp(int parameterIndex, Timestamp x, Calendar cal)
          Sets the designated parameter to the given java.sql.Timestamp value, using the given Calendar object.
 DbPreparedStatement setTimestamp(String parameterName, Timestamp x)
          Sets the named parameters to the given java.sql.Timestamp value.
 DbPreparedStatement setTimestamp(String parameterName, Timestamp x, Calendar cal)
          Sets the named parameters to the given java.sql.Timestamp value, using the given Calendar object.
 DbPreparedStatement setTimestamps(int[] parameterIndices, Timestamp x)
          Sets the designated parameters to the given java.sql.Timestamp value.
 DbPreparedStatement setTimestamps(int[] parameterIndices, Timestamp x, Calendar cal)
          Sets the designated parameters to the given java.sql.Timestamp value, using the given Calendar object.
 DbPreparedStatement setURL(int parameterIndex, URL x)
          Sets the designated parameter to the given java.net.URL value.
 DbPreparedStatement setURL(String parameterName, URL x)
          Sets the named parameters to the given java.net.URL value.
 DbPreparedStatement setURLs(int[] parameterIndices, URL x)
          Sets the designated parameters to the given java.net.URL value.
 void setVirtualParameters(VirtualParameters parameters)
          Sets the parameters that should be handled as virtual parameters.
 
Methods inherited from class com.uwyn.rife.database.DbStatement
addBatch, cancel, clearBatch, clearWarnings, clone, execute, execute, execute, execute, executeBatch, executeQuery, executeQuery, executeUpdate, executeUpdate, finalize, 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
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSql

public String getSql()
Returns the SQL query that will be executed by this prepared statement.

Returns:
a String with the SQL query of this prepared statement
Since:
1.0

getQuery

public Query getQuery()
Returns the query builder that provides the SQL query that will be executed by this prepared statement.

Returns:
a Query object with the query builder instance; or

null if the prepared statement was initialized from a string SQL query

Since:
1.0

executeQuery

public void executeQuery()
                  throws DatabaseException
Executes the SQL query in this DbPreparedStatement object. The ResultSet object generated by the query is stored and can be retrieved with the getResultSet method.

If an exception is thrown, this DbPreparedStatement is 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 a ResultSet object
Since:
1.0
See Also:
DbStatement.getResultSet()

executeUpdate

public int executeUpdate()
                  throws DatabaseException
Executes the SQL statement in this DbPreparedStatement object, which must be an SQL INSERT, UPDATE or DELETE statement; or a SQL statement that returns nothing, such as a DDL statement.

If an exception is thrown, this DbPreparedStatement is 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, or DELETE statements; or

0 for SQL statements that return nothing

Throws:
DatabaseException - if a database access error occurs or the SQL statement returns a ResultSet object
Since:
1.0

addBatch

public void addBatch()
              throws DatabaseException
Adds a set of parameters to this DbPreparedStatement object's batch of commands.

If an exception is thrown, this DbPreparedStatement is 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:
DbStatement.addBatch(java.lang.String)

close

public void close()
           throws DatabaseException
Releases this DbPreparedStatement object'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 close on a DbPreparedStatement object that is already closed has no effect.

Note: A DbPreparedStatement object is automatically closed when it is garbage collected. When a DbPreparedStatement object is closed, its current ResultSet object, if one exists, is also closed.

Overrides:
close in class DbStatement
Throws:
DatabaseException - if a database access error occurs
Since:
1.0

getMetaData

public ResultSetMetaData getMetaData()
                              throws DatabaseException
Retrieves a ResultSetMetaData object that contains information about the columns of the ResultSet object that will be returned when this PDbreparedStatement object is executed.

Because a DbPreparedStatement object is precompiled, it is possible to know about the ResultSet object that it will return without having to execute it. Consequently, it is possible to invoke the method getMetaData on a DbPreparedStatement object rather than waiting to execute it and then invoking the ResultSet.getMetaData method on the ResultSet object that is returned.

If an exception is thrown, this DbPreparedStatement is 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 ResultSet object's columns; or

null if the driver cannot return a ResultSetMetaData object

Throws:
DatabaseException - if a database access error occurs
Since:
1.0

getParameterMetaData

public ParameterMetaData getParameterMetaData()
                                       throws DatabaseException
Retrieves the number, types and properties of this DbPreparedStatement object's parameters.

If an exception is thrown, this DbPreparedStatement is automatically closed and an ongoing transaction will be automatically rolled back if it belongs to the executing thread.

Returns:
a ParameterMetaData object that contains information about the number, types and properties of this DbPreparedStatement object's parameters.
Throws:
DatabaseException - if a database access error occurs
Since:
1.0
See Also:
ParameterMetaData

getVirtualParameterValue

public Object getVirtualParameterValue(String name)
                                throws UndefinedVirtualParameterException
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 value
UndefinedVirtualParameterException
Since:
1.0

getVirtualParameterValue

public Object getVirtualParameterValue(int parameterIndex)
                                throws DatabaseException
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

public DbPreparedStatement setBean(Object bean)
                            throws DatabaseException
Automatically retrieves all the values of a bean's properties and sets them for the parameters that have been defined by the ParametrizedQuery object of this DbPrepareStatement instance.

Parameters:
bean - the bean whose properties should be assigned to the query's parameters.
Returns:
this DbPreparedStatement instance.
Throws:
DatabaseException - when this DbPrepareStatement instance wasn't defined by a ParametrizedQuery but by a regular sql string, or if the ParametrizedQuery doesn't contain any parameters, or if an error occurred during the manipulation of the bean's properties.
Since:
1.0

setVirtualParameters

public void setVirtualParameters(VirtualParameters parameters)
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 this DbPreparedStatement instance for retrieval by other functionalities like capabilities.

Parameters:
parameters - the VirtualParameters instance that will determine the virtual parameters
Since:
1.0

getParameterIndices

public int[] getParameterIndices(String parameterName)
                          throws DatabaseException
Retrieves all the parameter indices that correspond to the name of a parameter of the ParametrizedQuery object that is used by this DbPreparedStatement instance.

Parameters:
parameterName - the name of the parameter that should be looked up
Returns:
an int array with all the corresponding indices
Throws:
DatabaseException - when this DbPrepareStatement instance wasn't defined by a ParametrizedQuery but by a regular sql string, or if the ParametrizedQuery doesn't contain any parameters, or if no parameters with this name could be found.
Since:
1.0

setDouble

public DbPreparedStatement setDouble(String parameterName,
                                     double x)
                              throws DatabaseException
Sets the named parameters to the given Java double value. The driver converts this to a SQL DOUBLE value when it sends it to the database.

If a database access error occurs, this DbPreparedStatement instance is automatically closed.

Parameters:
parameterName - the name of the parameters that have to be set
x - the parameter value
Returns:
this DbPreparedStatement instance.
Throws:
DatabaseException - when this DbPrepareStatement instance wasn't defined by a ParametrizedQuery but by a regular sql string, or if the ParametrizedQuery doesn'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(int[], double), setDouble(int, double)

setDoubles

public DbPreparedStatement setDoubles(int[] parameterIndices,
                                      double x)
                               throws DatabaseException
Sets the designated parameters to the given Java double value. The driver converts this to a SQL DOUBLE value when it sends it to the database.

If an exception is thrown, this DbPreparedStatement is 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 DbPreparedStatement instance.
Throws:
DatabaseException - if a database access error occurs
Since:
1.0
See Also:
setDouble(String, double), setDouble(int, double)

setDouble

public DbPreparedStatement setDouble(int parameterIndex,
                                     double x)
                              throws DatabaseException
Sets the designated parameter to the given Java double value. The driver converts this to a SQL DOUBLE value when it sends it to the database.

If an exception is thrown, this DbPreparedStatement is 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 DbPreparedStatement instance.
Throws:
DatabaseException - if a database access error occurs
Since:
1.0
See Also:
setDouble(String, double), setDoubles(int[], double)

setShort

public DbPreparedStatement setShort(String parameterName,
                                    short x)
                             throws DatabaseException
Sets the named parameters to the given Java short value. The driver converts this to a SQL SMALLINT value when it sends it to the database.

If a database access error occurs, this DbPreparedStatement instance is automatically closed.

Parameters:
parameterName - the name of the parameters that have to be set
x - the parameter value
Returns:
this DbPreparedStatement instance.
Throws:
DatabaseException - when this DbPrepareStatement instance wasn't defined by a ParametrizedQuery but by a regular sql string, or if the ParametrizedQuery doesn'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(int[], short), setShort(int, short)

setShorts

public DbPreparedStatement setShorts(int[] parameterIndices,
                                     short x)
                              throws DatabaseException
Sets the designated parameters to the given Java short value. The driver converts this to a SQL SMALLINT value when it sends it to the database.

If an exception is thrown, this DbPreparedStatement is 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 DbPreparedStatement instance.
Throws:
DatabaseException - if a database access error occurs
Since:
1.0
See Also:
setShort(String, short), setShort(int, short)

setShort

public DbPreparedStatement setShort(int parameterIndex,
                                    short x)
                             throws DatabaseException
Sets the designated parameter to the given Java short value. The driver converts this to a SQL SMALLINT value when it sends it to the database.

If an exception is thrown, this DbPreparedStatement is 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 DbPreparedStatement instance.
Throws:
DatabaseException - if a database access error occurs
Since:
1.0
See Also:
setShort(String, short), setShorts(int[], short)

setNull

public DbPreparedStatement setNull(String parameterName,
                                   int sqlType)
                            throws DatabaseException
Sets the named parameters to SQL NULL.

If a database access error occurs, this DbPreparedStatement instance is automatically closed.

Note: You must specify the parameter's SQL type.

Parameters:
parameterName - the name of the parameters that have to be set
sqlType - the SQL type code defined in java.sql.Types
Returns:
this DbPreparedStatement instance.
Throws:
DatabaseException - when this DbPrepareStatement instance wasn't defined by a ParametrizedQuery but by a regular sql string, or if the ParametrizedQuery doesn'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:
Types, setNulls(int[], int), setNull(int, int)

setNulls

public DbPreparedStatement setNulls(int[] parameterIndices,
                                    int sqlType)
                             throws DatabaseException
Sets the designated parameters to SQL NULL.

If an exception is thrown, this DbPreparedStatement is 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 in java.sql.Types
Returns:
this DbPreparedStatement instance.
Throws:
DatabaseException - if a database access error occurs
Since:
1.0
See Also:
Types, setNull(String, int), setNull(int, int)

setNull

public DbPreparedStatement setNull(int parameterIndex,
                                   int sqlType)
                            throws DatabaseException
Sets the designated parameter to SQL NULL.

If an exception is thrown, this DbPreparedStatement is 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 in java.sql.Types
Returns:
this DbPreparedStatement instance.
Throws:
DatabaseException - if a database access error occurs
Since:
1.0
See Also:
Types, setNull(String, int), setNulls(int[], int)

setNull

public DbPreparedStatement setNull(String parameterName,
                                   int sqlType,
                                   String typeName)
                            throws DatabaseException
Sets the named parameters to SQL NULL. This version of the method setNull should 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 DbPreparedStatement instance is automatically closed.

Parameters:
parameterName - the name of the parameters that have to be set
sqlType - a value from java.sql.Types
typeName - the fully-qualified name of an SQL user-defined type; ignored if the parameter is not a user-defined type or REF
Returns:
this DbPreparedStatement instance.
Throws:
DatabaseException - when this DbPrepareStatement instance wasn't defined by a ParametrizedQuery but by a regular sql string, or if the ParametrizedQuery doesn'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:
Types, setNulls(int[], int, String), setNull(int, int, String)

setNulls

public DbPreparedStatement setNulls(int[] parameterIndices,
                                    int sqlType,
                                    String typeName)
                             throws DatabaseException
Sets the designated parameters to SQL NULL. This version of the method setNull should 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 DbPreparedStatement is 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 from java.sql.Types
typeName - the fully-qualified name of an SQL user-defined type; ignored if the parameter is not a user-defined type or REF
Returns:
this DbPreparedStatement instance.
Throws:
DatabaseException - if a database access error occurs
Since:
1.0
See Also:
Types, setNull(String, int, String), setNull(int, int, String)

setNull

public DbPreparedStatement setNull(int parameterIndex,
                                   int sqlType,
                                   String typeName)
                            throws DatabaseException
Sets the designated parameter to SQL NULL. This version of the method setNull should 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 DbPreparedStatement is 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 from java.sql.Types
typeName - the fully-qualified name of an SQL user-defined type; ignored if the parameter is not a user-defined type or REF
Returns:
this DbPreparedStatement instance.
Throws:
DatabaseException - if a database access error occurs
Since:
1.0
See Also:
Types, setNull(String, int, String), setNulls(int[], int, String)

setBoolean

public DbPreparedStatement setBoolean(String parameterName,
                                      boolean x)
                               throws DatabaseException
Sets the named parameters to the given Java boolean value. The driver converts this to a SQL BIT value when it sends it to the database.

If a database access error occurs, this DbPreparedStatement instance is automatically closed.

Parameters:
parameterName - the name of the parameters that have to be set
x - the parameter value
Returns:
this DbPreparedStatement instance.
Throws:
DatabaseException - when this DbPrepareStatement instance wasn't defined by a ParametrizedQuery but by a regular sql string, or if the ParametrizedQuery doesn'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:
setBoolean(String, boolean), setBooleans(int[], boolean)

setBooleans

public DbPreparedStatement setBooleans(int[] parameterIndices,
                                       boolean x)
                                throws DatabaseException
Sets the designated parameters to the given Java boolean value. The driver converts this to a SQL BIT value when it sends it to the database.

If an exception is thrown, this DbPreparedStatement is 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 DbPreparedStatement instance.
Throws:
DatabaseException - if a database access error occurs
Since:
1.0
See Also: