use of org.jdbi.v3.core.statement.OutParameters in project jdbi by jdbi.
the class TestOutParameterAnnotation method testOutParameter.
@Test
public void testOutParameter() {
MyDao myDao = db.onDemand(MyDao.class);
OutParameters outParameters = myDao.callStoredProc();
assertThat(outParameters.getInt("outparam")).isEqualTo(100);
}
use of org.jdbi.v3.core.statement.OutParameters in project jdbi by jdbi.
the class CallTest method testCall.
@Test
public void testCall() {
Handle handle = db.getHandle();
handle.execute(findSqlOnClasspath("create_stored_proc_add"));
// tag::invokeProcedure[]
OutParameters result = handle.createCall(// <1>
"{:sum = call add(:a, :b)}").bind("a", // <2>
13).bind("b", // <2>
9).registerOutParameter("sum", // <3> <4>
Types.INTEGER).invoke();
// end::invokeProcedure[]
// tag::getOutParameters[]
int sum = result.getInt("sum");
// end::getOutParameters[]
assertThat(sum).isEqualTo(22);
}
use of org.jdbi.v3.core.statement.OutParameters in project jdbi by jdbi.
the class TestSqlCall method testFoo.
@Test
public void testFoo() throws Exception {
Dao dao = handle.attach(Dao.class);
// OutParameters out = handle.createCall(":num = call stored_insert(:id, :name)")
// .bind("id", 1)
// .bind("name", "Jeff")
// .registerOutParameter("num", Types.INTEGER)
// .invoke();
dao.insert(1, "Jeff");
assertThat(handle.attach(Dao.class).findById(1)).isEqualTo(new Something(1, "Jeff"));
}
use of org.jdbi.v3.core.statement.OutParameters in project jdbi by jdbi.
the class TestOutParameterAnnotation method testMultipleOutParameters.
@Test
public void testMultipleOutParameters() {
MyDao myDao = db.onDemand(MyDao.class);
OutParameters outParameters = myDao.callMultipleOutParameters(1, 9);
assertThat(outParameters.getInt("c")).isEqualTo(9);
assertThat(outParameters.getInt("d")).isEqualTo(1);
}
Aggregations