jsp:SQLException: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态 ,怎么解决?
文件名:show.jsp 环境:myelcipse
实现功能:把数据表jsp的内容全部显示在页面上
结果只有一行: id: quest: answer:
console里面的错误提示为:SQLException: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态
我真不知道什么问题。。请指点。谢谢!
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="gb2312"%>
<body>
<%
try {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(ClassNotFoundException e)
{out.println("loading jdbc-odbc error!:"+e.getMessage());}
try{
Connection conn= DriverManager.getConnection("jdbc:odbc:jspConsultation");
Statement stmt=conn.createStatement();
String sql="select *from jsp";//jsp是一个表名
ResultSet rs=stmt.executeQuery(sql);
out.println("<table border='1'>");
out.println("<tr>");
out.println("<th width=30>"+"id:");
out.println("<th width=30>"+"quest:");
out.println("<th width=30>"+"answer:");
out.println("</th>");
while(rs.next());
{
out.println("<tr>");
out.println("<td>"+rs.getString(1)+"</td>");
out.println("<td>"+rs.getString(2)+"</td>");
out.println("<td>"+rs.getString(3)+"</td>");
out.println("</tr>");
}
out.println("</table>");
rs.close();
stmt.close();
conn.close();
}
catch(SQLException ex){ System.err.println("SQLException: " + ex.getMessage()); }
%>
</body>
</html>