日期:2014-05-18  浏览次数:20862 次

JSP连接MSSQL2000数据库碰到的问题,
最近搞课程设计遇到了一些问题.JSP做的一个文章管理系统.
Tomcat+MSSQL2000+JSP+windowsXP
源代码如下:
<%
    String   id=(String)request.getParameter( "id ");
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");   //载入驱动程序类别
    Connection   con   =   DriverManager.getConnection( "jdbc:odbc:firm ");   //建立数据库链接,jspdata为ODBC数据源名称
//建立Statement对象
    Statement   stmt   =   con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet   rs   =   stmt.executeQuery( "select   *   from   article   where   id= "+id);   //建立ResultSet(结果集)对象,并执行SQL语句
rs.next();//移动游标
%>
<table   width= "780 "   height= "462 "   align= "center "   cellpadding= "0 "   cellspacing= "0 ">
<TR>
<td   width= "152 "   height= "460 "   valign= "top "> &nbsp; </td>
<td   width= "643 "   valign= "top ">
          <table   width= "493 "   height= "135 "   border= "0 "   align= "center "   cellpadding= "0 "   cellspacing= "0 ">
              <tr>
                  <td   height= "20 "   colspan= "3 ">
                      标题:
                        <%=rs.getString( "subject ")%>   </td>
              </tr>
              <tr>
                  <td   width= "237 "   height= "14 "   valign= "top "> 作者:   <%=rs.getString( "author ")%>   </td>
                  <td   width= "131 "   height= "14 "   valign= "top "> 出处:   <%=rs.getString( "source ")%>   </td>
                  <td   width= "131 "   valign= "top "> 文章类型:   <%=rs.getString( "type ")%>   </td>
              </tr>
              <tr>
                  <td   colspan= "3 "   valign= "top "> 内容:   <%=rs.getString( "context ")%> </td>
              </tr>
          </table>
  </tr>
</table>
<%
rs.close();
stmt.close();
con.close();
%>

报错如下:
javax.servlet.ServletException:   [Microsoft][ODBC   SQL   Server   Driver]无效的描述符索引
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageConte