Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

connection.setAutoCommit()

 
Ranch Hand
Posts: 644
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

If I have a method which is processing bunch of SQL statements like below:

method a(){
con.setAutoCommit(false);
getA();
getB();
update();
updatex();
con.commit();

}
catch(Exception){
}
finally{
}

what are the consequences of not using the con.rollBack if some exception occurs.
Thanks,
Trupti
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by trupti nigam:

what are the consequences of not using the con.rollBack if some exception



Assume your update() method is successful and an exception occurr in updatex() method. Now if you don't rollback your transaction,the data will remain in same state changed by update() method until commit or rollaback.

If same time any other method want to perform any operation on same row changed by update() method then it will get error.

Shailesh
 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by trupti nigam:
what are the consequences of not using the con.rollBack if some exception occurs.



When you are performing transaction on any database row, you are locking it and not allowing other users to perform update operations on it. A rollback() or commit() releases the locks.
 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic