❮ Previous Next ❯

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 :

Let's see an example of a transaction management:

import java.sql.*;
class TransactionDemo
{
public static void main(String args[])throws Exception
{
Class.forName("oracle.jdbc.driver.OracleDrive");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
con.setAutoCommit(false);
Statement stmt=con.createStatement();
stmt.executeUpdate("insert into student values(101,'tapuuu','CSE')");
stmt.executeUpdate("insert into student values(1o2,'prerik','IT')");
con.commit();
con.close();
}
}

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
(
regdno varchar(25),
name char(45),
branch char(55)
);

❮ Previous Next ❯

Follow Us




  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved