I've got a problem with using a SELECT ... FOR UPDATE.

The code basically looks like this (stripped down for simplicity):

  PreparedStatement stat = conn.prepareStatement(
                                    "SELECT ... FOR UPDATE",
  try (ResultSet r = stat.executeQuery()) {
    if (!r.next()) {
      throw new Exception();
    r.updateRow();                      // throws SQLException

The call to updateRow() is throwing the following SQLException:

  class java.sql.SQLException: Invalid cursor state - no current row.

I cannot for the life of me see why this is happening, since the test on r.next() shows that I've found the row I want to update.

Can anyone suggest a reason what might be going on here?

John English

Reply via email to