zoukankan      html  css  js  c++  java
  • 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;
    	}
    
  • 相关阅读:
    初识你Swift【上篇】
    初识你Swift【下篇】
    单元测试基础
    时间都去哪了?
    iOS App上线的秘密
    mysql系列——DQL常见操作汇总(四)
    Get和Post请求有什么区别?
    SpringBoot2+WebSocket之聊天应用实战
    OCR识别
    mysql系列——子查询(非常重要)(八)
  • 原文地址:https://www.cnblogs.com/GenghisKhan/p/2342710.html
Copyright © 2011-2022 走看看