<%@page import="java.awt.Window"%>
<%@page import="beans.Account"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String account = new String(request.getParameter("account").getBytes("ISO-8859-1"),"UTF-8");
String password = new String(request.getParameter("password").getBytes("ISO-8859-1"),"UTF-8");
String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; //加载JDBC驱动
String dbURL = "jdbc:sqlserver://localhost:1433; DatabaseName=化妆品管理系统"; //连接服务器和数据库sample
String userName = "sa"; //默认用户名
String userPwd = "123456"; //密码
Connection conn;
Class.forName(driverName);
conn = DriverManager.getConnection(dbURL, userName, userPwd);
Statement stat = conn.createStatement();
String sql =
"select * FROM Login WHERE account ='"+ account +"'";
ResultSet result = stat.executeQuery(sql);
Account acount = new Account();
while (result.next()){
acount.setPassword(result.getString("password").trim());
acount.setName(result.getString("name").trim());
acount.setId(result.getString("id").trim());
}
out.println(acount.getId());
if(Integer.parseInt(password.trim())==Integer.parseInt(acount.getPassword().trim())){
out.print(acount.getId().trim()=="员工");
//{
// out.print("员工");
// }
// else if(acount.getId()=="管理员"){
// out.print("管理员");
// response.sendRedirect("customManage.jsp");
// }
// else if(acount.getId()=="顾客"){
// out.print("顾客");
// response.sendRedirect("index.jsp");
// }
}
else
out.print("WRONG");
result.close();
stat.close();
%>