1

I'm calling a stored proc using CallableStatement as below:

Connection connection = jdbcTemplate.getDataSource().getConnection();
CallableStatement callSt = connection.prepareCall("{call my_proc(?, ?)}");
callSt.setDate(1, getDate());
callSt.registerOutParameter(2, oracle.jdbc.OracleTypes.CURSOR);
callSt.execute();
ResultSet rs = (ResultSet) callSt.getObject(2);

I then iterate the result set to create a List<MyPojo> having 4 5 items

My query is how do I avoid iterating ResultSet and use RowMapper to get List

PS: I found the other way of using mapper using SimpleJdbcCall

SimpleJdbcCall call = new SimpleJdbcCall(jdbcTemplate)
                .withSchemaName("myindex")
                .withCatalogName("mypackage")
                .withProcedureName("my_proc")
                .declareParameters(new SqlParameter[]{
                        new SqlParameter("myinput", OracleTypes.DATE),
                        new SqlOutParameter("myoutput", OracleTypes.CURSOR, new MyMapper())
                    });
Ajeetkumar
  • 1,271
  • 7
  • 16
  • 34
  • See https://stackoverflow.com/questions/9361538/spring-jdbc-template-for-calling-stored-procedures – Ori Marko Dec 31 '19 at 09:52
  • thank you for the link but i did not prefer the idea of jdbcTemplate.query(). I want it through CallableStatement. I actually got the other way of using mapper (Updated question) – Ajeetkumar Dec 31 '19 at 10:31

0 Answers0