top of page

Transaction Management in JDBC

-Transaction Management in java is required when we are dealing with relational databases.

-By default when we create a database connection, it runs in auto-commit mode.

It means that whenever we execute a query and it's completed, the commit is fired automatically.

-So every SQL query we fire is a transaction and if we are running some DML or DDL queries, the changes are getting saved into database after every SQL statement finishes.

-Sometimes we want a group of SQL queries to be part of an transaction so that we can commit them when all the queries runs fine. If we get any exception we have a choice of rollback all the queries executed as part of the transaction.


ree

  • Advantages of Transaction Management:

-Fast Performance: It makes the performance fast because database is hit at the time of commit.


-In JDBC, Connection interface provides methods to manage transaction.

  1. void setAutoCommit (boolean status) : It is true by default means each transaction is committed by default.

  2. void commit() : Commits the transaction.

  3. void rollback() : Cancel the transaction.

  • Example:

ree



 
 
 

Recent Posts

See All

Comments


MiIT Logo

Company

Contact Us

905-487-4880 

5160 Explorer Dr #34, Mississauga,ON L4W 4T7

929-743-3199

4466 Buttonwood Ln Lilburn, GA 30047

262 Chapman Rd, STE 240 Newark DE 19702

Stay up to date on the latest from MiIT

  • Instagram
  • Facebook
  • http://linkedin.com/company/miittechnologies/about/
  • Whatsapp

© All Content MiIT Technologies Inc.2019 - 2025. All rights reserved.

bottom of page