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.
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) );
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc