Nonstop Database, HiRDB Version 9 UAP Development Guide

[Contents][Index][Back][Next]

18.4.4 PreparedStatement interface

Organization of this subsection
(1) Overview
(2) Methods
(3) Package and class names
(4) Notes

(1) Overview

The PreparedStatement interface provides the following principal functions:

Because the PreparedStatement interface is a subinterface of the Statement interface, it inherits all of the Statement interface functions.

(2) Methods

The table below lists the methods of the PreparedStatement interface. This interface does not support methods that are not listed in the table. If an unsupported method is specified, the interface throws an SQLException.

Table 18-24 PreparedStatement interface methods

Subsection Method Function
(a) addBatch() Adds the current parameter set to this PreparedStatement object's batch.
(b) clearParameters() Clears all values from the current parameter set that is specified.
(c) execute() Executes the preprocessed SQL statement.
(d) execute(String sql) Executes a specified SQL statement.
(e) executeQuery() Executes the preprocessed retrieval SQL statement and returns the resulting ResultSet object.
(f) executeQuery(String sql) Executes a specified retrieval SQL statement and returns a ResultSet object as the result.
(g) executeUpdate() Executes the preprocessed non-retrieval SQL statement and returns the number of updated rows.
(h) executeUpdate(String sql) Executes a specified non-retrieval SQL statement and returns the number of updated rows.
(i) setArray(int i, Array x) Sets an Array object in a specified parameter.
(j) setAsciiStream(int parameterIndex, java.io.InputStream x, int length) Sets the value of a specified InputStream object as a ? parameter value.
(k) setBigDecimal(int parameterIndex,BigDecimal x) Sets a specified BigDecimal object as a ? parameter value.
(l) setBinaryStream(int parameterIndex, java.io.InputStream x, int length) Sets the value of a specified InputStream object as a ? parameter value.
(m) setBlob(int parameterIndex, Blob x) Sets the value of a specified Blob object as a ? parameter value.
(n) setBoolean(int parameterIndex,boolean x) Sets a specified boolean value as a ? parameter value.
(o) setByte(int parameterIndex,byte x) Sets a specified byte value as a ? parameter value.
(p) setBytes(int parameterIndex,byte x[]) Sets a specified byte array as a ? parameter value.
(q) setCharacterStream(int parameterIndex,Reader reader,int length) Sets the value of a specified Reader object as a ? parameter value.
(r) setDate(int parameterIndex, java.sql.Date x) Sets a specified java.sql.Date object as a ? parameter value.
(s) setDate(int parameterIndex, java.sql.Date x,Calendar cal) Converts a java.sql.Date object specified in local time to the equivalent value in a specified calendar's time zone, and then sets the resulting value as a ? parameter value.
(t) setDouble(int parameterIndex,double x) Sets a specified double value as a ? parameter value.
(u) setFloat(int parameterIndex,float x) Sets a specified float value as a ? parameter value.
(v) setInt(int parameterIndex,int x) Sets a specified int value as a ? parameter value.
(w) setLong(int parameterIndex,long x) Sets a specified long value as a ? parameter value.
(x) setNull(int parameterIndex,int sqlType) Sets the NULL value in a specified ? parameter.
(y) setObject(int parameterIndex,Object x) Sets the value of a specified object as a ? parameter value.
(z) setObject(int parameterIndex,Object x,int targetSqlType) Sets the value of a specified object as a ? parameter value.
(aa) setObject(int parameterIndex,Object x,int targetSqlType,int scale) Sets the value of a specified object as a ? parameter value.
(ab) setShort(int parameterIndex,short x) Sets a specified short value as a ? parameter value.
(ac) setString(int parameterIndex,String x) Sets a specified String object as a ? parameter value.
(ad) setTime(int parameterIndex, java.sql.Time x) Sets a specified java.sql.Time object as a ? parameter value.
(ae) setTime(int parameterIndex, java.sql.Time x,Calendar cal) Converts a java.sql.Time object specified in local time to the equivalent value in a specified calendar's time zone, and then sets the resulting value as a ? parameter value.
(af) setTimestamp(int parameterIndex, java.sql.Timestamp x) Sets a specified java.sql.Timestamp object as a ? parameter value.
(ag) setTimestamp(int parameterIndex, java.sql.Timestamp x,Calendar cal) Converts a java.sql.Timestamp object specified in local time to the equivalent value in a specified calendar's time zone, and then sets the resulting value as a ? parameter value.
(a) addBatch()

Function
Adds the current parameter set to the this PreparedStatement object's batch.
You can register a maximum of 2,147,483,647 parameter sets.

Format
 
public synchronized void addBatch() throws SQLException
 

Arguments
None.

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued for the Connection object that created this PreparedStatement object.
  • No value is set for some ? parameters.
  • More than 2,147,483,647 items have been registered in the batch.
(b) clearParameters()

Function
Clears all values from the current parameter set that is specified.

Format
 
public synchronized void clearParameters() throws SQLException
 

Arguments
None.

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued for the Connection object that created this PreparedStatement object.
(c) execute()

Function
Executes the preprocessed SQL statement.
You can use PreparedStatement.getResultSet and PreparedStatement.getUpdateCount to obtain the ResultSet object and the number of updated rows as execution results.

Format
 
public synchronized boolean execute() throws SQLException
 

Arguments
None.

Return value
If a retrieval SQL statement was executed, this method returns true; if not, the method returns false.

Functional detail
This method executes the preprocessed SQL statement.
You can use PreparedStatement.getResultSet and PreparedStatement.getUpdateCount to obtain the ResultSet object and the number of updated rows. For the return values of Statement.getResultSet and Statement.getUpdateCount after method execution, see 18.4.3(2)(f) execute(String sql).

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued for the Connection object that created this PreparedStatement object.
  • No value is set in at least one ? parameter.
  • A database access error occurred.
(d) execute(String sql)

Function
Executes a specified SQL statement. You can use PreparedStatement.getResultSet and PreparedStatement.getUpdateCount to obtain the ResultSet object and the number of updated rows.

Format
 
public synchronized boolean execute(String sql) throws SQLException
 

Arguments
String sql
SQL statement to be executed

Return value
If a retrieval SQL statement was executed, this method returns true; if not, the method returns false.

Functional detail
This method executes the specified SQL statement. You can use PreparedStatement.getResultSet and PreparedStatement.getUpdateCount to obtain the ResultSet object and the number of updated rows.
For the return values of PreparedStatement.getResultSet and PreparedStatement.getUpdateCount after execution of this method, see Table 18-18 Relationship between the executed SQL statement and the return values of Statement.getResultSet and Statement.getUpdateCount.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued for the Connection object that created this PreparedStatement object.
  • null or a character string with a length of 0 was specified in the sql argument.
  • A database access error occurred.
(e) executeQuery()

Function
Executes the preprocessed retrieval SQL statement and returns the resulting ResultSet object.

Format
 
public synchronized ResultSet executeQuery() throws SQLException
 

Arguments
None.

Return value
ResultSet object for the execution result

Functional detail
  • When TRUE is not specified for the HiRDB_for_Java_DAB_EXECUTESQL_NOCHK system property
    This method executes the preprocessed retrieval SQL statement and returns the resulting ResultSet object. If a non-retrieval SQL statement is executed, the JDBC driver throws an SQLException.
  • When TRUE is specified for the HiRDB_for_Java_DAB_EXECUTESQL_NOCHK system property
    This method executes the preprocessed SQL statement and returns the resulting ResultSet object. If a non-retrieval SQL statement is executed, the method returns a ResultSet object containing no columns.
    You can use the Statement.getUpdateCount method to acquire the number of updated rows.
    For the return values of the executeQuery method and the Statement.getUpdateCount method that is executed after the executeQuery method, see 18.4.3(2)(h) executeQuery(String sql).

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued for the Connection object that created this PreparedStatement object.
  • A non-retrieval SQL statement was specified (other than when TRUE is specified for the HiRDB_for_Java_DAB_EXECUTESQL_NOCHK system property).
  • No value is set in at least one ? parameter.
  • A database access error occurred.
