hello all,
i know this question can be odd, but i have legacty code that calls storedProcedures using callable statement.(not using Spring, usingn plain JDBC returning a ResultSet)
i was wondering if it was possible to write a Spring StoredProcedure which returns a ResultSet within the Map returned by execute() method..
so far, i have been unable to do so..
when i use this code
i get back a null ResultSet...Code:declareParameter(new SqlReturnResultSet("rs", new ResultSetExtractor() { public Object extractData(ResultSet rs) throws SQLException { return rs; }}));
if i replace that code with this one
i get this exceptionCode:declareParameter(new SqlReturnResultSet("rs", new ResultSetExtractor() { public Object extractData(ResultSet rs) throws SQLException { Map map = new HashMap(); map.put(SPConstants.PARM_ID, rs.getString(1)); map.put(SPConstants.PARM_NAM, rs.getObject(2)); map.put(SPConstants.PARM_VAL, rs.getObject(3)); map.put(SPConstants.DAT_TYP, rs.getObject(4)); logger.info("-- Map is:" + map); return map; }}));
the only way to make it work is to use a RowMapper instead..Code:declareParameter(new SqlReturnResultSet("rs", new ResultSetExtractor() { public Object extractData(ResultSet rs) throws SQLException { Map map = new HashMap(); map.put(SPConstants.PARM_ID, rs.getString(1)); map.put(SPConstants.PARM_NAM, rs.getObject(2)); map.put(SPConstants.PARM_VAL, rs.getObject(3)); map.put(SPConstants.DAT_TYP, rs.getObject(4)); logger.info("-- Map is:" + map); return map; }}));
could anyone explain me why?
With kindest regards
marco


Reply With Quote