wood burning stoves 2.0*
The moose likes JDBC and the fly likes connection.SetAutoCommit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "connection.SetAutoCommit" Watch "connection.SetAutoCommit" New topic
Author

connection.SetAutoCommit

Kash Mhai
Greenhorn

Joined: Apr 01, 2005
Posts: 29
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


-------------<br />There are wheels within wheels...<br />P.G Wodehouse
Ann Sebastian
Ranch Hand

Joined: Sep 21, 2005
Posts: 37
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: connection.SetAutoCommit