(f) executeQuery(String sql)

Function
Executes a specified retrieval SQL statement and returns a ResultSet object as the result.

Format
 
public synchronized ResultSet executeQuery(String sql) throws SQLException
 

Arguments
String sql
SQL statement to be executed

Return value
ResultSet object for the execution result

Functional detail
  • When TRUE is not specified for the HiRDB_for_Java_DAB_EXECUTESQL_NOCHK system property
    This method executes a specified non-retrieval SQL statement and returns the number of updated rows. For an SQL statement that has no retrieval results (such as an INSERT statement), the JDBC driver throws an SQLException.
  • When TRUE is specified for the HiRDB_for_Java_DAB_EXECUTESQL_NOCHK system property
    The method executes a specified SQL statement and returns the resulting ResultSet object. If a non-retrieval SQL statement is executed, the method returns a ResultSet object containing no columns. You can use the Statement.getUpdateCount method to acquire the number of updated rows.
    For the return values of the executeQuery method and the Statement.getUpdateCount method that is executed after the executeQuery method, see 18.4.3(2)(h) executeQuery(String sql).

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued for the Connection object that created this PreparedStatement object.
  • A non-retrieval SQL statement was specified (other than when TRUE is specified for the HiRDB_for_Java_DAB_EXECUTESQL_NOCHK system property).
  • null or a character string with a length of 0 was specified in the sql argument.
  • A database access error occurred.
(g) executeUpdate()

Function
Executes the preprocessed non-retrieval SQL statement and returns the number of updated rows.

Format
 
public synchronized int executeUpdate() throws SQLException
 

Arguments
None.

Return value
The following table shows the return values:
Executed SQL statement type HiRDB_for_Java_DAB_EXECUTESQL_NOCHK system property setting
Other than TRUE TRUE
Retrieval SQL statement -- -1
Non-retrieval SQL statement INSERT, UPDATE, DELETE Number of updated rows Number of updated rows
Other 0 0

Functional detail
  • When TRUE is not specified for the HiRDB_for_Java_DAB_EXECUTESQL_NOCHK system property
    This method executes the preprocessed non-retrieval SQL statement and returns the number of updated rows.
    If a retrieval SQL statement is executed, the JDBC driver throws an SQLException.
  • When TRUE is specified for the HiRDB_for_Java_DAB_EXECUTESQL_NOCHK system property
    The method executes the preprocessed SQL statement.
    If the return value is -1, you can use the Statement.getResultSet method to acquire the ResultSet object. For the return value of the Statement.getResultSet method that is executed after the executeUpdate method was executed, see 18.4.3(2)(i) executeUpdate(String sql).

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has been issued for the object.
  • close() has already been issued for the Connection object that created this object.
  • A retrieval SQL statement was executed (other than when TRUE is specified for the HiRDB_for_Java_DAB_EXECUTESQL_NOCHK system property).
  • No value is set in at least one ? parameter.
  • A database access error occurred.
(h) executeUpdate(String sql)

Function
Executes a specified non-retrieval SQL statement and returns the number of updated rows.

Format
 
public synchronized int executeUpdate(String sql) throws SQLException
 

Arguments
String sql
SQL statement to be executed

Return value
The following table shows the return values:
Executed SQL statement type HiRDB_for_Java_DAB_EXECUTESQL_NOCHK system property setting
Other than TRUE TRUE
Retrieval SQL statement -- -1
Non-retrieval SQL statement INSERT, UPDATE, DELETE Number of updated rows Number of updated rows
Other 0 0

