zoukankan      html  css  js  c++  java
  • java调用存储过程

     1 try {
     2             DBConnection dbs = new DBConnection();
     3             conn = dbs.getConnection();
     4             stmt = conn.prepareCall("{call PAK_ExecuteAttendingDoctor.ExecuteAttendingDoctor (?,?,?)}");//前两个为参数,第三个为输出
             //存储过程内容详见http://www.cnblogs.com/wuhailong/p/5137254.html
    5 stmt.registerOutParameter(1, OracleTypes.VARCHAR);//参数 6 stmt.registerOutParameter(2, OracleTypes.VARCHAR);//存数 8 stmt.registerOutParameter(3, OracleTypes.CURSOR);//游标 9 stmt.setString(1, start_time); 10 stmt.setString(2, end_time); 11 if (true) { 12 String ss = "select dept_name from lcp_local_dept where dept_code='" 13 + deptcodevalue + "'"; 14 DatabaseClass db1 = LcpUtil.getDatabaseClass(); 15 String deptName = ""; 16 deptName = db1.FunGetDataSetBySQL(ss).FunGetDataAsStringById(0, 17 0); 18 // stmt.setString(3,deptName); 19 stmt.execute(); 20 rs = (ResultSet) stmt.getObject(3); 21 while (rs.next()) { 22 String execute_dept = rs.getString("execute_dept"); 23 String attending_doctor = rs.getString("attending_doctor"); 24 int fhrs = rs.getInt("fhrs"); 25 int nrrs = rs.getInt("nrrs"); 26 int wcrs = rs.getInt("wcrs"); 27 double nrl = rs.getDouble("nrl"); 28 double wcl = rs.getDouble("wcl"); 29 int xdyzzs = rs.getInt("xdyzzs"); 30 int xdlcljyzs = rs.getInt("xdlcljyzs"); 31 double xdl = rs.getDouble("xdl"); 32 data.add(new Object[] { execute_dept, attending_doctor, 33 fhrs, nrrs, wcrs, nrl, wcl, xdyzzs, xdlcljyzs, xdl }); 34 } 35 } 36 } catch (Exception e) { 37 System.out.println("存储过程取数据出错!!" + e.getMessage()); 38 } finally { 39 if (stmt != null) { 40 try { 41 stmt.close(); 42 } catch (SQLException e) { 43 e.printStackTrace(); 44 } 45 stmt = null; 46 } 47 if (rs != null) { 48 try { 49 rs.close(); 50 } catch (SQLException e) { 51 e.printStackTrace(); 52 } 53 rs = null; 54 } 55 if (statement != null) { 56 try { 57 statement.close(); 58 } catch (SQLException e) { 59 e.printStackTrace(); 60 } 61 statement = null; 62 } 63 if (conn != null) { 64 try { 65 conn.close(); 66 } catch (SQLException e) { 67 e.printStackTrace(); 68 } 69 conn = null; 70 } 71 }
  • 相关阅读:
    RHEL 5.7 Yum配置本地源[Errno 2] No such file or directory
    SQL SERVER中什么情况会导致索引查找变成索引扫描
    Vmware扩展磁盘如何不需重启系统
    Vmware虚拟机进入BIOS方法
    Linux LVM学习总结——删除物理卷
    Linux系统检查查看桌面环境
    spring面试问题与答案集锦
    solr查询特殊字符的处理
    阅读源代码的一点小技巧
    solr查询工作原理深入内幕
  • 原文地址:https://www.cnblogs.com/wuhailong/p/5137261.html
Copyright © 2011-2022 走看看