This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

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.
 
get schwifty. tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!