我昏,你这个存储过程没输出参数,但你在代码里注册一个输出参数做什么??
你这错误不止一个哦,发个原始的例子给你看看
public ResultSet getRs(int agrs1,int agrs2)
    {
      try
      {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        //trade是数据源名称
        Connection con=DriverManager.getConnection("jdbc:odbc:trade","sa","");
        //procedureName是指存储过程名
        CallableStatement pstat=conn.prepareCall("{call procedureName(?,?)}");
        pstat.setInt(1,agrs1);
        pstat.setInt(2,agrs2);
        ResultSet rs=pstat.executeQuery();
        return rs;
      }
      catch(Exception e)
      {
        e.printStackTrace();
return null;
      }
    }
返回了结果集就不用我告诉你该怎么做了吧?

解决方案 »

  1.   

    新的问题有出了
    ???
    建表
    create table gao
    (
      id not null identity(1,1) primary key,
      name varchar(20),
      sex varchar(5),
      aa int,
      bb int
    )
    建视图
    create view tt
    as
    (
       select [id],name,sex,aa,bb from gao 
    )
    建存储过程
    create proc g
    @p1 int,
    @p2 int
    as
      select [id],name,sex,aa,bb from tt where aa=@p1 and bb=@p2java调用它  并输出表中的数据
    try
       {
        CallableStatement callst = null;
        Connection con = Jdbc.getConnection() ;
        callst = con.prepareCall("{call espshang(?,?)}") ;
        
        callst.setInt(1,1) ;
        callst.setInt(2,2) ;
        callst.execute() ;         
        ResultSet rs = callst.getResultSet() ; 
        while(rs.next())
        {
               System.out.println(rs.getInt("id")) ; ----看这里1
               System.out.println(rs.getString("name")) ;
               System.out.println(rs.getString("sex")) ;
        }
       }catch(Exception e)
       {
       e.printStackTrace() ;
       }
    以上程序是正确的
      但我想这样输出,该如何??     while(rs.next())
        { 
               System.out.println(rs.getString("name")) ;----看这里1
               System.out.println(rs.getInt("id")) ;         
               System.out.println(rs.getString("sex")) ;
        } 位置可是变了呀!怎么就不对了??????
      

  2.   

    那就select name,[id],sex,aa,bb from tt where aa=@p1 and bb=@p2呗,rs有这个毛病的
      

  3.   

    那就select name,[id],sex,aa,bb from tt where aa=@p1 and bb=@p2呗,
    rs有这个毛病的有什么毛病???