• 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

setAutocommit

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a problem and it looks like setAutocommit does not works as expected.
We do something like this:
setAutocommit(false)
loop
do some things and some updates
if succesfull{
commit()
System.out.println("success")
} else {
rollback()
System.out.println("failure")
}
endloop
Sometimes the "things" are not succesfull and I expect that a rollback should take place (as I can see from the System.out.println) but....
The rollback is not performed! The updates are still in the database!

Has anyone seen this behaviour before?
 
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Could you post some real code? You only need to show the important bits to do with JDBC like commit(), rollback() etc. Please include your try-catch-finally. It's difficult to determine the real flow of control without this.

Thanks!
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure you are not executing any DDL inside your loop?
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What database driver and version are you using? With the Oracle JDBC driver 10.x the SetAutoCommit() will not access the database (as one would expect).

Vic
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem might be due to you are not capturing failed database operations. make sure you are catching all the exceptions for failed transactions.
if you can post your real code it will be helpful.
 
The airline is called "Virgin"? Don't you want a plane to go all the way? This tiny ad will go all the way:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic