DB2® for z/OS® and DB2 for 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.
updateRowId is valid only if the target database system supports updating of ROWID columns.
If you are using JDBC 3.0, for getObject, the IBM Data Server Driver for JDBC and SQLJ returns an instance of the IBM Data Server Driver for JDBC and SQLJ-only class com.ibm.db2.jcc.DB2RowID.
If you are using JDBC 4.0, for getObject, the IBM Data Server Driver for JDBC and SQLJ returns an instance of the class java.sql.RowId.
If you are using JDBC 3.0, for setObject, use the IBM Data Server Driver for JDBC and SQLJ-only type com.ibm.db2.jcc.Types.ROWID or an instance of the com.ibm.db2.jcc.DB2RowID class as the target type for the parameter.
If you are using 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.
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 for Linux, UNIX, and Windows | ROWID_UNSUPPORTED |
DB2 for i | ROWID_VALID_FOREVER |
IBM Informix | ROWID_VALID_FOREVER |
ps.setRowId(1, rid);
java.sql.RowId rwid = rs.getRowId(1);
cs.registerOutParameter(1, java.sql.Types.ROWID)