Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connection.SetAutoCommit

 
Kash Mhai
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Please see the following code..
------------
//con=getConnection();//Assume connection is there..
try
{
con.setAutoCommit(false);
...
..
//Insert some rows into a table
..
..
//All succeded.. no problems
con.commit();
}
catch (Exception e){
con.rollback();
}
------------
My questions are -
1. Does the AutoCommit property of the connection need to be set to TRUE?? before the connection is closed?
2. Does the rollback() need to be commited? I mean,
after using con.rollback(); in catch, do we need to use con.commit() again?
3. If i dont set the connection to setAutoCommit(true) again, will there be an effect while managing data from backend?
4. Does not using con.commit() after con.rollback(), and not setting the AutoCommit to true cause any performance issues?

Regards,
Kash
 
Ann Sebastian
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.By specifying conn.rollback() rolls back the transaction.You dont need to use conn.commit() after rollback to commit rollback.
2.conn.setAutoCommit has to be set to true if you dont want to explicitly commit other transaction from java.I dont think it affects performance in backend.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic