Transactions Control Language (TCL) Syntax
Transactions group a set of tasks into a single execution unit. Each transaction begins with a specific task and ends when all the tasks in the group are successfully completed. If any of the tasks fail, the transaction fails. Therefore, a transaction has only two results: success or failure. You can explore more about transactions
This is supported by JDBC Java DataBase Connectivity. This is an application programming interface (API) for the Java programming language, which defines how a client may access a database. V3
Transaction Control Language (TCL Syntax)
BEGIN/START and END/COMMIT are available to define the beginning and end of a Logical Unit of Work as a transaction.
The default transaction isolation level is READ_COMMITTED.
Example 1:
Example 2:
Syntax | Explanation | Examples |
BEGIN (or START); |
Begin transaction |
|
INSERT …xxx…; |
|
|
SELECT …xxx…; |
OK |
|
ROLLBACK; |
|
Explicit Rollback Call: Rollback in the Case of Exception: |
SELECT …xxx…; |
Not found
|
|
INSERT …yyy…; |
|
|
SELECT …yyy…; |
OK |
|
COMMIT; |
End transaction with commit |
|
SELECT …yyy…; |
OK |
|
END (or COMMIT); |
|
Transaction Properties (Set Env Properties)
Property | Explanation |
com.gs.jdbc.v3.transaction_manager.transaction_isolation_level |
Transaction isolation level. Default transaction isolation level is READ_COMMITTED. |
com.gs.jdbc.v3.transaction_manager.commit_timeout |
Commit timeout. Default value is MAX_VALUE of Long. |
com.gs.jdbc.v3.transaction_manager.rollback_timeout |
Rollback timeout. Default value is MAX_VALUE of Long. |
com.gs.jdbc.v3.transaction_manager.default_timeout |
The requested lease time for the transaction. Default value is 90000. |