DB2ResultSet interface
The com.ibm.db2.jcc.DB2ResultSet interface is used to create objects from which IBM® Data Server Driver for JDBC and SQLJ-only query information can be obtained.
DB2ResultSet fields
The following fields are defined only for the IBM Data Server Driver for JDBC and SQLJ.
The integer constants in the following table are used in the column descriptor information that getDBRowDescriptor returns. These constants contain information about the column values that are returned by getDBRowAsBytes. All fields are defined as public static int.
| Field value | Description of returned data |
|---|---|
| REPRESENTATION_FIXED_STRING (0) | Fixed-length string data |
| REPRESENTATION_BIG_ENDIAN (1) | Signed binary format in which the most significant byte is stored in the highest address |
| REPRESENTATION_LITTLE_ENDIAN (2) | Signed binary format in which the least significant byte is stored in the highest address |
| REPRESENTATION_VARIABLE_STRING (2) | String data that begins with a two-byte length field |
| REPRESENTATION_NUL_TERMINATED_STRING (3) | Nul-terminated string data |
| REPRESENTATION_FIXED_BYTES (4) | Fixed-length byte string |
| REPRESENTATION_VARIABLE_BYTES (5) | Byte string that begins with a two-byte length field |
| REPRESENTATION_NUL_TERMINATED_BYTES (7) | Nul-terminated byte data |
| REPRESENTATION_FIXED_BINARY (15) | Fixed-length binary string |
| REPRESENTATION_VARIABLE_BINARY (16) | Binary string that begins with a two-byte length field |
| REPRESENTATION_PACKED_DECIMAL (48) | Nul-terminated binary string |
| REPRESENTATION_NUMERIC_CHARACTER (50) | Character-based, fixed-point format |
| REPRESENTATION_ZONED_DECIMAL (51) | Zoned-decimal format that is returned by IBM System i and IBM Z |
| REPRESENTATION_COBOL2_ZONED_DECIMAL (53) | Zoned-decimal format that is returned by Windows or UNIX systems |
| REPRESENTATION_HEXADECIMAL_FLOATING_POINT (64) | S/390® hexadecimal floating point format |
| REPRESENTATION_DECIMAL_FLOATING_POINT (66) | Decimal floating point format |
| REPRESENTATION_IEEE_754_FLOATING_POINT_BYTE_REVERSED (71) | IEEE floating-point format in which the least significant byte is stored in the highest address |
| REPRESENTATION_IEEE_754_FLOATING_POINT (72) | IEEE floating-point format in which the most significant byte is stored in the highest address |
DB2ResultSet methods
The following methods are defined only for the IBM Data Server Driver for JDBC and SQLJ.
- getDB2RowChangeToken
- Format:
public long DB2ResultSet.getDB2RowChangeToken() throws java.sql.SQLExceptionReturns the row change token for the current row, if it is available. Returns 0 if optimistic locking columns were not requested or are not available.
This method applies only to connections to Db2 on Linux®, UNIX, and Windows systems.
- getDB2RID
- Format:
public Object DB2ResultSet.getDB2RID() throws java.sql.SQLExceptionReturns the RID for the current row, if it is available. The RID is available if optimistic locking columns were requested and are available. Returns null if optimistic locking columns were not requested or are not available.
This method applies only to connections to Db2 on Linux, UNIX, and Windows systems.
- getDB2RIDType
- Format:
public int DB2ResultSet.getDB2RIDType() throws java.sql.SQLExceptionReturns the data type of the RID column in a DB2ResultSet. The returned value maps to a
java.sql.Typesconstant. If the DB2ResultSet does not contain a RID column,java.sql.Types.NULLis returned.This method applies only to connections to Db2 on Linux, UNIX, and Windows systems.
- getDBRowDataAsBytes
- Format:
public Object [] getDBRowDataAsBytes() throws SQLExceptionReturns an Object array that represents the data in the current row of an open ResultSet object.
This method does not apply to connections to IBM Informix®.
getDBRowDataAsBytes cannot be called if the ResultSet object on which it operates meets any of the following conditions:
- A ResultSet row that is being retrieved has been updated, deleted, or inserted.
- The ResultSet object was created for optimistic locking.
The returned information includes:
- The data in raw byte array format
- The offset to the data for each column
Suppose that obj is an instance of the returned Object array. The format of the Object array is:
- obj[0]
- A byte array that describes the row data.
- obj[1]
- An integer array that contains the offset into obj[0] of
each column description. The offsets can be used to determine the
length of the data that is returned for each column. That length represents
the length of the raw data, and not the defined length of the column.If a ResultSet object contains a column of any of the following types, the offset value for that column value in obj[1] is -1. -1 indicates that a value for that column is not returned.
- BLOB
- CLOB
- DBCLOB
- XML
The byte array in obj[0] has the following format:
rnndd…dd…nndd…ddThere is one nndd…dd set for each column in the row.
The following table describes the contents of the row data:
Item Description r A single byte that has one of the following values: - 0
- The row data is not valid. One reason for invalid data is that the row has not yet been fetched.
- 1
- The row data is valid.
nn A two-byte NULL indicator for a column value. Possible values are: - -1
- The column value that follows is null.
- 0
- The column value that follows is not null.
dd…dd Raw byte data for a column value. - getDBRowDescriptor
- Format:
public int [] getDBRowDescriptor() throws SQLExceptionReturns an int array that contains descriptive information about each column of the row data that is returned by getDBRowDataAsBytes.
This method does not apply to connections to IBM Informix.
Suppose that returnedInfo is an instance of the array that is returned by getDBRowDescriptor. The format of the returned array is:
- returnedInfo[0]
- The number of columns in the row data. Suppose that this value is n.
- returnedInfo[1] through returnedInfo[4*n]
- n repeating groups of four integer values.
Each group contains descriptive information for a single column. That
information is:
Column descriptor number Description 1 The data type of the column, expressed as an SQLTYPE value. This value is the same as the SQLTYPE value that is returned in an SQLDA. 2 The CCSID of the column, for a character data type. For a DECIMAL data type, this value is the scale of the column. 3 The defined length of the column, for all data types except DECIMAL. For a DECIMAL data type, this value is the precision of the column. For varying-length character data types, this value might be greater than the number of returned bytes. 4 Additional information about the column. Possible values are described in DB2ResultSet fields.
- getDBTimestamp
- Formats:
public DBTimestamp getDBTimestamp(int parameterIndex) throws SQLException public DBTimestamp getDBTimestamp(String parameterName) throws SQLExceptionReturns the value in the current row of a TIMESTAMP or TIMESTAMP WITH TIME ZONE column that is in a DB2ResultSet object as a DBTimestamp object. For a TIMESTAMP column, the returned value has the local time zone. If the value of the DB2ResultSet column is NULL, the returned value is null.
Parameters:- parameterIndex
- The number of the column in the DB2ResultSet whose value is being retrieved.
- parameterName
- The name of the column in the DB2ResultSet whose value is being retrieved.
- setMAXBLKEXT
- Formats:
public void setMAXBLKEXT(int maxblkext) throws SQLExceptionSpecifies the maximum number of extra blocks that the DRDA client can receive from the data server without further prompting.
Parameters:- maxblkext
- The number of extra blocks to be returned. Possible values are:
- -1
- The data server determines the maximum number of extra blocks that the client can receive. -1 is the default.
- 0
- The client receives no extra blocks.
- n
- The maximum number of extra blocks that the client can receive. n is an integer that is greater than or equal to 1 and less than or equal to 100.
The MAXBLKEXT value that is set through this method overrides the value of the MAXBLKEXT Connection or DataSource property.
This property is applicable only to IBM Data Server Driver for JDBC and SQLJ type 4 connectivity to Db2 for z/OS® or Db2 on Linux, UNIX, and Windows systems.
- updateDBDefault
- Formats:
public void updateDBDefault(int parameterIndex) throws SQLException public void updateDBDefault(String columnName) throws SQLExceptionAssigns the default value to the specified column in a DB2ResultSet object. This method does not update the underlying table.
Parameters:- parameterIndex
- The number of the column in the DB2ResultSet whose value is being updated.
- columnName
- The name of the column in the DB2ResultSet whose value is being updated.
This method is not supported for connections to IBM Informix data sources.