Functional detail
  • When TRUE is not specified for the HiRDB_for_Java_DAB_EXECUTESQL_NOCHK system property
    This method executes a specified non-retrieval SQL statement and returns the number of updated rows.
    For an SQL statement that returns retrieval results (such as a SELECT statement), the JDBC driver throws an SQLException.
  • When TRUE is specified for the HiRDB_for_Java_DAB_EXECUTESQL_NOCHK system property
    The method executes a specified SQL statement.
    If the return value is -1, you can use the Statement.getResultSet method to acquire the ResultSet object. For the return value of the Statement.getResultSet method that is executed after the executeUpdate method was executed, see 18.4.3(2)(i) executeUpdate(String sql).

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued for the Connection object that created this PreparedStatement object.
  • A retrieval SQL statement was specified (other than when TRUE is specified for the HiRDB_for_Java_DAB_EXECUTESQL_NOCHK system property).
  • null or a character string with a length of 0 was specified in the sql argument.
  • A database access error occurred.
(i) setArray(int i,Array x)

Function
Sets an Array object in a specified parameter.

Format
 
public void setArray(int i,Array x) throws SQLException
 

Arguments
int i
? parameter number, such as 1 for the first parameter, 2 for the second parameter, etc.
Array x
Array object that is to be set in the ? parameter.

Return value
None.

Functional detail
This method sets an Array object in the parameter with a specified parameter number.
If the data type of the Object array acquired by the Array object's getArray() does not correspond to the data type acquired by the Array object's getBaseType(), an SQLException occurs.
The following table shows the correspondence between the data type of the Object array acquired by the Array object's getArray() and the data type acquired by the Array object's getBaseType():
Data type acquired by getBaseType() Data type of Object array acquired by getArray()
java.sql.Types.SMALLINT short[],java.lang.Short[]
java.sql.Types.INTEGER int[],java.lang.Integer[]
java.sql.Types.REAL float[],java.lang.Float[]
java.sql.Types.FLOAT double[],java.lang.Double[]
java.sql.Types.Decimal java.math.BigDecimal[]
java.sql.Types.CHAR java.lang.String[]
java.sql.Types.VARCHAR java.lang.String[]
java.sql.Types.DATE java.sql.Date
java.sql.Types.TIME java.sql.Time
java.sql.Types.TIMESTAMP java.sql.Timestamp
The following table shows the relationships among the i and x arguments and their values:
Argument i Argument x Number of elements in Object array acquired by getArray() Each element of Object array Element of repetition column set in HiRDB
Number of an existing ? parameter !=null 0 < number of elements [Figure] 30000 All elements are null Repetition column whose elements are all null
Other than the above Repetition column other than the above
Number of elements > 30000 -- SQLException
0 -- Repetition column that contain no element
null -- -- Entire column is null
Number of an existing ? parameter that is not a repetition column -- -- -- SQLException
Number of a nonexistent ? parameter SQLException

Legend:
-- Not applicable

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified for the i argument.
  • The column for the parameter number specified in the i argument is not an HiRDB repetition column.
  • The data type of the Object array acquired from the Array object specified in the x argument cannot be converted to the data type of the column of the ? parameter.
  • The length of the Object array acquired from the Array object specified in the x argument exceeds 30000 (the number of array elements exceeds 30000).
(j) setAsciiStream(int parameterIndex, java.io.InputStream x, int length)

Function
Sets the value of a specified InputStream object as a ? parameter value.

Format
 
public synchronized void setAsciiStream(int parameterIndex, java.io.InputStream x, int length) throws SQLException
 

Arguments
int parameterIndex
? parameter number
java.io.InputStream x
InputStream object that contains the value to be set in the ? parameter
int length
Number of bytes to be set

Return value
None.

Functional detail
This method sets the value of a specified InputStream object as a ? parameter value.
This method does not execute the close() method on x even after input from x has been completed.
If the HiRDB data type of the ? parameter is not [M|N][VAR]CHAR or BINARY or BLOB, the JDBC driver throws an SQLException result.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A value less than 0 was specified for length.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • The specified ? parameter is the OUT parameter.
(k) setBigDecimal(int parameterIndex, BigDecimal x)

Function
Sets a specified BigDecimal object as a ? parameter value.

Format
 
public synchronized void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException
 

