oracle's package P_T_Reoprt
create or replace package P_T_Reoprt
as
type v_cursor is ref cursor;
function T_Reoprt (j varchar2) return v_cursor;
end P_T_Reoprt;
create or replace package body P_T_Reoprt
as
function T_Reoprt (j varchar2) return v_cursor
is
rc v_cursor;
begin
open rc for select * from customer where customer.sex = j;
return rc;
end;
end P_T_Reoprt;
------------------------------------------------
DBConnection.java(a method of the javabean's source)
....
public ResultSet executeProduce(){
rs = null;
try {
//connect the database
conn = DriverManager.getConnection("jdbc
racle:thin:@192.168.0.176:1521:yzttest","bill","bill"
;System.out.println("004:connection success!"
;// Prepare a PL/SQL call
CallableStatement call = conn.prepareCall ("{?=call P_T_Reoprt.T_Reoprt(?)}"
;System.out.println("005:prepare PL/SQL Call success!"
;// Find out all Record
call.registerOutParameter (1,OracleTypes.CURSOR);
call.setString (2,"M"
;System.out.println("006
L/SQL define success !"
;call.execute ();
System.err.println("007
L/SQL execute success!"
;ResultSet rs = (ResultSet)call.getObject (1);
System.out.println("008:take resultset success!"
;}
catch(SQLException ex) {
System.err.println("012:fail to DBConnection.executeProduce: " + ex.getMessage());
}
return rs;
}
....
------------------------------------------------
when i invok that DBConnection's executeProduce method in the Servlet, that had happened and error when execute at "while(rs.next())"
...
DBConnection JavaBean = new DBConnection();
System.out.println("001:JavaBean instance success!"
;ResultSet rs=JavaBean.executeProduce();
System.out.println("002:method invok success!"
;while (rs.next())//<<--------------that has error
System.out.println("018:there have record!"
上一页 下一页






