• 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;
        }
    

      

  • 相关阅读:
    Vue生命周期
    脚本生命周期
    音频
    光照系统
    InstantOC(对象渲染---游戏优化)
    kafka单机环境配置以及基本操作
    mysql 锁机制
    java.math.BigDecimal类multiply的使用
    去掉返回的json中特殊字符
    TheadLocal与synchronized
  • 原文地址:https://www.cnblogs.com/qxqbk/p/15421002.html
Copyright © 2020-2023  润新知