int i;
//i赋值
CallableStatement proc;
try {
        proc = connection.prepareCall("{call sp_hlr_sync(?,?,?)}");
        proc.setInt(1,i);
        proc.registerOutParameter(2,OracleTypes.NUMBER);
        proc.registerOutParameter(3,OracleTypes.VARCHAR);
               if(proc.execute())
                System.out.print("yes");
                while(rs2.next())
      
        int a1=proc.getInt(2);
        String a2=proc.getString(3);
        System.out.print(a1+"|"+a2);
        } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
}

解决方案 »

  1.   

    //
    if(proc.execute())
                    System.out.print("yes");
                    while(rs2.next())
    //
    while(rs2.next())删去!
      

  2.   

    重发:
    int i;
    //i赋值
    CallableStatement proc;
    try {
            proc = connection.prepareCall("{call sp_hlr_sync(?,?,?)}");
            proc.setInt(1,i);
            proc.registerOutParameter(2,OracleTypes.NUMBER);
            proc.registerOutParameter(3,OracleTypes.VARCHAR);
            proc.execute();
                                          
            int a1=proc.getInt(2);
            String a2=proc.getString(3);
            System.out.print(a1+"|"+a2);
            } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
    }
      

  3.   

    private static String getContent(String startDate, String endDate) throws
          DAOException {
        DBconn db = null;
        String sql = null;
        ResultSet rs = null;
        Connection con = null;
        CallableStatement call = null;
        try {
          db = new DBconn();
          con = db.getConnection();
          call = con.prepareCall("call p_dtsgdttj_getsql(?,?,?)");
          call.registerOutParameter(3, java.sql.Types.VARCHAR);
          call.setString(1, startDate);
          call.setString(2, endDate);
          rs = call.executeQuery();
          sql = call.getString(3);
        }
        catch (ConnectionException e) {
          throw new DAOException(e, "统计报表失败!");
        }
        catch (SQLException e) {
          throw new DAOException(e);
        }
        finally {
          if (rs != null) {
            try {
              rs.close(); //关闭结果集
            }
            catch (Exception e) {
              e.printStackTrace();
            }
          }
          if (call != null) {
            try {
              call.close();
            }
            catch (Exception e) {
              e.printStackTrace();
            }
          }
          if (con != null) {
            try {
              con.close(); //关闭连接
            }
            catch (Exception e) {
              e.printStackTrace();
            }
          }
        }
        return sql;
      }
    }