• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setAutocommit

 
Bianca Hagen
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?
 
Horatio Westock
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!
 
Adeel Ansari
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?
 
Vic Stachura
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
 
Bonagiri UmaMaheshwar Rao
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic