Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Synchronized java code hanging on a commit
I have a client server application that is hanging when, from what I
can tell, doing a commit - but I can't see anything wrong with the
code. All the server methods that update or delete data from the
database are in the same object and are synchronized (the ones that
only read data are not). The server has only one database connection.
The read-only methods do not contain transaction markers. The methods
that update data do contain transaction markers and these methods
protect themselves from nested transactions as shown in the code
snippet at the end of the posting (the server hangs on the
dbConn.commit() call in the singleDBConn class).
If only one thread can ever be updating data, how can we be getting what appears to be deadlock!?
The database is Oracle 8i. I am not sure what information is relevant
but -
the isolation level on the connection is set to
TRANSACTION_READ_COMMITTED
auto commit is set to false
the JDBC driver we are using is the OCI8 one.
One more piece of information - when the server hangs, there is a TX and a TM type record on the V$LOCK table, with what appear to be corresponding records in the V$LOCKED_OBJECT and V$TRANSACTION tables.
Any help greatly appreciated!!
Paul
public class C1
{
public synchronized String updateStuff()
{
blnMyTrans = singleDBConn.beginTrans(); ...do db updates... if (blnMyTrans) singleDBConn.commitTrans();
}
public Class singleDBConn
{
private boolean transStarted = false;
public boolean beginTransaction()
{
boolean thisCallStartedTrans = false; if (transStarted == false) { thisCallStartedTrans = true; transStarted = true; } return thisCallStartedTrans;
try { transStarted = false; dbConn.commit(); } catch (SQLException e) { }