How many rows are added to the colors table from running the following?.
try (Connection conn = DriverManager.getConnection(url); Statement stmt = conn.createStatement()) { conn.setAutoCommit(false); stmt.executeUpdate("insert into colors values ('red')"); stmt.executeUpdate("insert into colors values ('blue')"); conn.commit(); conn.setAutoCommit(true); stmt.executeUpdate("insert into colors values ('green')"); }
D.
While the code turns off automatic committing, there is a commit()
statement after the first two inserts that explicitly commits those to the database.
Then automatic commit is turned back on and the third commit is made, making Option D the answer.