?? e0791f061419001e136682f9a6412c6b
字號:
package com.cric.onlineshopclothes.dao;
import java.sql.ResultSet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.cric.onlineshopclothes.javabean.Customer;
import com.cric.onlineshopclothes.util.DBUtils;
public class CustomerLoginDAO {
public Customer getLoginParam(HttpServletRequest request, HttpServletResponse response){
Customer customer=new Customer();
String customerLoginName=request.getParameter("userName");
String customerLoginPassword=request.getParameter("passWord");
customer.setCustomerName(customerLoginName);
customer.setCustomerPass(customerLoginPassword);
return customer;
}
public boolean checkLoginParam(Customer customer){
boolean flag=false;
//在數據庫中查找是否有匹配的用戶名和密碼
String strSql="select * from customer where customerName='"+customer.getCustomerName()+"' and customerPass='"+customer.getCustomerPass()+"'";
System.out.println(strSql);
DBUtils db=new DBUtils();
//返回結果集
ResultSet rs=db.excuteQuery(strSql);
try {
if(rs.next()){
flag=true;
}else{
flag=false;
}
} catch (Exception e) {
e.printStackTrace();
}
// System.out.print(flag);
return flag;
}
public int getUidByUname(String userName1){
String sqlStr="seletct *from customer where userName='"+userName1+"'";
DBUtils db=new DBUtils();
int uid=0;
try{
ResultSet rs=db.excuteQuery(sqlStr);
while(rs.next()){
uid=rs.getInt(1);
}
}catch (Exception e) {
e.printStackTrace();
}finally{
db.closeConnection();
}
return uid;
}
public Customer getUserByUid(int uid){
String sqlStr="seletct *from customer where Cid='+uid;" +
DBUtils db=new DBUtils();
Customer customer=new Customer();
try{
ResultSet rs=db.excuteQuery(strSql);
while(rs.next()){
customer.setCId(rs.getInt("uid"));//字段 名
customer.setCustomerPass(rs.getString(""));
customer.setCustomerName(rs.getString(""));
customer.setSex(rs.getString(""));
customer.setAddress(rs.getString(""));
customer.setEmail(rs.getString(""));
}
}catch (Exception e) {
e.printStackTrace();
}finally{
db.closeConnection();
}
return customer;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -