<%@page import=”java.beans.Statement”%>
<%@ page language=”java” import=”java.sql.*,java.util.*,” pageEncoding=”gb2312″%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;
%>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<base href=”<%=basePath%>”>
<title>My JSP “”loginCl.jsp”” starting page</title>
<meta http-equiv=”pragma” content=”no-cache”>
<meta http-equiv=”cache-control” content=”no-cache”>
<meta http-equiv=”expires” content=”0″>
<meta http-equiv=”keywords” content=”keyword1,keyword2,keyword3″>
<meta http-equiv=”description” content=”This is my page”>
<!–
<link rel=”stylesheet” type=”text/css” href=”styles.css”>
–>
</head>
<body>
<%
//接收用户名和密码,完成对用户的验证
String u=request.getParameter(“username”);
String p=request.getParameter(“passwd”);
//到数据库中验证用户
//1.加载驱动
Class.forName(“com.microsofr.jdbc.sqlserver.SQLServerDriver”);
//2.得到链接
Connection ct=DriverManager.getConnection(“jdbc:microsoft:sqlserver://127.0.0.1:1433;databaseName=ManagementSystem”,”sa”,”HXHhxh1206″);
//3.创建Statement
Statement sm=ct.createStatement();
[color=#000000]这个出现以下问题,已经有导入java.sql.*包了,求解释[/color]
Type mismatch: cannot convert from java.sql.Statement to java.beans.Statement
//4.查询
ResultSet rs=sm.executeQuery(“select passed from admin where username=”””+u+””””);
[color=#000000]可能是上个问题出现,所以导致这个也出现问题,求解释[/color]
Type mismatch: cannot convert from java.sql.Statement to java.beans.Statement
//5.执行,根据结果判断
if(rs.next()){
//说明用户名存在
if(rs.getString(1).equals(p))
{
//一定合法
response.sendRedirect(“wel.jsp?user=”+u);
}else{
//密码错误
response.sendRedirect(“login.jsp”);
}
}else{
response.sendRedirect(“login.jsp”);
}
%>
</body>
</html>