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个回答
网易云信
2023-12-06 广告
2023-12-06 广告
UIkit是一套轻量级、模块化且易于使用的开源UI组件库,由YOOtheme团队开发。它提供了丰富的界面元素,包括按钮、表单、表格、对话框、滑块、下拉菜单、选项卡等等,适用于各种类型的网站和应用程序。UIkit还支持响应式设计,可以根据不同...
点击进入详情页
本回答由网易云信提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询