Arguments
int parameterIndex
? parameter number
BigDecimal x
BigDecimal object to be set in the ? parameter

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • The specified ? parameter is the OUT parameter.
(l) setBinaryStream(int parameterIndex, java.io.InputStream x, int length)

Function
Sets the value of a specified InputStream object as a ? parameter value.

Format
 
public synchronized void setBinaryStream(int parameterIndex, java.io.InputStream x, int length) throws SQLException
 

Arguments
int parameterIndex
? parameter number
java.io.InputStream x
InputStream object that contains the value to be set in the ? parameter
int length
Number of bytes to be set

Return value
None.

Functional detail
This method sets the value of a specified InputStream object as a ? parameter value.
This method does not execute the close() method on x even after input from x has been completed.
If the HiRDB data type of the ? parameter is not BINARY or BLOB, the JDBC driver throws an SQLException result.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A value less than 0 was specified for length.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • The specified ? parameter is the OUT parameter.
(m) setBlob(int parameterIndex, Blob x)

Function
Sets the value of a specified Blob object as a ? parameter value.

Format
 
public synchronized void setBlob(int parameterIndex, Blob x) throws SQLException
 

Arguments
int parameterIndex
? parameter number
Blob x
Blob object that contains the value to be set in the ? parameter

Return value
None.

Functional detail
This method sets the value of a specified InputStream object as a ? parameter value.
If the HiRDB data type of the ? parameter is not BINARY or BLOB, the JDBC driver throws an SQLException result.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • The specified ? parameter is the OUT parameter.
(n) setBoolean(int parameterIndex, boolean x)

Function
Sets a specified boolean value as a ? parameter value.

Format
 
public synchronized void setBoolean(int parameterIndex, boolean x) throws SQLException
 

Arguments
int parameterIndex
? parameter number
boolean x
Value to be set in the ? parameter

Return value
None.

Functional detail
This method sets a specified boolean value as a ? parameter value.
If the HiRDB data type of the ? parameter specified by parameterIndex is CHAR, MCHAR, NCHAR, VARCHAR, MVARCHAR, or NVARHAR and x is true, then the ? parameter value is true. If the HiRDB data type of the ? parameter specified by parameterIndex is CHAR, MCHAR, NCHAR, VARCHAR, MVARCHAR, or NVARHAR and x is false, then the ? parameter value is false[Figure] ([Figure]: single-byte space).

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified ? parameter is the OUT parameter.
(o) setByte(int parameterIndex, byte x)

Function
Sets a specified byte value as a ? parameter value.

Format
 
public synchronized void setByte(int parameterIndex, byte x) throws SQLException
 

Arguments
int parameterIndex
? parameter number
byte x
Value to be set in the ? parameter

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified ? parameter is the OUT parameter.
(p) setBytes(int parameterIndex, byte x[])

Function
Sets a specified byte array as a ? parameter value.

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

Arguments
int parameterIndex
? parameter number
byte x[]
byte array that contains the values to be set in the ? parameter

Return value
None.

Functional detail
This method provides only referencing without copying the byte array. Therefore, if you change a value in the byte array before executing the executeXXX method, this method will use the new value after the change.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • The HiRDB data type of the ? parameter cannot be set by this method (the data type is not BINARY or BLOB).
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • The specified ? parameter is the OUT parameter.
(q) setCharacterStream(int parameterIndex, Reader reader, int length)

Function
Sets the value of a specified Reader object as a ? parameter value.

Format
 
public synchronized void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException
 

Arguments
int parameterIndex
? parameter number
Reader reader
Reader object that contains the value to be set in the ? parameter
int length
Number of characters

Return value
None.

Functional detail
This method sets the value of a specified Reader object as a ? parameter value.
If the HiRDB data type of the ? parameter is not [M|N][VAR]CHAR or BINARY or BLOB, the JDBC driver throws an SQLException.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A value less than 0 was specified for length.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • Encoding failed.
  • The specified ? parameter is the OUT parameter.
(r) setDate(int parameterIndex, java.sql.Date x)

Function
Sets a specified java.sql.Date object as a ? parameter value.

Format
 
