Oracle
1Z0-809 · Question #26
public class Test { public static Connection newConnection =null; public static Connection getConnection () throws SQLException { try (Connection con = DriverManager.getConnection(URL, userName…
The correct answer is C. A SQLException is thrown as runtime. You've hit your session limit · resets 5:20pm (America/New_York)
Question
public class Test {
public static Connection newConnection =null;
public static Connection getConnection () throws SQLException {
try (Connection con = DriverManager.getConnection(URL, userName, password)) {
newConnection = con;
}
return newConnection;
}
public static void main (String [] args) throws SQLException {
getConnection ();
Statement st = newConnection.createStatement();
st.executeUpdate("INSERT INTO student VALUES (102, 'Kelvin')");
}
}
Assume that:
- The required database driver is configured in the classpath.
- The appropriate database is accessible with the URL, username, and password exists.
- The SQL query is valid. What is the result?
Options
- AThe program executes successfully and the STUDENT table is updated with one record.
- BThe program executes successfully and the STUDENT table is NOT updated with any record.
- CA SQLException is thrown as runtime.
- DA NullPointerException is thrown as runtime.
How the community answered
(32 responses)- A9% (3)
- B3% (1)
- C81% (26)
- D6% (2)
Explanation
You've hit your session limit · resets 5:20pm (America/New_York)
Community Discussion
No community discussion yet for this question.