加这句后就出现问题了:
String aStr="";
aStr=rs_anything.getString(3);javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Column index 3 is out of range.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.anything_jsp._jspService(anything_jsp.java:256)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Column index 3 is out of range.
com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.base.BaseResultSet.validateColumnIndex(Unknown Source)
com.microsoft.jdbc.base.BaseResultSet.getString(Unknown Source)
org.apache.jsp.anything_jsp._jspService(anything_jsp.java:185)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

解决方案 »

  1.   

    你数据库里的字段只有两个,你想得到第三个的时候,报"Column index 3 is out of range."越界了.
    分拿来.呵呵。
      

  2.   

    这个问题挺明显的~rs_anything.getString(3);但是表里并没有第3个字段!就报出超出范围的错误了
      

  3.   

    rs_anything.getString(2);要不就增加个字段吧
      

  4.   

    你把查询的语句跟你要读取的字段比较一下,看是不是相同,
    还有就是你可以直接把数据库中的字段拿出来读也可以获取值的。
    如:rs = stat.executeQuery("select a,b,c from tab");
    String aStr = rs.getString("c");
    你可以试试,功能是一样的。
      

  5.   

    String aStr="";
    aStr=rs_anything.getString(3);
    数据库里没有第三个字段,应该是你要查询的返回值。在数据库里加上!
      

  6.   

    我有第三个字段啊,第三个字段是aContent,类型是text
    改成
    String aStr="";
    aStr=rs_anything.getString("aContent");
    也不行,所以才郁闷
      

  7.   

    把你的sql贴出来吧,不然没有说服力
      

  8.   

    终于搞明白了,原来是SQL语句漏了aContent,虽然数据库有,但没有查询到,谢谢各位啊