assertFalse(r.next());
}
@Test
public void testCallableStatements() throws SQLException {
MockConnection connection = new MockConnection(new MockDataProvider() {
@Override
public MockResult[] execute(MockExecuteContext ctx) throws SQLException {
assertEquals("{ ? = call my_function(?, ?, ?, ?) }", ctx.sql());
assertEquals(5, ctx.bindings().length);
assertEquals(null, ctx.bindings()[0]);
assertEquals(2, ctx.bindings()[1]);
assertEquals(null, ctx.bindings()[2]);
assertEquals(4, ctx.bindings()[3]);
assertEquals(null, ctx.bindings()[4]);
assertEquals(5, ctx.outParameterTypes().length);
assertEquals(Types.INTEGER, ctx.outParameterTypes()[0]);
assertEquals(0, ctx.outParameterTypes()[1]);
assertEquals(Types.VARCHAR, ctx.outParameterTypes()[2]);
assertEquals(0, ctx.outParameterTypes()[3]);
assertEquals(Types.DATE, ctx.outParameterTypes()[4]);
return new MockResult[] { new MockResult(recordOne) };
}
});
CallableStatement stmt = connection.prepareCall("{ ? = call my_function(?, ?, ?, ?) }");
stmt.registerOutParameter(1, Types.INTEGER);
stmt.setInt(2, 2);
stmt.registerOutParameter(3, Types.VARCHAR);
stmt.setInt(4, 4);