你查询用的column号码有问题,你的表只有一个字段吗?怎么连2都会超出范围呢?

解决方案 »

  1.   

    This problem occurs when all the following conditions are true:• The Select Transact-SQL statement that is used to retrieve the data from the SQL Server tables to the ResultSet object contains a JOIN between different tables in the SQL Server database. 
    • The Select Transact-SQL statement uses asterisk (*) to retrieve all fields from the respective tables. 
      

  2.   

    那个系统用户表里七个字段,我检查系统用户的用户名和密码是否匹配(调用存储过程),若匹配则显示登陆成功,反之则显示该用户不存在.主要代码段如下:
    String SysuserID=request.getParameter("SysuserID");
    String pwd=request.getParameter("Password");if(SysuserID.length()==0)
    out.println("<p align=center>错误用户</p>");
    else {
       try{
    strSql="{call dbo.sp_CheckSysuser(?,?)}";
    cstmt=conn.prepareCall(strSql);
    cstmt.setString(1,SysuserID);
    cstmt.setString(2,pwd); rs=cstmt.executeQuery(); if(rs.next()){
    session.putValue("sysuser",SysuserID);
    String tmp=new String(rs.getString(2).getBytes("8859_1"),"gb2312");
    session.putValue("sysuserType",tmp);
    %>
    <jsp:forward page="SysuserInfo.jsp?action=mine"/>
    <%
    }
    else {
    session.invalidate();
    out.println("<p align=center>帐号检测失败!请重试.</p>");
    }
    }
    catch(SQLException sqe) 
    {
    sqe.printStackTrace();
    out.println(sqe.getMessage());
    }
    catch(Exception e) 
    {
    e.printStackTrace();
    out.println(e.getMessage());
    }
    finally{
    rs.close();
    cstmt.close();
    conn.close();
    }
    }
    %>
      

  3.   

    String tmp=new String(rs.getString(2).getBytes("8859_1"),"gb2312");
    session.putValue("sysuserType",tmp);这时的rs里面是你执行存储过程的结果,很可能只有一列,即一个布尔值。但看你的意思,好像是要从原来的用户表里查出type,那么你需要再作一次查询,而不是用这个只有一列的rs。