10.B] Write a note on:
i) Transaction processing
ii) Savepoint
Transaction processing
- A transaction is a set of actions to be carried out as a single, atomic action. Either all of the actions are carried out, or none of them are.
- Advantage is fast performance It makes the performance fast because database is hit at the time of commit.
Method | Description |
void setAutoCommit(boolean status) | It is true bydefault means each transaction is committed bydefault. |
void commit() | commits the transaction. |
void rollback() | cancels the transaction. |
Savepoints
- When you set a savepoint you define a logical rollback point within a transaction. If an error occurs past a savepoint, you can use the rollback method to undo either all the changes or only the changes made after the savepoint.
The Connection object has two new methods that help you manage savepoints −
- setSavepoint(String savepointName): Defines a new savepoint. It also returns a Savepoint object.
- releaseSavepoint(Savepoint savepointName): Deletes a savepoint. Notice that it requires a Savepoint object as a parameter. This object is usually a savepoint generated by the setSavepoint() method.