• 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
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Using commit and rollback  RSS feed

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I am in non-commit mode and I try to commit a database transaction using the commit object, and the commit fails, will all queries in that commit be undone, or do I need to call rollback()? For example, say I want to commit 10 queries, but in the middle of committing them, I lose my database connection. Will the ones that were already committed be permanent changes, or do the changes not get made to the database until all of the queries successfully commit?

Thanks,
Jeff
 
Ranch Hand
Posts: 893
Java Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Storey,

When you loose your database connection an exception will be thrown. You can decide after the exception to rollback your transaction. The only problem is that you don't have a connection to a database for rolling back your transaction.

Your DBMS will discover the loss of the connection and will rollback your transaction.
 
Do you pee on your compost? Does this tiny ad?
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!