Oracle
1Z0-819 · Question #102
Consider the method declaration: public void setSessionUser(Connection conn, String user) throws SQLException { Statement stmt = conn.createStatement(); String sql = "<EXPRESSION>"…
The correct answer is A. A, because it sends exactly the value of user provided by the calling code. See the full explanation below for the reasoning.
Question
Consider the method declaration:
public void setSessionUser(Connection conn, String user) throws SQLException {
Statement stmt = conn.createStatement();
String sql = "<EXPRESSION>";
stmt.execute(sql);
}
Is A or B the correct replacement for <EXPRESSION> and why?
A. SET SESSION AUTHORIZATION "" + stmt.enquoidetifier(user)
B. SET SESSION AUTHORIZATION "" + user
Is A or B the correct replacement for <EXPRESSION> and why?
Options
- AA, because it sends exactly the value of user provided by the calling code.
- BB, because it sends exactly the value of user provided by the calling code prevents SQL injection.
- CA and B are functionally equivalent.
- DA, because it is unnecessary to enclose identifiers in quotes.
- EB, because all values provided by the calling code should be unquoted.
How the community answered
(47 responses)- A83% (39)
- B9% (4)
- C4% (2)
- D2% (1)
- E2% (1)
Community Discussion
No community discussion yet for this question.