<%
int Id=Integer.parseInt(rs.getString("id"));
out.print(Id);
%>
这段代码错了吗?
错误报告就是:Column index 2 is out of range.

解决方案 »

  1.   

    看下你的sql语句的结果集中有没有id这个字段,而且我觉得你调用 了rs.getString(2);
      

  2.   

    sql语句中有id这个字段,为什么说我调用了rs.getString(2)?
      

  3.   

    <%
    String sql="SELECT  path from image order by Id asc"; 
    ResultSet rs=stmt.executeQuery(sql);
    if(!rs.next()){
    out.print("<img src='error.gif'");
    }else{
    while(rs.next()){
    %>
    <div id="imagediv" style="height:150px;width:200px;filter:progid:DXImageTransform.Microsoft.BasicImage(0);">
      <IMG src="../uploadfile/<%=rs.getString("path")%>"width="600" border="0" align="middle" id="ye" style="zoom:1" title="点击查看下一张" onmousewheel="return bbimg(this)" onclick='this.src="1213165357671.gif"'></td></div>
    </tr>
    <%
    int Id=Integer.parseInt(rs.getString("Id"));
    out.print(Id);
    %>
    <tr>
    <td height="25">    
    <input type="button" name="shangzhang" value="上一张" onclick="javascript:window.open('showimage.jsp?Id=<%=Id-1%>','_self')">
    <input type="button" name="xiazhang" value="下一张" onclick="javascript:window.open('showimage.jsp?Id=<%=Id+1%>','_self')">
    <input type="button" name="fanhui" value="返回图片列表" onclick="location.href='show_image.jsp'">
    </td>
    </tr>
    </table>
    <%
    }
    %>
    <%
    }
    %>
    这就是.
      

  4.   

    String sql="SELECT  path from image order by Id asc"; 
    这里哪来的Id .............
      

  5.   

    你没有 select Id 这个字段, 不能 get 的
      

  6.   

    String sql="SELECT Id, path from image order by Id asc";