public synchronized void setDate(int parameterIndex, java.sql.Date x) throws SQLException
 

Arguments
int parameterIndex
? parameter number
java.sql.Date x
java.sql.Date object that contains the value to be set in the ? parameter

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • The specified ? parameter is the OUT parameter.
(s) setDate(int parameterIndex, java.sql.Date x,Calendar cal)

Function
Converts a java.sql.Date object specified in local time to the equivalent value in a specified calendar's time zone, and then sets the resulting value as a ? parameter value.

Format
 
public synchronized void setDate(int parameterIndex, java.sql.Date x,Calendar cal) throws SQLException
 

Arguments
int parameterIndex
? parameter number
java.sql.Date x
java.sql.Date object that contains the value to be set in the ? parameter
Calendar cal
Calendar in which the time zone for the value to be stored in the database has been set. If null is specified, the JavaVM default calendar's time zone is assumed.

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • The specified ? parameter is the OUT parameter.
(t) setDouble(int parameterIndex, double x)

Function
Sets a specified double value as a ? parameter value.

Format
 
public synchronized void setDouble(int parameterIndex, double x) throws SQLException
 

Arguments
int parameterIndex
? parameter number
double x
Value to be set in the ? parameter

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • The specified ? parameter is the OUT parameter.
(u) setFloat(int parameterIndex, float x)

Function
Sets a specified float value as a ? parameter value.

Format
 
public synchronized void setFloat(int parameterIndex, float x) throws SQLException
 

Arguments
int parameterIndex
? parameter number
float x
Value to be set in the ? parameter

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • The specified ? parameter is the OUT parameter.
(v) setInt(int parameterIndex, int x)

Function
Sets a specified int value as a ? parameter value.

Format
 
public synchronized void setInt(int parameterIndex, int x) throws SQLException
 

Arguments
int parameterIndex
? parameter number
int x
Value to be set in the ? parameter

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • The specified ? parameter is the OUT parameter.
(w) setLong(int parameterIndex, long x)

Function
Sets a specified long value as a ? parameter value.

Format
 
public synchronized void setLong(int parameterIndex, long x) throws SQLException
 

Arguments
int parameterIndex
? parameter number
long x
Value to be set in the ? parameter

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • The specified ? parameter is the OUT parameter.
(x) setNull(int parameterIndex,int sqlType)

Function
Sets the NULL value in a specified ? parameter.
This driver ignores the sqlType argument.

Format
 
public synchronized void setNull(int parameterIndex,int sqlType) throws SQLException
 

Arguments
int parameterIndex
? parameter number
int sqlType
JDBC's SQL data type

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • The specified ? parameter is the OUT parameter.
(y) setObject(int parameterIndex, Object x)

Function
Sets the value of a specified object as a ? parameter value.

Format
 
public synchronized void setObject(int parameterIndex, Object x) throws SQLException
 

Arguments
int parameterIndex
? parameter number
Object x
Object that contains the value to be set in the ? parameter

Return value
None.

Functional detail
This method sets the value of a specified object as a ? parameter value.
If the type of the ? parameter specified by parameterIndex is HiRDB's CHAR, MCHAR, NCHAR, VARCHAR, MVARCHAR, or NVARHAR, x is a Boolean object, and x is true, then the ? parameter value is true. If the type of the ? parameter specified by parameterIndex is HiRDB's CHAR, MCHAR, NCHAR, VARCHAR, MVARCHAR, or NVARHAR, x is a Boolean object, and x is false, then the ? parameter value is false[Figure] ([Figure]: single-byte space).
If x is a byte array, this method provides only referencing without copying the byte array. Therefore, if you change a value in the byte array before executing the executeXXX method, this method uses the new value after the change.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • The specified ? parameter is the OUT parameter.
(z) setObject(int parameterIndex, Object x, int targetSqlType)

Function
Sets the value of a specified object as a ? parameter value.

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

Arguments
int parameterIndex
? parameter number
Object x
Object that contains the value to be set in the ? parameter
int targetSqlType
JDBC's SQL data type

