急!!! 提示:java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态
NemoF 2005-07-15 08:43:31 源码:
<jsp:useBean id="List" class="guestbook.GuestBookJdbc" scope="page"/>
<%
String username = request.getParameter("username");
String pass = request.getParameter("pass");
if(username==null || "".equals(username) || pass==null || "".equals(pass)){
out.print("<script>alert('请完整填写表单!');history.back()</script>");
}else{
Connection Conn=List.GetConn();
Statement stmt=Conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String sql="select * from user where logonName = '"+username.trim()+"' and password = '"+pass.trim()+"'";
out.print(sql);
try{
ResultSet Rs=stmt.executeQuery(sql);
out.print(Rs.getRow());
/**/if(Rs.isAfterLast()){
out.print("<script>");
out.print("alert('用户名或密码出错!"+username+"|"+pass+"');");
out.print("window.location.href='index.htm';");
out.print("</script>");
}
else
{
int userId = Rs.getInt("id");
session.setAttribute("username",username);
session.setAttribute("userId",userId+"");
response.sendRedirect("main.htm");
}
}catch(Exception e)
{
out.print("<script>");
out.print("alert('用户名或密码出错!"+e.toString()+"');");
out.print("window.location.href='index.htm';");
out.print("</script>");
}finally {
Conn.close();
}
}
%>