• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is SetAutocommit() dangerous?  RSS feed

 
Neha Ashok
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Is it necessary to do connction.commit() or rollback() after using connection.setAutoCommit(false)? Is it dangerous to if set this property false?
(Connection object has Application scope)
 
Juanjo Bazan
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Setting autocommit to false you get the best performance if the commit level used is Connection.TRANSACTION_NONE (default).
The changes will be rolled back only if there is running a transaction isolation level other than none when you close the connection.
So if your application do not really need any implicit commit, this is a good practice.
Ttake a look at other JDBC tips here.
HTH
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...or you could always try the JDBC forum

Dave
 
David Hibbs
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Juanjo Bazan:
Setting autocommit to false you get the best performance if the commit level used is Connection.TRANSACTION_NONE (default).
The changes will be rolled back only if there is running a transaction isolation level other than none when you close the connection.
So if your application do not really need any implicit commit, this is a good practice.
Ttake a look at other JDBC tips here.
HTH

Just to clarify, if you want _anything_ committed, you need to issue the commit call. Otherwise, everything will be rolled back. So what he said is correct--you technically do not _have_ to issue either a commit or rollback call. However, if you don't, the result will be a rollback!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!