In Java spring boot framework,trying to consume the Store procedure using the following method
 jdbcTemplate.setDataSource(dataSource);
       SimpleJdbcCall simpleJdbcCall = new SimpleJdbcCall(jdbcTemplate)
                                           .withSchemaName("abc")
                                           .withFunctionName("proname")
                                           .addDeclaredParameter(new
 SqlOutParameter("",""));
        Map<String, Object> map= new HashMap<>();
         map.put("a",a);
        map.put("b",b);
        map.put("c",c);
        map.put("d",d);
 SqlParameterSource in = new MapSqlParameterSource(map);
 Map<String, Object> out = simpleJdbcCall.execute(in);
but my procedure also has out parameters here is my procedure
function proname(z varchar2,
                                            a varchar2,
                                            b varchar2,
                                            c varchar2,
                                            d in out number,
                                            e out number,
                                            f out varchar2,
                                            g out varchar2)
the procedure also has out parameters as one can see in above code, Question is how can I mention multiple out parameters(Note Multiple ) in Simple JDBC Call????
I tried like following and it works:
jdbcTemplate.execute((CallableStatementCreator) con -> {
        con = con.unwrap(OracleConnection.class);
        CallableStatement cs = con.prepareCall("{ ? = call usr.abc.proname(?,?,?,?,?,?,?) }");
        cs.registerOutParameter(1, OracleType.NUMBER);
        cs.setString(2, "a");
        cs.setString(3, "b");
        cs.setString(4, "c");
        cs.registerOutParameter(4, OracleType.NUMBER);
        cs.registerOutParameter(5, OracleType.NUMBER);
        cs.registerOutParameter(6, OracleType.VARCHAR);
        cs.registerOutParameter(7, OracleType.VARCHAR);
        return cs;
    }, (CallableStatementCallback<MyModel>) cs -> {
        cs.execute();
        return new MyModel(cs.getInt(1),
                           cs.getInt(4),
                           cs.getInt(5),
                           cs.getString(6),
                           cs.getString(7));
    });
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With