首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

一个简单的jsp 页面 [Microsoft][ODBC 驱动程序管理器] 无效的游标状态 多谢

2012-12-15 
一个简单的jsp 页面 [Microsoft][ODBC 驱动程序管理器] 无效的游标状态 谢谢代码如下:有用的只有中间那段:

一个简单的jsp 页面 [Microsoft][ODBC 驱动程序管理器] 无效的游标状态 谢谢
代码如下:有用的只有中间那段:
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@page import="java.sql.*"%>
<% request.setCharacterEncoding("gbk"); %>

<html> 
  <head>
   <title>My JSP 'main1.jsp' starting page</title>
 </head>
  <body  >
  
  <%
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String strSQL = "";

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException ce){
out.println(ce.getMessage());
}

%>
  
  
  <br>
  <table width="827" border="1" align="center">
    <tr>
      <td width="817" height="52" colspan="3"></td>    
    </tr>
  </table>
   <table width="827" border="1" align="center">
    <tr>
      <td width="817" height="174" colspan="3"> </td>
    </tr>
  </table>
 <table width="832" border="1" align="center" >
    <tr >
      <td width="270" height="532" valign="top"><div align="left"><a href="classly.jsp" class="STYLE1">留言板</a> <a href="classly.jsp">more</a></div>
      <p> </p>


<%   try{
     conn=DriverManager.getConnection("jdbc:odbc:liu1");
    stmt=conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);

     strSQL = "SELECT * FROM classly";
         rs = stmt.executeQuery(strSQL);
    for(int i=1; i<=2; i++)
       {
     out.print(rs.getString("sno"));

     out.println(rs.getString("title"));

if(!rs.next()) break;
    }
     }
       catch(SQLException e){
    System.out.println(e.getMessage());
    }
    finally{
    rs.close();
stmt.close();
conn.close();
    } %>
      
      
      
      
      
      
      </td>
   <td width="270" height="532">       </td>
    <td width="270" height="532">       </td>
    </tr>
  </table>
    <table width="828" border="0"align="center" background="11111.jpg">
    <tr>


      <td width="818"  height="249" colspan="3"> </td>
    </tr>
   </table>
  </body>
</html>


数据库连接没有问题,我用的accsee,表里面有5条语句,select语句在数据库里可以正确的查询,我希望在表格中显示几条语句,但是页面上显示不出,myeclipse提示 [Microsoft][ODBC 驱动程序管理器] 无效的游标状态 谢谢各位高手帮忙~~
[解决办法]
我已经忘了当初是怎么解决的,应该是少了一句:
if(rs.next()) 吧~

热点排行