java执行查询存储过程
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 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; } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 提示词工程——AI应用必不可少的技术
· 地球OL攻略 —— 某应届生求职总结
· 字符编码:从基础到乱码解决
· SpringCloud带你走进微服务的世界