Oracle table lock

Hi,

privatestatic String SQL_UPDATE =

"UPDATE ACCT_TRANSACTION " +

"SET " +

" ATTEMPT = ?, " +

" OUTCOME = ?, " +

" QUEUED = ?, " +

" RESULT1 = 'Cxvya', " +

" RESULT2 = ?, " +

" CALL_START_TIME = ?, " +

" DATE_MODIFIED = SYSDATE " +

"WHERE ACCT_TRANSACTION_ID = ? " ;

conn = DAOFactory.getConnection();

PreparedStatement pstmt = conn.prepareStatement(CallDAO.SQL_UPDATE);

pstmt.setQueryTimeout(30);

pstmt.setInt(1, call.getAttempts());

pstmt.setString(2, call.getOutcome());

pstmt.setInt(3, call.getQueued());

pstmt.setString(4, call.getResult2());

pstmt.setTimestamp(5, call.getCallStartTime());

pstmt.setString(6, call.getAcctTransactionId());

if(pstmt.getUpdateCount() != -1){

pstmt.close();

conn.commit() ;

}else{

pstmt.close();

conn.rollback();

}

Ive run into a situation where there is a lock on the table, and my code needs to realise there is a lock and take move on. pstm.setQueryTimeOut(30); does'nt seem to work right.

The above snippet checking the updateCount() although not tested, sounded like a good idea. Right now the threads hang when there is a lock on the table. Any other ideas, how I can realise there is a lock and timeout, or throw an exception using prepared statements, or any other method?

[1890 byte] By [Cstriker533a] at [2007-10-3 5:20:55]
# 1

The real solution is to get rid of the lock.

You didn't say why the timeout didn't work.

The repeating tries is only going to work if the lock does not last long and is not repeated often. (And if it is repeated often then it really suggests it is wrong.)

You can probably write a stored proc that can actually test for a lock.

jschella at 2007-7-14 23:27:52 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...