Originally posted by Jan Cumps:
Hanna,
Can you post your solution? It helps fellow ranchers that have the same question.
Regards, Jan
Here is my solution:
Connection connection = null;
String sql = "{ ? = call getNextEntityId }";
Long id = null;
CallableStatement cs = null;
try
{
connection = session.connection();
cs = connection.prepareCall(sql);
cs.registerOutParameter(1, Types.BIGINT);
cs.execute();
id = cs.getLong(1);
logger.info("generate(): Id generated successfuly: " + id);
return(id);
}
The key is to register the OUT parameters before you execute the stored procedure. In the above case, the stored proc. returns one value, so I registered one value. Then, you get the registered values in the same order they are registerd and with the same type as they are registerd using cs.getXX()