Which is true if the myTable
database exists and contains an empty myTable
table?.
String url = "jdbc:derby:myTable"; try (Connection conn = DriverManager.getConnection(url); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("select count(*) from myTable")) { rs.next(); // r1 System.out.println(rs.getInt(1)); // r2 }
A.
The count(*) function in SQL always returns a number.
In this case, it is the number zero.
This means line r1 executes successfully because it positions the cursor at that row.
Line r2 also executes successfully and prints 0, which is the value in the row.
Since the code runs successfully, Option A is the answer.