java调用存储过程
2016-01-17 15:11
447 查看
try { DBConnection dbs = new DBConnection(); conn = dbs.getConnection(); stmt = conn.prepareCall("{call PAK_ExecuteAttendingDoctor.ExecuteAttendingDoctor (?,?,?)}");//前两个为参数,第三个为输出 //存储过程内容详见http://www.cnblogs.com/wuhailong/p/5137254.html stmt.registerOutParameter(1, OracleTypes.VARCHAR);//参数 stmt.registerOutParameter(2, OracleTypes.VARCHAR);//存数 stmt.registerOutParameter(3, OracleTypes.CURSOR);//游标 stmt.setString(1, start_time); stmt.setString(2, end_time); if (true) { String ss = "select dept_name from lcp_local_dept where dept_code='" + deptcodevalue + "'"; DatabaseClass db1 = LcpUtil.getDatabaseClass(); String deptName = ""; deptName = db1.FunGetDataSetBySQL(ss).FunGetDataAsStringById(0, 0); // stmt.setString(3,deptName); stmt.execute(); rs = (ResultSet) stmt.getObject(3); while (rs.next()) { String execute_dept = rs.getString("execute_dept"); String attending_doctor = rs.getString("attending_doctor"); int fhrs = rs.getInt("fhrs"); int nrrs = rs.getInt("nrrs"); int wcrs = rs.getInt("wcrs"); double nrl = rs.getDouble("nrl"); double wcl = rs.getDouble("wcl"); int xdyzzs = rs.getInt("xdyzzs"); int xdlcljyzs = rs.getInt("xdlcljyzs"); double xdl = rs.getDouble("xdl"); data.add(new Object[] { execute_dept, attending_doctor, fhrs, nrrs, wcrs, nrl, wcl, xdyzzs, xdlcljyzs, xdl }); } } } catch (Exception e) { System.out.println("存储过程取数据出错!!" + e.getMessage()); } finally { if (stmt != null) { try { stmt.close(); } catch (SQLException e) { e.printStackTrace(); } stmt = null; } if (rs != null) { try { rs.close(); } catch (SQLException e) { e.printStackTrace(); } rs = null; } if (statement != null) { try { statement.close(); } catch (SQLException e) { e.printStackTrace(); } statement = null; } if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } conn = null; } }
相关文章推荐
- 中文和unicode互转
- JAVA OO 第二章知识点
- 浅析Java中CountDownLatch用法
- JavaWeb_SpringMVC和titles的简单整合
- Eclipse下Preferences解析
- 【转】零基础写Java知乎爬虫之进阶篇
- java BigInteger 的使用
- Git学习笔记(2)-Eclipse中Git插件使用
- 浅谈Java平台无关性
- Java第二章总结(数据类型,运算符)
- Java 入门 之 system.out.println
- Spring (五) 声明式事务
- 3 Maven-POM文件说明
- Spring 整合Structs
- JAVA NIO 基础(一)
- JavaOO第二章知识总结
- spring (三) 加载外部资源文件/配置jdbc数据源
- 基于java实现,封装验证码实例
- spring (二) 构造器注入和工厂模式注入
- spring (一) 不同版本加载 bean 的方式