If you add the ROWID pseudocolumn to a query you can retrieve it in JDBC with the ResultSet getString entrypoint. You can also bind a ROWID to a preparedStatement parameter with the setString entrypoint.
This allows in-place updates, as in the following example:
Statement stmt = conn.createStatement ();
// Query the employee names with "FOR UPDATE" to lock the rows.
// Select the ROWID to identify the rows to be updated.
ResultSet rset =
stmt.executeQuery ("select ENAME, ROWID from EMP for update");
// Prepare a statement to update the ENAME column at a given ROWID
PreparedStatement pstmt =
conn.prepareStatement ("update EMP set ENAME = ? where ROWID = ?");
// Loop through the results of the query
while (rset.next ())
{
String ename = rset.getString (1);
String rowid = rset.getString (2); // Get the ROWID as a String
pstmt.setString (1, ename.toLowerCase ());
pstmt.setString (2, rowid); // Pass ROWID to the update statement
pstmt.executeUpdate (); // Do the update
}
In the ResultSetMetaData class, columns containing ROWIDs are reported with the type oracle.jdbc.OracleTypes.ROWID, whose value is -8.