There are currently 100 rows in the table cat before inserting a new row.
What is the output of the following code?
try (Connection conn = DriverManager.getConnection("jdbc:derby:zoo"); Statement stmt = conn.createStatement()) { ResultSet rs = stmt.executeQuery("select count(*) from cat"); int num = stmt.executeUpdate("INSERT INTO cat VALUES (3, 'Ant', .05)"); rs.next(); System.out.println(rs.getInt(1)); }
D.
A Statement automatically closes the open ResultSet when another SQL statement is run.
This means that rs is no longer open by the println, and a SQLException is thrown because the ResultSet is closed.