⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 customerlogindao.java

📁 网上购物系统
💻 JAVA
字号:
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+"'";
	  System.out.println(sqlStr);
	  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(sqlStr);
		  while(rs.next()){
			  customer.setCId(rs.getInt("CId"));//字段 名 
			  customer.setCustomerPass(rs.getString("customerPass"));
			  customer.setCustomerName(rs.getString("customerName"));
			  customer.setSex(rs.getString("sex"));
			  customer.setAddress(rs.getString("address"));
			  customer.setEmail(rs.getString("email"));
			  customer.setContact(rs.getString("contact"));
		  }
				  
	  }catch (Exception e) {
			e.printStackTrace();
			
	   }finally{
		  db.closeConnection();
	  }
	  return customer;
  }

}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -