日期:2014-05-18  浏览次数:20929 次

各位大侠帮帮忙吧(java调oracle函数问题)
CREATE   OR   REPLACE   PACKAGE   MY_STEEL_SOFT
AS
    --存储过程返回数据集的类型
    TYPE   ReturnDataSet   IS   REF   CURSOR;

END   MY_STEEL_SOFT;

--函数
create   or   replace   function   bb(beginDate   in   varchar2)
    return   My_steel_soft.ReturnDataSet
as
    ACursor   My_steel_soft.ReturnDataSet;
begin
    open   ACursor   for   select   *   from   v_out_orderqry   t
                    where   t.dOrderDate> =beginDate;
                                --and   t.dOrderDate <   endDate;
                                --and   t.sSalerGUID=orgguid
                                --or   t.sBuyGUID=orgguid;
    return   ACursor;
end;


/**
  *   TestFun.java
  *   create   on   2007-5-23
  *   Copyright   2010   MySteelSoft   All   Rights   Reserved.
  */
package   com.test;

import   java.sql.CallableStatement;
import   java.sql.Connection;
import   java.sql.DriverManager;
import   java.sql.ResultSet;
import   java.sql.SQLException;
public   class   TestFun{

public   static   void   main(String[]   args)
{
        Connection   connection   =   null;
try{  
Class.forName( "oracle.jdbc.driver.OracleDriver ");  
}  
catch(ClassNotFoundException   e)   {  
System.out.println( "数据库驱动类没找到 ");
}
try{
String   serverName   =   "192.168.18.21 ";
String   portNumber   =   "1521 ";
String   sid   =   "eTrade ";
String   url   =   "jdbc:oracle:thin:@ "   +   serverName   +   ": "   +   portNumber   +   ": "   +   sid;
String   username   =   "developer ";
String   password   =   "mysteelsoft ";
connection   =   DriverManager.getConnection(url,username,password);
CallableStatement   cstmt;

cstmt   =   connection.prepareCall( "{?   =   call   bb(?)} ");
cstmt.setString(2, "2006-12-12 ");
cstmt.registerOutParameter(1,oracle.jdbc.OracleTypes.CURSOR);
ResultSet   rest   =   cstmt.executeQuery();
while(rest.next()){
System.out.println( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!::: "+rest.getString( "SGUID "));
}
}catch(SQLException   e)   {
e.printStackTrace();    
}
}
}


执行后出现以下错误!!