Oracle调用存储过程返回游标结果

/**
1
*/
public ResultSet queryForAllJSD_NEWEST(final String hpCode, final String id) {
System.out.println("hpCode:"+hpCode+",id:"+id);
ResultSet rs = (ResultSet)this.jdbctemplate.execute("{call pro_querybcb_newest(? , ? ,?)}" , new CallableStatementCallback(){
public Object doInCallableStatement(CallableStatement cs)
throws SQLException, DataAccessException {
cs.setString(1, hpCode) ;
cs.setString(2, id) ;
cs.registerOutParameter(3, oracle.jdbc.OracleTypes.CURSOR);
cs.execute();
return cs.getObject(3);
}
});
return rs;
}

/**
2
*/
public Map getMzJsData1(String hpCode,String id) throws IOException,
SQLException, JSONException {
System.out.println("========pro_querybcb_newest=============flag=AAA======");
System.out.println("hpCode[" + hpCode + "],id[" + id + "]");
Object hlzh = "";
ResultSet rs = dao1.queryForAllJSD_NEWEST(hpCode, id);
Map map = new HashMap();
Map m=(Map) dao.checkMzObj(hpCode, id).get(0);
map.put("groupid", m.get("ONE_MZ01_010"));
map.put("hosid", m.get("ONE_MZ01_011"));
map.put("subsection", m.get("ONE_MZ01_016"));
JSONObject jss = null;
try {
if (rs.next()) {
ResultSetMetaData rsmd = rs.getMetaData();
int i = rsmd.getColumnCount();
System.out.println("i=" + i);
for (int j = 1; j <= i; j++) {
map.put(rsmd.getColumnName(j),rs.getString(j) == null ? "" : rs.getString(j));
}
hlzh = dao1.getAreaName(id);
map.put("areaName", hlzh == null ? "" : hlzh.toString());

}
} finally {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
}
}
}
return map;
}


/**
3
*/

Map md=getMzJsData1(h.getHpCode(),map.get("ZYDJLSCODE").toString());

if(md!=null){
map.put("groupid", md.get("groupid"));
map.put("hosid", md.get("hosid"));
map.put("name", md.get("A4"));
map.put("idno", md.get("A7"));
map.put("Indate", md.get("A16"));
map.put("outdate", md.get("A17"));
map.put("hosno", md.get("A15"));
map.put("sick", md.get("A24"));
}

原文地址:https://www.cnblogs.com/fkeyta/p/12129219.html