Oracle DB 12.1 does not support inserting stored procedure names as part of callable statements
Typo for setting user_id (parameter 4) in callable statement (is set to parameter 3 instead of 4)
ResultSet cannot be called and expect an OUT parameter with Oracle DB 12.1, AFAIK
Assertion is checking that ID of every study set in ResultSet is equal to 1, instead of checking for e.g. user_id equaling value passed into the stored procedure.
To reproduce
Create required stored procedure in database
Set TIER_3_PROCEDURE_NAME in com.rev.config.ConnectionConfig` as well as database details.
Run Answer4Test.java
Workaround
This is a rework of the test that has worked for me.
try (Connection conn = DriverManager.getConnection(ConnectionConfig.URL, ConnectionConfig.USERNAME, ConnectionConfig.PASSWORD)) {
String sql = "{ call " + ConnectionConfig.TIER_3_PROCEDURE_NAME + "(?, ?) }";
CallableStatement cs = conn.prepareCall(sql);
// First parameter is set to user_id 4, since this user owns study sets
int userId = 4;
cs.setInt(1, userId);
// Second parameter is the cursor
cs.registerOutParameter(2, Types.REF_CURSOR);
// Manually execute callable statement
cs.execute();
// Select OUT parameter
ResultSet rs = (ResultSet) cs.getObject(2);
while (rs.next()) {
// Assert that user_id is the owner of every study set
// Expects user_id 4 from every third column (OWNER_ID)
assertEquals(userId, rs.getInt(3));
}
Describe the bug
user_id
(parameter 4) in callable statement (is set to parameter 3 instead of 4)To reproduce
TIER_3_PROCEDURE_NAME
in com.rev.config.ConnectionConfig` as well as database details.Workaround This is a rework of the test that has worked for me.