18.5 Atomic Transactions

By default, a newly created database Connection object is in auto-commit mode. That means that each update to the database is treated as a separate transaction and is automatically committed to the database. Sometimes, however, you want to group several updates into a single atomic transaction, with the property that either all the updates complete successfully or no updates occur at all. With a database system (and JDBC driver) that supports it, you can take the Connection out of auto-commit mode and explicitly call commit( ) to commit a batch of transactions or call rollback( ) to abort a batch of transactions, undoing the ones that have already been done. Example 21-3 in Chapter 21 uses atomic transactions to ensure database consistency.



Java Examples in a Nutshell
Java Examples in a Nutshell, 3rd Edition
ISBN: 0596006209
EAN: 2147483647
Year: 2003
Pages: 285

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net