Nonstop Database, HiRDB Version 9 UAP Development Guide

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

18.4.3 Statement interface

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

(1) Overview

The Statement interface provides the following principal functions:

(2) Methods

The table below lists the methods of the Statement 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-17 Statement interface methods

Subsection Method Function
(a) addBatch(String sql) Adds specified SQL statements to this Statement object's batch.
(b) cancel() Cancels the SQL statements executing in the corresponding object and in objects using the same connection as the corresponding object.
(c) clearBatch() Clears all SQL statements registered in this Statement object's batch.
(d) clearWarnings() Clears all warnings that have been reported for this Statement object.
(e) close() Closes the Statement object and any ResultSet object created from this Statement object.
(f) execute(String sql) Executes a specified SQL statement.
(g) executeBatch() Executes the SQL statements registered in a batch and returns an array of the numbers of updated rows.
(h) executeQuery(String sql) Executes a specified retrieval SQL statement and returns a ResultSet object as the result.
(i) executeUpdate(String sql) Executes a specified non-retrieval SQL statement and returns the number of updated rows.
(j) getConnection() Returns the Connection object that created this Statement object.
(k) getFetchDirection() Acquires the default fetch direction for a result set that is created from this Statement object.
(l) getFetchSize() Acquires the default fetch size for a ResultSet object that is created from this Statement object.
(m) getMaxFieldSize() Acquires the maximum number of bytes for the character columns or binary columns of a ResultSet object that is created by this Statement object.
(n) getMaxRows() Acquires the maximum number of rows that can be stored in a ResultSet object created by this Statement object.
(o) getMoreResults() Moves to the next result set.
(p) getQueryTimeout() Returns the SQL execution timeout value (in seconds).
(q) getResultSet() Acquires the current results as a ResultSet object.
(r) getResultSetConcurrency() Acquires the parallel processing mode for a ResultSet object that is created from this Statement object.
(s) getResultSetHoldability() Acquires the holding facility for a ResultSet object that is created from this Statement object.
(t) getResultSetType() Acquires the type of the result set of a ResultSet object that is created from this Statement object.
(u) getUpdateCount() Returns the number of updated rows.
(v) getWarnings() Acquires the first warning that is reported by a call related to this Statement object.
(w) setCursorName(String name) This method ignores the specified value because the driver does not support positioned updating or deletion processing.
(x) setEscapeProcessing(boolean enable) Enables or disables escape syntax analysis by this Statement object.
(y) setFetchDirection(int direction) Specifies the default fetch direction for a result set that is created from this Statement object.
(z) setFetchSize(int rows) Specifies the default fetch size for a ResultSet object that is created from this Statement object.
(aa) setMaxFieldSize(int max) Sets a maximum number of bytes for each character column or binary column in a ResultSet object that is created from this Statement object.
(ab) setMaxRows(int max) Specifies the maximum number of rows that can be stored in a ResultSet object that is created from this Statement object.
(ac) setQueryTimeout(int seconds) Specifies an SQL execution timeout value (in seconds).
(a) addBatch(String sql)

Function
Adds specified SQL statements to this Statement object's batch.
You can register a maximum of 2,147,483,647 SQL statements to be executed.

Format
 
public synchronized void addBatch(String sql) throws SQLException
 

Arguments
String sql
SQL statements to be executed

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the Statement object.
  • close() has already been issued for the Connection object that created this Statement object.
  • An attempt was made to register more than 2,147,483,647 SQL statements.
  • null or a character string with a length of 0 is specified for the SQL statements.
(b) cancel()

Function
Cancels the SQL statements executing in the corresponding object and in objects using the same connection as the corresponding object.

Format
 
public void cancel() throws SQLException
 

Arguments
None.

Return value
None.

