ResultSet rs=stmt.executeQuery(sql);出错,可是我查不出来是哪里的错啊
<%@pagelanguage="java"import="java.util.*"pageEncoding="gb2312"%><!DOCTYPEHTMLPUBLIC"...
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<jsp:useBean id="stmt" class="com.jdbc.DBHandler" scope="session"/>
<% String lname="",
lpwd="",
usertype="",
name="",
tpwd="",
sql="";
int lid=0;
lname=request.getParameter("lname");
lpwd=request.getParameter("lpwd");
usertype=request.getParameter("usertype");
if(usertype.equals("user"))
{
sql="select * from member where mname='"+lname+"'";
}
ResultSet rs=stmt.executeQuery(sql);
int rowcount=0;
while(rs.next())
{
rowcount++;
if(usertype.equals("users"))
{
lid=rs.getInt("id");
lname=rs.getString("mname");
tpwd=rs.getString("mpwd");
name=rs.getString("name");
}
}
if((rowcount==1)&&(tpwd.equals(lpwd)))
{
if(usertype.equals("user"))
{
session.setAttribute("id",lid);
session.setAttribute("username",lname);
session.setAttribute("name",name);
session.setAttribute("usertype",usertype);
response.sendRedirect("index.jsp");
}
}
else
{
out.println("登录失败!用户名或密码错误,请重新<a href=\"index.jsp\"target=\"_top\">登录</a>");
}
%>
</head>
<body>
</body>
</html> 展开
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<jsp:useBean id="stmt" class="com.jdbc.DBHandler" scope="session"/>
<% String lname="",
lpwd="",
usertype="",
name="",
tpwd="",
sql="";
int lid=0;
lname=request.getParameter("lname");
lpwd=request.getParameter("lpwd");
usertype=request.getParameter("usertype");
if(usertype.equals("user"))
{
sql="select * from member where mname='"+lname+"'";
}
ResultSet rs=stmt.executeQuery(sql);
int rowcount=0;
while(rs.next())
{
rowcount++;
if(usertype.equals("users"))
{
lid=rs.getInt("id");
lname=rs.getString("mname");
tpwd=rs.getString("mpwd");
name=rs.getString("name");
}
}
if((rowcount==1)&&(tpwd.equals(lpwd)))
{
if(usertype.equals("user"))
{
session.setAttribute("id",lid);
session.setAttribute("username",lname);
session.setAttribute("name",name);
session.setAttribute("usertype",usertype);
response.sendRedirect("index.jsp");
}
}
else
{
out.println("登录失败!用户名或密码错误,请重新<a href=\"index.jsp\"target=\"_top\">登录</a>");
}
%>
</head>
<body>
</body>
</html> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询