- List<Map<String, Object>> entryList = jdbcTemplate.execute(new CallableStatementCreator() {
- public CallableStatement createCallableStatement(Connection con) throws SQLException {
- String storedProc = "{ call JSJD_DXJG(?,?,?,?,?) }";// 调用的sql
- CallableStatement cs = con.prepareCall(storedProc);
- cs.setString(1, year);// 设置输入参数的值
- cs.setString(2, month);
- cs.setString(3, projectrate);
- cs.setString(4, v_type);
- cs.registerOutParameter(5, OracleTypes.CURSOR);// 注册输出参数的类型
- return cs;
- }
- }, new CallableStatementCallback() {
- public Object doInCallableStatement(CallableStatement cs) throws SQLException,DataAccessException {
- List resultsMap = new ArrayList();
- cs.execute();
- ResultSet rs = (ResultSet) cs.getObject(5);// 获取游标一行的值
- while (rs.next()) {// 转换每行的返回值到Map中
- Map rowMap = new HashMap();
- rowMap.put("org_code", rs.getString("org_code"));
- rowMap.put("org_name", rs.getString("org_name"));
- rowMap.put("num", rs.getString("num"));
- rowMap.put("finsh", rs.getString("finsh"));
- rowMap.put("bfb", rs.getString("bfb"));
- rowMap.put("project_money", rs.getString("project_money"));
- resultsMap.add(rowMap);
- }
- rs.close();
- return resultsMap;
- }
- });
转载于:https://blog.51cto.com/daheyuan/1138486