Return value
None.

Functional detail
This method sets the value of a specified object as a ? parameter value.
If targetSqlType is java.sql.Types.CHAR, java.sql.Types.VARCHAR, or java.sql.Types.LONGVARCHAR, x is a Boolean object, and x is true, then the ? parameter value is 1,0.
If the ? parameter's data type is NCHAR or NVARCHAR (which are HiRDB data types) and its value is 1,0, the JDBC driver throws an SQLException.
If x is a byte array, this method provides only referencing without copying the byte array. Therefore, if you change a value in the byte array before executing the executeXXX method, this method uses the new value after the change.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • targetSqlType is one of the following:
    Types.ARRAY, Types.CLOB, Types.REF, or Types.STRUCT
  • The specified ? parameter is the OUT parameter.
(aa) setObject(int parameterIndex, Object x, int targetSqlType, int scale)

Function
Sets the value of a specified object as a ? parameter value.

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

Arguments
int parameterIndex
? parameter number
Object x
Object that contains the value to be set in the ? parameter
int targetSqlType
JDBC's SQL data type
int scale
Scaling (ignored, if specified)

Return value
None.

Functional detail
This method sets the value of a specified object as a ? parameter value.
If targetSqlType is java.sql.Types.CHAR, java.sql.Types.VARCHAR, or java.sql.Types.LONGVARCHAR, x is a Boolean object, and x is true, then the ? parameter value is 1,0.
If the ? parameter's data type is NCHAR or NVARCHAR type (which are HiRDB data types) and its value is 1,0, the JDBC driver throws an SQLException.
If x is a byte array, this method provides only referencing without copying the byte array. Therefore, if you change a value in the byte array before executing the executeXXX method, this method uses the new value after the change.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • targetSqlType is one of the following:
    Types.ARRAY, Types.CLOB, Types.REF, or Types.STRUCT
  • The specified ? parameter is the OUT parameter.
(ab) setShort(int parameterIndex, short x)

Function
Sets a specified short value as a ? parameter value.

Format
 
public synchronized void setShort(int parameterIndex, short x) throws SQLException
 

Arguments
int parameterIndex
? parameter number
short x
Value to be set in the ? parameter

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified ? parameter is the OUT parameter.
(ac) setString(int parameterIndex, String x)

Function
Sets a specified String object as a ? parameter value.

Format
 
public synchronized void setString(int parameterIndex, String x) throws SQLException
 

Arguments
int parameterIndex
? parameter number
String x
String object that contains the value to be set in the ? parameter

Return value
None.

Functional detail
This method sets in a ? parameter the String object specified in the x argument.
The following table shows the value of the ? parameter when the corresponding instance is CallableStatement and the x argument value is a character string with a length of 0:
Data type of ? parameter Value of ? parameter
[M|N][VAR]CHAR
  • When the HiRDB_for_Java_DAB_CONVERT_NULL system property is set to TRUE
    null
  • Otherwise
    Character string with a length of 0
BINARY or BLOB Character string with a length of 0
Other null

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • CLOSE() has already been issued to the CONNECTION object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • Encoding failed.
  • The specified ? parameter is the OUT parameter.
(ad) setTime(int parameterIndex, java.sql.Time x)

Function
Sets a specified java.sql.Time object as a ? parameter value.

Format
 
public synchronized void setTime(int parameterIndex, java.sql.Time x) throws SQLException
 

Arguments
int parameterIndex
? parameter number
java.sql.Time x
java.sql.Time object that contains the value to be set in the ? parameter

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified ? parameter is the OUT parameter.
(ae) setTime(int parameterIndex, java.sql.Time x,Calendar cal)

Function
Converts a java.sql.Time object specified in local time to the equivalent value in a specified calendar's time zone, and then sets the resulting value as a ? parameter value.

Format
 
public synchronized void setTime(int parameterIndex, java.sql.Time x,Calendar cal) throws SQLException
 

