CallableStatement调用带参存储过程

con = this.getConnection();

   cs = con.prepareCall("{call PROC_TEST(?,?,?,?)}");
   cs.setInt(1, inParam1);
   cs.setInt(2, inParam2);
   cs.setString(3, inParam3);
   cs.registerOutParameter(4, OracleTypes.CURSOR);//存储过程中返回游标

   cs.execute();
   rs = (ResultSet) cs.getObject(4);//返回参数,注意要与设置返回参数的下标一致

   ResultSetMetaData md = rs.getMetaData();
   int columnCount = md.getColumnCount();

   while (rs.next()) {
    Map rowMap = new HashMap(columnCount);
    for (int i = 1; i <= columnCount; i++) {
     rowMap.put(md.getColumnName(i), rs.getObject(i));
    }
    returnList.add(rowMap);

   }

猜你喜欢

转载自huzhupo.iteye.com/blog/2119976