Multiple sequential calls to updateXXX/commit on updatable ResultSet fail
843854Sep 28 2001 — edited Oct 3 2001private static void myRun (
Connection oConnection,
Integer oId)
throws Exception
{
PreparedStatement oStatement = null;
ResultSet oResultSet = null;
try
{
oStatement = oConnection.prepareStatement (
"select dii_import.* from dii_import where dii_history_oid = ? " +
"and dii_import_status = ?",
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
oStatement.setInt (1, oId.intValue ());
oStatement.setString (2, "NUL");
// <Cursor into result set>
oResultSet = oStatement.executeQuery ();
while (oResultSet.next ())
{
oResultSet.updateString ("DII_IMPORT_STATUS", "ST1");
oResultSet.updateRow ();
oConnection.commit ();
// do some work
oResultSet.updateString ("DII_IMPORT_STATUS", "ST2");
oResultSet.updateRow ();
oConnection.commit ();
}
}
finally
{
if (oResultSet != null) oResultSet.close();
if (oStatement != null) oStatement.close();
}
}
We update each record to "ST1" to indicate we started working on the record, process it, & then try to set it to "ST2" to indicate that the record has been processed. On the second (2nd) updateRow () the following exception is thrown.... any ideas on how to get around it. I've tried refreshRow (), moving to the same row after the update with a call to ResultSet.absolute ().
java.sql.SQLException: Value conflicts occurs
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
at oracle.jdbc.driver.UpdatableResultSet.execute_updateRow(UpdatableResultSet.java:2136)
at oracle.jdbc.driver.UpdatableResultSet.updateRow(UpdatableResultSet.java:1322)
I'm running jdk1.3 on oracle 8i.