从java调用存储过程
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection(url,user,pw);
System.out.println("Connected");
CallableStatement st=con.prepareCall("{call myProcedure(?,?)}");
st.setString(1,"hibernate");
st.registerOutParameter(2, Types.INTEGER);
ResultSet rs=st.executeQuery();
while(rs.next()){
System.out.println(rs.getInt(2));
}
我无法从DB中获取多条记录。任何人都会在这方面指导我。谢谢
这是我的程序
create or replace procedure myProcedure(eskill varchar2,eid out number)
is
cursor c
is
select empid from emp_skills where skill=eskill;
begin
open c;
loop
fetch c into eid;
exit when c%notfound;
dbms_output.put_line('name of the emp with skill '||eskill|| ' ' ||eid);
end loop;
close c;
end myProcedure;
/