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 }

 

你可能感兴趣的:(java调用存储过程)