Hi, list! 

A strange problem. 

I have a session bean that access a datasource. When a connection is 
requested and method Connection.getAutoCommit() is called, I always obtain 
true. The default autocommit isn't false? 

Stranger! See this code:

  try {
    Connection con = getConnection();  //obtain connection in datasource
    con.setAutoCommit(false);
    ....
    stmt.executeUpdate(sql1);
    stmt.executeUpdate(sql2);
    ....
  } catch(Exception) {
      sessionContext.setRollbackOnly();
  } 

When stmt.executeUpdate(sql) throws a SQLException, my session bean calls
setRollbackOnly and the transaction should rollback. In fact, I saw that 
stmt.executeUpdate(sql1) didn't have effect in database just after this 
method have execute. But after about 1 minute, I turn to database and I saw 
that the effect of  stmt.executeUpdate(sql1) was commited. 

I repeat the experiment many times, and the same occurred after one minute. 

It sounds like the container had setted the autocommit true after some 
timeout. Does anyone knows what is happenning? The default autocommit isn't 
false? 


Carlos Roberto da Silva Júnior
Engenheiro de Software
Ramal - 4631 

Qualiti Software Processes - CESAR
Soluções para o processo de construção de software
http://www.qualiti.com.br
+55 81 3272.4700 

Reply via email to