Arguments
int parameterIndex
? parameter number
java.sql.Time x
java.sql.Time object that contains the value to be set in the ? parameter
Calendar cal
Calendar in which the time zone for the value to be stored in the database has been set. If null is specified, the JavaVM default calendar's time zone is assumed.

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified ? parameter is the OUT parameter.
(af) setTimestamp(int parameterIndex, java.sql.Timestamp x)

Function
Sets a specified java.sql.Timestamp object as a ? parameter value.

Format
 
public synchronized void setTimestamp(int parameterIndex, java.sql.Timestamp x) throws SQLException
 

Arguments
int parameterIndex
? parameter number
java.sql.Timestamp x
java.sql.Timestamp object that contains the value to be set in the ? parameter

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • The specified ? parameter is the OUT parameter.
(ag) setTimestamp(int parameterIndex, java.sql.Timestamp x,Calendar cal)

Function
Converts a java.sql.Timestamp object specified in local time to the equivalent value in a specified calendar's time zone, and then sets the resulting value as a ? parameter value.

Format
 
public synchronized void setTimestamp(int parameterIndex, java.sql.Timestamp x,Calendar cal) throws SQLException
 

Arguments
int parameterIndex
? parameter number
java.sql.Timestamp x
java.sql.Timestamp object that contains the value to be set in the ? parameter
Calendar cal
Calendar in which the time zone for the value to be stored in the database has been set. If null is specified, the JavaVM default calendar's time zone is assumed.

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the PreparedStatement object.
  • close() has already been issued to the Connection object that created this PreparedStatement object.
  • A nonexistent ? parameter number was specified.
  • This method does not support the HiRDB data type specified in the ? parameter.
  • The specified value is outside the range of data types for the column or in a format that cannot be converted.
  • The specified ? parameter is the OUT parameter.

(3) Package and class names

The names of the package and class for installing this interface are as follows:

Package name: JP.co.Hitachi.soft.HiRDB.JDBC

Class name: PrdbPreparedStatement

(4) Notes

Because the PreparedStatement interface is a subinterface of the Statement interface, all notes for the Statement interface also apply to the PreparedStatement interface.

This section describes additional notes that apply to the PreparedStatement interface.

(a) ? parameter setup
(b) Retaining SQL preprocessing results beyond commit or rollback processing

For details about retaining SQL preprocessing results beyond commit or rollback processing, see 18.2.2(1)(c) Notes about specification of HIRDB_CURSOR and STATEMENT_COMMIT_BEHAVIOR.

(c) Specification values for ? parameters of HiRDB's DECIMAL type

Described below are operations that are executed when a setXXX method is used to specify a value for a ? parameter of HiRDB's DECIMAL type, and when the precision and decimal scaling position of the ? parameter do not match those of the specification value.

When the precision of the specification value is greater than the actual precision: the HiRDB driver throws an SQLException.

When the precision of the specification value is smaller than the actual precision: the HiRDB driver expands the precision of the specification value.

When the decimal scaling position of the specification value is greater than the actual decimal scaling position: the HiRDB driver truncates the actual decimal scaling position.

When the decimal scaling position of the specification value is smaller than the actual decimal scaling position: the HiRDB driver expands the decimal scaling position by adding zeros.
(d) Specification values for ? parameters of HiRDB's TIMESTAMP type

When a setXXX method is used to specify a value for a ? parameter of HiRDB's TIMESTAMP type, and the fraction-of-a-second precision of the value is greater than the fraction-of-a-second precision of the ? parameter, the JDBC driver truncates the fraction-of-a-second precision to match that of the ? parameter.

(e) Specification values for ? parameters of HiRDB's CHAR, VARCHAR, NCHAR, NVARCHAR, MCHAR, or MVARCHAR type

When a setXXX method is used to specify a value for a ? parameter of HiRDB's CHAR, VARCHAR, NCHAR, NVARCHAR, MCHAR, or MVARCHAR type, and when the length of the value after conversion to a character string expression is greater that the defined length of the ? parameter, the JDBC driver throws an SQLException.

(f) Objects that can be specified with setObject

The objects that can be specified for the x argument of setObject are objects of the following types: