Delay in Commit
I have application with three tier architecture Client- Web Server- Oracle
Oracle DB running on the RAC and LOAD_BALANCE is turned ON.
...
connection = connectionFactory.getConnection();
connection.setAutoCommit(false);
try
{
updateTables(connection);
connection.commit();
} catch (SQLException sqle) {
connection.rollback();
} finally {
try {
if (connection != null)
connection.close();
} catch (SQLException sqle) {
}
}
...
public void updateTables(Connection Connection) throws SQLException
{
...
// for each table
ResultSet resultSet = selectStatement.executeQuery();
if (resultSet.next()) {
count = columns.size();
for (int i = 0; i < count; i++) {
resultSet.updateString((String)columns.get(i),
(String)data.get(i));
}
resultSet.updateRow();
}
resultSet.close();
...
}
After transaction is completed sometimes I need to retrieve data from DB back to the client with the new server call to the DB (new connection). Sometimes I get old data back, not newly committed. If I repeat call in a second or so, I will get latest update.
I donât know how to fix problem except make it sleep for a second after connection is closed but before I reply to user.
I asked DBAs in my company for help.
I was told that my problem is that I close the result set, before I commit and I cannot do it. I should issue the commit statement first and then close the result set.
How would I rollback, when error occurs in the last table that needs to be updated, if I already committed updates in the previous tables. It doesnât make sense.
I would appreciate any help.
Thank you,
Irina.