Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Delay in Commit

419277Dec 16 2004
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.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 13 2005
Added on Dec 16 2004
0 comments
386 views