• java执行查询存储过程


    public JSONObject getDataSyrsBzsAndSyrs(String type,String date){
            String sjklx = CodeRepositoryUtil.getValue("SJKLX","2");//实名制是2
            JSONObject jsonObject=new JSONObject();//
            //以下查询人员
            String sql="select (select count(*) from "+sjklx+".t_ry_jbxx t where  t.zwjb in('121','111'))tjzz," +
                    "(select count(*) from "+sjklx+".t_ry_jbxx t where  t.zwjb in('122','112')) tjfz," +
                    "(select count(*) from "+sjklx+".t_ry_jbxx t where  t.zwjb in('131')) xjczz," +
                    "(select count(*) from "+sjklx+".t_ry_jbxx t where  t.zwjb in('132')) xjcfz," +
                    "(select count(*) from "+sjklx+".t_ry_jbxx t) zj  from dual"; //页面运算  减去上面的就是其他
            JSONArray obj=DatabaseOptUtils.listObjectsBySqlAsJson(this,sql);
            if(obj!=null&&obj.size()>0){
                jsonObject=obj.getJSONObject(0);
            }
            //查询编制
            CallableStatement cs=null;
            Connection connection=null;
            ResultSet rs = null;
    
            try {
                connection= this.jdbcTemplate.getDataSource().getConnection();
                String smz= CodeRepositoryUtil.getValue("SJKLX","2");
                cs = connection.prepareCall("{call "+smz+".proc_report_1_5(?,?)}");
                cs.setString(1, "320000");
                cs.registerOutParameter(2, OracleTypes.CURSOR);
                cs.execute();
                rs = (ResultSet) cs.getObject(2);
                int i=0;
                while (rs.next()) {
                    if(i==17){
                        jsonObject.put("bz",rs.getInt(3));
                        jsonObject.put("zz",rs.getInt(4));
                    }
                    i++;
                }
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }finally{
                try {
                    if(rs!=null){
                        rs.close();
                    }
                    if (cs!=null) {
                        cs.close();
                    }
                    if(connection!=null) {
                        connection.close();
                    }
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
    
            return jsonObject;
        }
    

      

  • 相关阅读:
    arc路径例子-磊哥
    使用路径arc-奥运五环
    arc路径-磊哥
    使用路径arc-七彩
    html5- 摘自网友dudu
    使用路径arc
    textBaseline
    html5-磊哥
    【洛谷1345】 [USACO5.4]奶牛的电信(最小割)
    【洛谷1231】 教辅的组成(网络流)
  • 原文地址:https://www.cnblogs.com/qxqbk/p/15421002.html
Copyright © 2020-2023  润新知