Nonstop Database, HiRDB Version 9 UAP Development Guide
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.
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. |
public synchronized void addBatch() throws SQLException
public synchronized void clearParameters() throws SQLException
public synchronized boolean execute() throws SQLException
public synchronized boolean execute(String sql) throws SQLException
public synchronized ResultSet executeQuery() throws SQLException
public synchronized ResultSet executeQuery(String sql) throws SQLException
public synchronized int executeUpdate() throws SQLException
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 |
public synchronized int executeUpdate(String sql) throws SQLException
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 |
public void setArray(int i,Array x) throws SQLException
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 |
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 |
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 |
public synchronized void setAsciiStream(int parameterIndex, java.io.InputStream x, int length) throws SQLException
public synchronized void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException
public synchronized void setBinaryStream(int parameterIndex, java.io.InputStream x, int length) throws SQLException
public synchronized void setBlob(int parameterIndex, Blob x) throws SQLException
public synchronized void setBoolean(int parameterIndex, boolean x) throws SQLException
public synchronized void setByte(int parameterIndex, byte x) throws SQLException
public synchronized void setBytes(int parameterIndex, byte x[]) throws SQLException
public synchronized void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException
public synchronized void setDate(int parameterIndex, java.sql.Date x) throws SQLException
public synchronized void setDate(int parameterIndex, java.sql.Date x,Calendar cal) throws SQLException
public synchronized void setDouble(int parameterIndex, double x) throws SQLException
public synchronized void setFloat(int parameterIndex, float x) throws SQLException
public synchronized void setInt(int parameterIndex, int x) throws SQLException
public synchronized void setLong(int parameterIndex, long x) throws SQLException
public synchronized void setNull(int parameterIndex,int sqlType) throws SQLException
public synchronized void setObject(int parameterIndex, Object x) throws SQLException
public synchronized void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException
public synchronized void setObject(int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException
public synchronized void setShort(int parameterIndex, short x) throws SQLException
public synchronized void setString(int parameterIndex, String x) throws SQLException
Data type of ? parameter | Value of ? parameter |
---|---|
[M|N][VAR]CHAR |
|
BINARY or BLOB | Character string with a length of 0 |
Other | null |
public synchronized void setTime(int parameterIndex, java.sql.Time x) throws SQLException
public synchronized void setTime(int parameterIndex, java.sql.Time x,Calendar cal) throws SQLException
public synchronized void setTimestamp(int parameterIndex, java.sql.Timestamp x) throws SQLException
public synchronized void setTimestamp(int parameterIndex, java.sql.Timestamp x,Calendar cal) throws SQLException
The names of the package and class for installing this interface are as follows:
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.
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.
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 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.
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.
The objects that can be specified for the x argument of setObject are objects of the following types:
All Rights Reserved. Copyright (C) 2011, Hitachi, Ltd.