posted 3 weeks ago
Suppose learn() is a stored procedure that takes one IN parameter and one OUT parameter. What is wrong with the following code? (Choose all that apply.)
18: var sql = "{?= call learn(?)}";
19: try (var cs = conn.prepareCall(sql)) {
20: cs.setInt(1, 8);
21: cs.execute();
22: System.out.println(cs.getInt(1));
23: }
1. Line 18 does not call the stored procedure properly.
2. The parameter value is not set for input.
3. The parameter is not registered for output.
4. The code does not compile.
5. Something else is wrong with the code.
6. None of the above. This code is correct.
The given answer is
C. Since an OUT parameter is used, the code should call registerOutParameter(). Since this is missing, option C is correct.
This seems wrong based on my understanding to the context in page 889 for "Returning an OUT Parameter" and the index shouldnt be 1 for both cs.setInt(1) and cs.getInt(1)