ROWIDs in JDBC with the IBM Data Server Driver for JDBC and SQLJ
Db2® for z/OS® and Db2 for IBM® i support the ROWID data type for a column in a database table. A ROWID is a value that uniquely identifies a row in a table.
Although IBM Informix® also supports rowids, those rowids have the INTEGER data type. You can select an IBM Informix rowid column into a variable with a four-byte integer data type.
- getBytes
- getColumns (JDBC 4.0 and later)
- getObject
- getRowId (JDBC 4.0 and later)
- updateRowId (JDBC 4.0 and later)
updateRowId is valid only if the target database system supports updating of ROWID columns.
In JDBC 4.0, for getObject, the IBM Data Server Driver for JDBC and SQLJ returns an instance of the class java.sql.RowId.
- setRowId (JDBC 4.0 and later)
- setBytes
- setObject
In JDBC 4.0, for setObject, use the type java.sql.Types.ROWID
or an instance of the java.sql.RowId
class as the target type for the parameter.
- getRowId (JDBC 4.0 and later)
- getObject
To call a stored procedure that is defined with a ROWID output
parameter, register that parameter to be of the java.sql.Types.ROWID
type.
Database server | DatabaseMetaData.getRowIdLifetime |
---|---|
Db2 for z/OS | ROWID_VALID_TRANSACTION |
Db2 on Linux®, UNIX, and Windows systems | ROWID_UNSUPPORTED |
Db2 for IBM i | ROWID_VALID_FOREVER |
IBM Informix | ROWID_VALID_FOREVER |
ps.setRowId(1, rid);
java.sql.RowId rwid = rs.getRowId(1);
java.sql.Types.ROWID
data type,
use this form of the registerOutParameter method: cs.registerOutParameter(1, java.sql.Types.ROWID)