?? customer.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 + -