Functional detail
You can use the cancel method to cancel executing SQL statements# asynchronously.
If the corresponding Statement object is not executing any SQL statements, but another object is executing SQL statements on the same connection object, this method performs asynchronous cancellation.
When cancellation processing is performed on the HiRDB server, any ResultSet, PreparedStatement, and CallableStatement objects created prior to the cancellation are ignored regardless of the following settings:
  • HiRDB_for_Java_STATEMENT_COMMIT_BEHAVIOR property in the Properties argument of DriverManager.getConnection
  • STATEMENT_COMMIT_BEHAVIOR in URL
  • setStatementCommitBehavior of the DataSource interface
  • HIRDB_CURSOR property in the Properties argument of DriverManager.getConnection
  • HIRDB_CURSOR in URL
  • setHiRDBCursorMode of the DataSource interface
  • setHoldability method of the Connection interface
  • resultSetHoldability argument in the createStatement and prepareStatement methods of the Connection interface
  • SQL statement (until disconnect specification)
If the corresponding Statement object is not executing any SQL statements and no other object is executing SQL statements on the same connection object, this method does not perform cancellation processing on HiRDB.
For a connection that uses XADataSource, an asynchronous cancellation request is ignored.
#
SQL statements being processed by the server when the HiRDB server has control (this JDBC driver is waiting for a response).

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

Function
Clears all SQL statements registered in this Statement object's batch.

Format
 
public synchronized void clearBatch() 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 Statement object.
  • close() has already been issued for the Connection object that created this Statement object.
(d) clearWarnings()

Function
Clears all warnings that have been reported for this Statement object.

Format
 
public synchronized void clearWarnings() throws SQLException
 

Arguments
None.

Return value
None.

Exceptions
None.
(e) close()

Function
Closes the Statement object and any ResultSet object created from this Statement object.

Format
 
public void close() throws SQLException
 

Arguments
None.

Return value
None.

Functional detail
This method closes the Statement object and any ResultSet object created from this Statement object.
If the close method of Statement results in an error while a pooling connection is being used, this method does not throw an SQLException.
In a pooling environment or an XA environment, if the close method of Statement results in an error because of physical disconnection from the database, thereby disabling connection pooling, ConnectionEventListener.connectionErrorOccurred() does not occur.

Exceptions
If a database access error occurs, the JDBC driver throws an SQLException.
(f) execute(String sql)

Function
Executes a specified SQL statement. You can use Statement.getResultSet and Statement.getUpdateCount to acquire 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 Statement.getResultSet and Statement.getUpdateCount to acquire the ResultSet object and the number of updated rows.
The following table shows the return values of Statement.getResultSet and Statement.getUpdateCount after execution of this method.

Table 18-18 Relationship between the executed SQL statement and the return values of Statement.getResultSet and Statement.getUpdateCount

Type of executed SQL statement Return value of Statement.getResultSet Return value of Statement.getUpdateCount
HiRDB_for_Java_DAB_EXECUTESQL_NOCHK system property setting
Other than TRUE TRUE
Retrieval SQL statement ResultSet object obtained as the execution result -1
Non-retrieval SQL statement null ResultSet object of 0 columns 0 or a greater value
SQL execution resulting in an error null null -1

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

Function
Executes the SQL statements registered in a batch and returns an array of the numbers of updated rows.
If an error occurs while the SQL statements registered in the batch are executing, or after they have all executed, the method calls Statement.clearBatch() and clears the batch registration information.

Format
 
public synchronized int[] executeBatch() throws SQLException
 

Arguments
None.

Return value
This method returns as an array the numbers of updated rows for all the executed SQL statements. The elements of the array are in the order the SQL statements were registered in the batch. If no SQL statements were registered in the batch, or the first SQL statement in the batch resulted in an error, the method returns an array containing no elements.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the Statement object.
  • close() has already been issued for the Connection object that created this Statement object.
The method throws a BatchUpdateException (subclass of SQLException) in the following cases:
  • A retrieval SQL statement was executed in the batch.
  • A database access error occurred.
(h) 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
    The method executes the specified non-retrieval SQL statement and returns the number of updated rows. For an SQL statement that has no retrieval result (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 the specified SQL statement and returns the resulting ResultSet object.
    For an SQL statement that has no retrieval result (such as an INSERT statement), the method returns a ResultSet object containing no columns. You can also use the Statement.getUpdateCount method to acquire the number of updated rows. The following table shows the return values of the executeQuery method and the Statement.getUpdateCount method that is executed after the executeQuery method.

    Table 18-19 Return values of the executeQuery method and the Statement.getUpdateCount method that is executed after the executeQuery method

    Executed SQL statement type executeQuery method's return value Statement.getUpdateCount method's return value
    Retrieval SQL statement ResultSet object for the execution result -1
    Non-retrieval SQL statement INSERT, UPDATE, DELETE ResultSet object containing no columns Number of updated rows
    Other ResultSet object containing no columns 0
    SQL statement resulting in an error -- -1

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the Statement object.
  • close() has already been issued for the Connection object that created this Statement 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.
(i) 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
    The method executes the 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 the specified SQL statement.
    If the return value is -1, you can use the Statement.getResultSet method to acquire the ResultSet object. The following table shows the return value of the Statement.getResultSet method that is executed after the executeUpdate method.

    Table 18-20 Return value of the Statement.getResultSet method that is executed after the executeUpdate method

    Executed SQL statement type Statement.getResultSet method's return value
    Retrieval SQL statement ResultSet object for the execution result
    Non-retrieval SQL statement INSERT, UPDATE, DELETE ResultSet object containing no columns
    Other ResultSet object containing no columns
    SQL statement resulting in an error null

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the Statement object.
  • close() has already been issued for the Connection object that created this Statement 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.
(j) getConnection()

Function
Returns the Connection object that created this Statement object.

Format
 
public synchronized Connection getConnection() throws SQLException
 

Arguments
None.

Return value
Connection object

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

Function
Acquires the default fetch direction for a result set that is created from this Statement object.
This method's return value is always ResultSet.FETCH_FORWARD because only the forward fetch direction is supported in HiRDB.

Format
 
public synchronized int getFetchDirection() throws SQLException
 

Arguments
None.

Return value
This method always returns ResultSet.FETCH_FORWARD.

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

Function
Acquires the default fetch size for a ResultSet object that is created from this Statement object.

Format
 
public synchronized int getFetchSize() throws SQLException
 

Arguments
None.

Return value
Default fetch size for a ResultSet object that is created from this Statement object.

Functional detail
This method acquires the default fetch size for a ResultSet object that is created from this Statement object.
If 0 is specified for setFetchSize, this method returns 0 even though the actual fetch size depends on the client environment definition. The following table shows the relationship between the fetch size and the return value.

Table 18-21 Relationship between fetch size and return value

setFetchSize setting (m) Return value
0 0
1 [Figure] m [Figure] 4096 m

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

Function
Acquires the maximum number of bytes for the character columns or binary columns of a ResultSet object that is created by this Statement object. Such a maximum size is applicable only to [M|N][VAR]CHAR, BINARY, and BLOB columns. Any excess bytes are discarded.
This method returns the value set by setMaxFieldSize.

Format
 
public synchronized int getMaxFieldSize() throws SQLException
 

Arguments
None.

Return value
Current maximum size (in bytes) for [M|N][VAR]CHAR, BINARY, and BLOB columns. A value of 0 means that there is no size limit.

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

Function
Acquires the maximum number of rows that can be stored in a ResultSet object created by this Statement object. Any excess rows are excluded without notification.
This method returns the value set by setMaxRows.

Format
 
public synchronized int getMaxRows() throws SQLException
 

Arguments
None.

Return value
Maximum number of rows that can be stored in a ResultSet object that is created by this Statement object (a value of 0 means that there is no limit to the number of rows).

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

Function
Moves to the next result set.

Format
 
public synchronized boolean getMoreResults() throws SQLException
 

Arguments
None.

Return value
true
There is another result set.
false
There are no more result sets.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the Statement object.
  • close() has already been issued for the Connection object that created this Statement object.
  • A database access error occurred.
(p) getQueryTimeout()

Function
Returns the SQL execution timeout value (in seconds).
This method returns the value set by setQueryTimeout.
If setQueryTimeout has not been executed, the method returns 0.

Format
 
public synchronized int getQueryTimeout() throws SQLException
 

Arguments
None.

Return value
Timeout value in seconds

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

Function
Acquires the current results as a ResultSet object.

Format
 
public synchronized ResultSet getResultSet() throws SQLException
 

Arguments
None.

Return value
ResultSet object held by the Statement object (if there are no results, the method returns null)

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

Function
Acquires the parallel processing mode for a ResultSet object that is created from this Statement object.
The method always returns ResultSet.CONCUR_READ_ONLY because the JDBC driver does not support an update cursor.

Format
 
public synchronized int getResultSetConcurrency() throws SQLException
 

Arguments
None.

Return value
This method always returns ResultSet.CONCUR_READ_ONLY.

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

Function
Acquires the holding facility for a ResultSet object that is created from this Statement object.
The holding facility is determined when the Statement object is created and cannot be changed subsequently.

Format
 
public synchronized int getResultSetHoldability() throws SQLException
 

Arguments
None.

Return value
ResultSet.HOLD_CURSORS_OVER_COMMIT
The ResultSet object may be manipulated even after commit or rollback processing.
ResultSet.CLOSE_CURSORS_AT_COMMIT
Any attempt after commit or rollback processing to manipulate the ResultSet object by a method other than close will result in an SQLException.

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

Function
Acquires the type of the result set of a ResultSet object that is created from this Statement object.
This method returns ResultSet.TYPE_FORWARD_ONLY or ResultSet.TYPE_SCROLL_INSENSITIVE because the JDBC driver does not support an update cursor.

Format
 
public synchronized int getResultSetType() throws SQLException
 

Arguments
None.

Return value
ResultSet.TYPE_FORWARD_ONLY
The cursor can move only forward.
ResultSet.TYPE_SCROLL_INSENSITIVE
The cursor can be scrolled, but a value change does not take effect.

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

Function
Returns the number of updated rows.

Format
 
public synchronized int getUpdateCount() throws SQLException
 

Arguments
None.

Return value
The following table shows the return values:
Statement object's method execution status Return value of getUpdateCount
executeXXX method has not been executed. -1
executeXXX method has been executed. getMoreResults method was executed after the last executeXXX method was executed. -1
The last executeXXX method executed resulted in an error. -1
executeBatch method was executed at the end. -1
An executeXXX method other than executeBatch was executed at the end. A retrieval SQL statement was executed at the end. -1
A non-retrieval SQL statement was executed at the end. INSERT,
UPDATE,
DELETE
Number of updated rows
Other 0

Functional detail
This method returns the number of updated rows.

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

Function
Acquires the first warning that is reported by a call related to this Statement object. If there is more than one warning, each subsequent warning is changed to the first warning and can be acquired by calling the SQLWarning.getNextWarning method for the immediately preceding warning that was acquired.

Format
 
public synchronized SQLWarning getWarnings() throws SQLException
 

Arguments
None.

Return value
First SQLWarning object (if there is no such SQLWarning object, the method returns null)

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the Statement object.
  • close() has already been issued for the Connection object that created this Statement object.
(w) setCursorName(String name)

Function
This method ignores the specified value because the driver does not support positioned updating or deletion processing.

Format
 
public synchronized void setCursorName(String name) throws SQLException
 

Arguments
String name
Cursor name

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the Statement object.
  • close() has already been issued for the Connection object that created this Statement object.
(x) setEscapeProcessing(boolean enable)

Function
Enables or disables escape syntax analysis by this Statement object.
The default is that escape syntax analysis is enabled.

Format
 
public synchronized void setEscapeProcessing(boolean enable) throws SQLException
 

Arguments
boolean enable
Specifies true to enable escape syntax analysis and false to disable it.

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the Statement object.
  • close() has already been issued for the Connection object that created this Statement object.
(y) setFetchDirection(int direction)

Function
Specifies the default fetch direction for a result set that is created from this Statement object.
The default value is ResultSet.FETCH_FORWARD.

Format
 
public synchronized void setFetchDirection(int direction) throws SQLException
 

Arguments
int direction
Only ResultSet.FETCH_FORWARD, which is the default fetch direction, can be specified.

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the Statement object.
  • close() has already been issued for the Connection object that created this Statement object.
  • A value other than ResultSet.FETCH_FORWARD is specified for direction.
(z) setFetchSize(int rows)

Function
Specifies the default fetch size for a ResultSet object that is created from this Statement object. If 0 is specified, the default fetch size depends on the client environment definition.

Format
 
public synchronized void setFetchSize(int rows) throws SQLException
 

Arguments
int rows
Number of rows to be fetched, in the range from 0 to 4096.

Return value
None.

Functional detail
This method specifies the default fetch size for a ResultSet object that is created from this Statement object. If 0 is specified, the default fetch size depends on the client environment definition.
The default value is 0. When a nonzero value is specified, the JDBC driver uses the block transfer facility by applying the specified value as the value of the PDBLKF client environment definition. For details about the block transfer facility, see 4.7 Block transfer facility.
The following table shows the relationship between this setting and the actual PDBLKF value that is used.

Table 18-22 Setting and actual PDBLKF value that is used

setFetchSize setting (m) Value of PDBLKF client environment definition (n) PDBLKF value used by block transfer facility
0 1 [Figure] n [Figure] 4096 n
Not specified Not specified
1 [Figure] m [Figure] 4096 1 [Figure] n [Figure] 4096 m
Not specified m

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the Statement object.
  • close() has already been issued for the Connection object that created this Statement object.
  • The condition rows < 0, maximum number of rows (value of getMaxRows()) < rows, or 4096 (maximum value of block fetch) < rows is true.
(aa) setMaxFieldSize(int max)

Function
Sets a maximum number of bytes for each character column or binary column in a ResultSet object that is created from this Statement object. This maximum size is applicable to [M|N][VAR]CHAR, BINARY, and BLOB columns. Any excess bytes are discarded.
The default value is 0.
This setting has no effect on ResultSet objects that have already been created.

Format
 
public synchronized void setMaxFieldSize(int max) throws SQLException
 

Arguments
int max
New maximum number of bytes. A value of 0 means that there is no size limit. If the maximum number of bytes is an odd number, that value minus 1 is used as the maximum number of bytes for NCHAR and NVARCHAR columns. As a result of this calculation, if the specified value is 1, the maximum number of bytes will become 0 for NCHAR or NVARCHAR columns, in which case the JDBC driver will assume that there is no size limit.

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the Statement object.
  • close() has already been issued for the Connection object that created this Statement object.
  • A value less than 0 is specified for max.
(ab) setMaxRows(int max)

Function
Specifies the maximum number of rows that can be stored in a ResultSet object that is created from this Statement object. Any excess rows are excluded without notification.
The default value is 0.
This setting has no effect on ResultSet objects that have already been created.

Format
 
public synchronized void setMaxRows(int max) throws SQLException
 

Arguments
int max
New maximum number of rows that can be stored. A value of 0 means that there is no limit to the number of rows. If 0 is specified when the type of the result set is ResultSet.TYPE_SCROLL_INSENSITIVE, the maximum number of rows that can be stored becomes Integer.MAX_VALUE.

Return value
None.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the Statement object.
  • close() has already been issued for the Connection object that created this Statement object.
  • A value less than 0 is specified for max.
(ac) setQueryTimeout(int seconds)

Function
Specifies an SQL execution timeout value (in seconds).

Format
 
public synchronized void setQueryTimeout(int seconds) throws SQLException
 

Arguments
int seconds
Timeout value in seconds

Return value
None.

Functional detail
This method specifies the maximum wait time (in seconds) for communication with the HiRDB server during SQL statement execution.
If 0 is specified, the value depends on the setting of the PDCWAITTIME client environment definition.
The default value is 0.
This method ignores the specified value if it is greater than 65535.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • close() has already been issued for the Statement object.
  • close() has already been issued for the Connection object that created this Statement object.
  • A value less than 0 is specified for seconds.

(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: PrdbStatement

(4) Notes

(a) Using the block transfer facility by specifying the setFetchSize method

If the value 1 or greater is specified for the setFetchSize method, the JDBC driver uses the block transfer facility and requests the HiRDB server to transfer all at once the retrieval results for the number of rows specified in the argument. For details about the block transfer facility, see 4.7 Block transfer facility.

Although there is no maximum specification value for the setFetchSize method, the block transfer facility can transfer only up to 4,096 rows at a time. Therefore, when a value greater than 4,096 is specified, the number of rows actually transferred at once will not exceed 4,096.

The following table shows the priorities that determine the number of rows that the JDBC driver requests the HiRDB server to transfer in a single transmission.

Table 18-23 Priorities for number of rows that the JDBC driver requests the HiRDB server to transfer in one transmission

Priority Specification value
1 Value specified in the argument of the setFetchSize method of the ResultSet class
2 Value specified in the argument of the setFetchSize method of the Statement class
3 Value specified in the PDBLKF client environment definition

For details about the number of rows that the JDBC driver actually receives from the HiRDB server in one communication when the driver requests the number of rows indicated in Table 18-23, see 4.7(4) Number of rows transferred in one transmission. However, when reading this section, replace PDBLKF with number of rows requested for transfer as determined by the priorities shown in Table 18-23, and replace FETCH statement with next method of the ResultSet class.

If the retrieval result is larger than the number of transfer rows shown in Table 18-23, the JDBC driver requests transfer to the HiRDB server as many times as necessary until retrieval is completed (or until all retrieval requests from the UAP are processed).

If one of the following conditions is satisfied, the number of rows that the JDBC driver receives from the HiRDB server in one transmission is 1:

(b) Asynchronous cancellation by the cancel method

You can use the cancel method to execute asynchronous cancellation of SQL statements being processed by the HiRDB server. Even if the target Statement object is not executing an SQL statement, asynchronous cancellation is executed if another object is executing an SQL statement for the same connected object.

When asynchronous cancellation is executed at the HiRDB server, all PreparedStatement and ResultSet objects that were created before the asynchronous cancellation become invalid, regardless of the specification for validating or invalidating Statement and ResultSet objects after commit execution.

The following methods specify whether or not objects are to remain valid after commit execution:

Asynchronous cancellation is not executed for the HiRDB server if the target Statement object is not executing an SQL statement, and if no other object is executing an SQL statement for that same connection object.

If XADataSource was used for the connection, an asynchronous cancellation request is not valid.

(c) Closing the ResultSet object during execution of an executeXXX method

If you execute an executeXXX method before the ResultSet object created by the corresponding Statement object has been closed, the JDBC driver closes the previous ResultSet object that was created. If an attempt is made to use the previously created ResultSet object to acquire search results after the executeXXX method has been executed, the JDBC driver will throw an SQLException. The following shows an example that results in an SQLException:

 
  Statement st  = con.createStatement();
  ResultSet rs1 = st.executeQuery("select * from tb1");
  ResultSet rs2 = st.executeQuery("select * from tb2");
  rs1.next();  // Throw SQLException
  rs2.next();