Hibernate 存储过程 02

public List<StatisticsPO> statisticsEducationStatus(int sType,
			String districtCode, String parm1, String parm2, String examType) {
		List<StatisticsPO> rList = new ArrayList();
 		Connection conn = null;
		CallableStatement cs = null;
		ResultSet rs = null;
		try {
		      conn = SessionFactoryUtils.getDataSource(
		      getSessionFactory()).getConnection();
			cs = conn
				.prepareCall("{call package_statistics.statistics_education_status1(?,?,?,?)}");
			cs.setString(1, districtCode);
			cs.setString(2, parm1);
			cs.setString(3, examType);
			cs.registerOutParameter(4, oracle.jdbc.OracleTypes.CURSOR);
			cs.execute();
			rs = (ResultSet) cs.getObject(4);
			int orderIndex = 1;
			while (rs.next()) {
				StatisticsPO obj = new StatisticsPO(orderIndex);
				obj.setCode(rs.getString("CODE"));
				obj.setName(rs.getString("NAME"));
				obj.setNum1(rs.getFloat("EDUCATION_COUNT"));
				obj.setNum2(rs.getFloat("EDUCATION_COUNT_PERCENT"));
				obj.setNum3(rs.getFloat("AVG_SCORE"));
				obj.setNum4(rs.getFloat("RIGHT_KNOWLEDGE_AVG_SCORE"));
				obj.setNum5(rs.getFloat("RIGHT_ACTION_AVG_SCORE"));
				orderIndex++;
				rList.add(obj);
			}
			if (rs != null)
				rs.close();
			if (cs != null)
				cs.close();
			if (conn != null)
				conn.close();
			} catch (SQLException e) {
				log
				  .error("call package_statistics.education_status1错误!",e);
				} finally {
					if (rs != null)
					   try {
						rs.close();
					    } catch (Exception e) {
					    }
					if (cs != null)
					    try {
						cs.close();
					    } catch (Exception e) {
					}
					try {
					    if (conn != null) {
					         conn.close();
					    }
					} catch (Exception e) {
					}
				}
			} 
		return rList;
	}
原文地址:https://www.cnblogs.com/GenghisKhan/p/2342710.html