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

📄 customer.java

📁 一个完整的网上书店
💻 JAVA
字号:
package com.ascenttech.ebookstore.bean;
import java.sql.*;
import java.util.*;

import com.ascenttech.ebookstore.util.DataAccess;

public class Customer {

    //data
    private int custId ;  // only to get uid
    private String user;
    private String password;
    private String name;
    private String title;  // values F: for female ; M: for male.
    private String email;

    private boolean checkin = false;

      
    //method
    public Customer() {
    }
    //getXXX/setXXX(){}
    public int getCustid(){ return custId;}
    public String getUser() { return user;}
    public String getPassword(){return password;}
    public String getName() {return name;}
    public String getTitle(){return title;}
    public String getEmail() {return email;}
    public boolean getCheckin() {return this.checkin;}
    public void setCustid(int cid){this.custId = cid;}
    public void setUser(String user){this.user = user;}
    public void setPassword(String password){this.password = password;}
    public void setName(String name){this.name = name;}
    public void setTitle(String title){this.title = title;}
    public void setEmail(String email){this.email = email;}
    public void setCheckin(boolean checkin){this.checkin = checkin;}

    public void newCustomer(){}
 
    public boolean login(String user, String password) throws SQLException {
          boolean succ = false;
          Connection con = DataAccess.getConnection();
          String sql = "select * from ebs_customer where user='"
                       + user+"' AND password ='"
                       + password+"'";
          Statement stmt = con.createStatement();

          ResultSet rs = stmt.executeQuery(sql);
          while (rs.next()){
            succ = true;;
          }
          rs.close();
          stmt.close();
          con.close();
          return succ;

    }

    public void saveInfo() throws Exception {
		    Connection con = DataAccess.getConnection();
		    String sqlStr = "insert into ebs_customer "
		                    + "  values(" + this.getCustid()+","
		                                  + "'"+this.getUser()+"',"
		                                  + "'"+this.getPassword()+"',"
		                                  + "'"+this.getName()+"',"
		                                  + "'"+this.getTitle()+"',"
		                                  + "'"+this.getEmail()+"'" +
		                                  " )";
		    Statement stmt = con.createStatement();
		    stmt.executeUpdate(sqlStr);
		    stmt.close();
		    con.close();
		

    }

    public boolean logOut(){ return false;}
        
}

⌨️ 快捷键说明

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