O'Reilly logo

Special Edition Using Java 2 Standard Edition by Geoff Friesen, Chuck Cavaness, Brian Keeton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Transactions

There are times when you have multiple statements that depend on one another successfully completing before another statement should execute. For example, in the employee database that you are working with, if an employee's salary is updated in the EMPLOYEE table, you also need to update that in the SALARYHISTORY table. If the update to the EMPLOYEE table fails, you don't want to go through with the update to the SALARYHISTORY table or you will have invalid data in the database. This is known as a data integrity problem.

The best way to ensure that this happens in the correct manner is to wrap these two updates in a transaction. A transaction is a set of one or more statements that work together as a unit. Either all the statements ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required