This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Using commit and rollback Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Using commit and rollback" Watch "Using commit and rollback" New topic
Author

Using commit and rollback

Jeff Storey
Ranch Hand

Joined: Apr 07, 2007
Posts: 230
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
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
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.


Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using commit and rollback
 
Similar Threads
use of commit() and rollback()
Hibernate Queries and Transactions
SQL Exception Connection is busy with results for another hstmt.
can this be solved
How to control the transaction with external system?