Most asked top Interview Questions and Answers | Online Test | Mock Test
Education platform for interview prep, online tests, tutorials, and live practice

Build skills with focused learning paths, mock tests, and interview-ready content.

WithoutBook brings subject-wise interview questions, online practice tests, tutorials, and comparison guides into one responsive learning workspace.

Search the library
Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Question: What does setAutoCommit do?
Answer: When a connection is created, it is in auto-commit mode. This means that each individual SQL statement is treated as a transaction and will be automatically committed right after it is executed. The way to allow two or more statements to be grouped into a transaction is to disable auto-commit mode:
con.setAutoCommit(false);

Once auto-commit mode is disabled, no SQL statements will be committed until you call the method commit explicitly.

con.setAutoCommit(false);
PreparedStatement updateSales =
con.prepareStatement( "UPDATE EMPLOYEE SET SAL = ? WHERE EMP_NAME LIKE ?");
updateSales.setInt(1, 50000); updateSales.setString(2, "Arindam");
updateSales.executeUpdate();
PreparedStatement updateTotal =
con.prepareStatement("UPDATE EMPLOYEE SET TOTAL = TOTAL + ? WHERE EMP_NAME LIKE ?");
updateTotal.setInt(1, 50000);
updateTotal.setString(2, "Arindam");
updateTotal.executeUpdate();
con.commit();
con.setAutoCommit(true);

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful? Yes No

Most helpful rated by users:

©2026 WithoutBook