Scalable Database Server, HiRDB Version 8 UAP Development Guide

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

17.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

Table 17-11 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 17-11 Statement interface methods

Method Remarks
addBatch(String sql) Up to 2,147,483,647 SQL statements can be registered for execution. If the maximum is exceeded, this method throws an SQLException.
cancel() For notes about this method, see (4)(b) Asynchronous cancellation by the cancel method.
clearBatch() --
clearWarnings() --
close() If an error occurs during close method execution when a connection pool or an XA connection is being used, the method does not throw an SQLException. If a fatal error occurs and the connection pool can no longer be used, the connectionErrorOccurred method of the ConnectionEventListener class does not occur.
execute(String sql) --
executeBatch() --
executeQuery(String Sql) If the SQL statement (such as an INSERT statement) does not have retrieval results, this method throws an SQLException.
executeUpdate(String Sql) If the SQL statement (SELECT statement) returns retrieval results, this method throws an SQLException.
getConnection() --
getFetchDirection() --
getFetchSize() Returns the value set by setFetchSize. If no value was set by setFetchSize, this method returns 0.
getMaxFieldSize() Returns the value set by setMaxFieldSize.
getMaxRows() Returns the value set by setMaxRows.
getMoreResults() --
getQueryTimeout() Returns the value set by setQueryTimeout. If no value was set by setQueryTimeout, this method returns 0.
getResultSet() --
getResultSetConcurrency() --
getResultSetHoldability() --
getResultSetType() --
getUpdateCount() The method returns -1 if any of the following applies:
  • No executeXXX method was executed.
  • The executeXXX that was executed last was the executeBatch method.
  • The executeXXX method that was executed last was not the executeBatch method and it returned a result set (example: SELECT statement execution).
  • The getMoreResults method was executed after the executeXXX method that was executed last.
  • The executeXXX method that was executed last threw an SQLException.
getWarnings() --
setCursorName(String name) --
setEscapeProcessing(Boolean enable) --
setFetchDirection(int direction) --
setFetchSize(int rows) If no value was specified with this method or if 0 was specified, the JDBC driver uses the value of the PDBLKF client environment variable as an indicator of the number of rows that must be extracted from the database when it retrieves data.
For notes about this method, see (4)(a) Using the block transfer facility by specifying the setFetchSize method.
setMaxFieldSize(int max) --
setMaxRows(int max) --
setQueryTimeout(int seconds) Specifies the maximum wait time (seconds) for communication with the HiRDB server during SQL execution. If this method is not called, the time specified by the PDCWAITTIME client environment variable becomes the maximum wait time.
If 65,536 or greater is specified, this method ignores the specification value.

Legend:
--: None.

(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.

Table 17-12 shows the priorities that determine the number of rows that the JDBC driver requests the HiRDB server to transfer in one transmission.

Table 17-12 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 17-12, 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 17-12, 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 17-12, 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.