日期:2014-05-19 浏览次数:20822 次
CallableStatement callstate; ResultSet rs; List<Account> list = new ArrayList<Account>(); try { callstate = factory.getCurrentSession().connection().prepareCall( "call p_zhou.quer_aaccount(?,?)"); callstate.setString(1, "2"); callstate.registerOutParameter(2, oracle.jdbc.OracleTypes.CURSOR); callstate.execute(); rs = (ResultSet) callstate.getObject(2); int i = rs.getMetaData().getColumnCount();// 得到列数 while (rs.next()) { Account account = new Account(); account.setName(rs.getString(1)); account.setPassword(rs.getString(2)); list.add(account); }
create or replace package body p_zhou is -- Private type declarations -- Private constant declarations -- Private variable declarations -- Function and procedure implementations procedure quer_aaccount(zpassword varchar2, Zresult out zjcursor) as begin open Zresult for select t.* from account t where t.password = zpassword; exception when others then p_Myerr.Handle(sqlcode, sqlerrm); end; end p_zhou;