Question: Java transaction
Here is the answer,
We can handle the transanction by using setAutoCommit() method. We use setAutoCommit() method because all the database transaction should be committed automatically by JDBC. JDBC takes default commit mode as true. true means transactions committed automatically.[you cannot roll back any database transaction].false means you can manipulate transaction yourself.
So we use this method commit mode as false.
The code is as follows-
Connection conn = getConnection(); conn.setAutocommit(false); //other code conn.commit(); conn.close();