STRUCTURE OF TABLE TREE id INT PRIMARY KEY average_age INT(3) name CHAR(100) which statements are true about the following code if con is a valid Connection object? try (Connection con = getConnection(); Statement statement = con.createStatement(); ResultSet rs = statement.executeQuery("SELECT * FROM tree");){ if (rs.next()) rs.getString(2); //line1 } catch (SQLException e) { System.out.println(e); } A. The code prints the average_age for all rows in table tree. B. The code prints the name for all rows in table tree. C. If there are no rows in table tree, the code will throw an exception. D. If table tree has multiple rows, the code prints the value for the average_age for the first row.
STRUCTURE OF TABLE TREE
id INT PRIMARY KEY
average_age INT(3)
name CHAR(100)
which statements are true about the following code if con is a valid Connection object?
try (Connection con = getConnection();
Statement statement = con.createStatement();
ResultSet rs = statement.executeQuery("SELECT * FROM tree");){
if (rs.next()) rs.getString(2); //line1
}
catch (SQLException e) {
System.out.println(e);
}
A.
The code prints the average_age for all rows in table tree.
B.
The code prints the name for all rows in table tree.
C.
If there are no rows in table tree, the code will throw an exception.
D.
If table tree has multiple rows, the code prints the value for the average_age for the first row.
Step by step
Solved in 2 steps