您的位置:首页 >> 编程开发 >> Java >> JavaBeans >> 正文
RSS
 

What way is right to invok ResultSet form JavaBean in Servle

http://www.rdxx.com 05年09月13日 19:35 ChinaUnix.net 我要投稿

关键词: JavaBean , FORM , RM , BEA , Java

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("jdbcracle: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("006L/SQL define success !";
    call.execute ();
    System.err.println("007L/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!"
上一页 下一页

 
 
标签: JavaBean , FORM , RM , BEA , Java 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站