Spring:jdbcDao调用存储过程

来源:互联网 发布:淘宝哪个玩具店好 编辑:程序博客网 时间:2024/05/01 14:58
public Map statisticsByProcedure(final java.sql.Date date) {return (Map) jdbcDao.getJdbcTemplate().execute("{call STATISTICS_FOR_SHITANG(?)}",new CallableStatementCallback() {public Object doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {cs.setDate(1, date);ResultSet rs = cs.executeQuery();Map statisticsMap = new HashMap(); // map<PIC,map<WEEKDAY,COUNT>>while (rs.next()) {String C_PID = rs.getString("C_PID");Integer N_WEEKDAY = new Integer(rs.getInt("N_WEEKDAY"));Integer N_COUNT = new Integer(rs.getInt("N_COUNT"));Map countMap = new HashMap(); // map<WEEKDAY,COUNT>countMap.put(N_WEEKDAY, N_COUNT);Map _map = (Map) statisticsMap.get(C_PID); // map<WEEKDAY,COUNT>if (_map == null) {_map = countMap;} else {_map.putAll(countMap);}statisticsMap.put(C_PID, _map);}return statisticsMap;}});}


 

原创粉丝点击