Transaction Management In JDBC
Transaction represents a single unit of work. Transaction is a set of statements executed on a resource or resources applying ACID properties. Transactions are used to provide the data integrity over multiple users. The transaction includes the interaction between the databases and users.
ACID Properties :
- Atomicity, it's simple either all operations in database occur, or nothing occurs.
- Consistency, ensures that the database is in a valid state before and after the transaction.
- Isolation, any transaction is independent of another, and your result doesn't depends of any other.
- Durability, the result of commit a transaction must persist in a non-volatile memory even if occurs a crash or power loss.
Let's see an example of a transaction management:
public static void main(String args)throws Exception
stmt.executeUpdate("insert into student values(101,'tapuuu','CSE')");
stmt.executeUpdate("insert into student values(1o2,'prerik','IT')");
If we see the table student, (select * from student) we will see that 2 records has been added.
For this we need to create the student tables first.
create table student
Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects
SILAN Technology, BBSR Call to: 0674-2361252