?? login.java
字號:
package hall;
/**
* Project: NWPU online shop
* JDK version used: jdk1.5.0
* Version: 1.01
* class login 用來處理關(guān)于用戶的登陸問題
*/
import java.sql.*;
public class login{
private String username; //登錄用戶名
private String passwd; //登錄密碼
private DBWrapper myConnection = null;//數(shù)據(jù)庫連接和操作
private String sqlStr;
public login() throws Exception{
username = "";
passwd = "";
myConnection = DBWrapper.Instance();
sqlStr = "";
}
public String getUsername() {
return username;
}
public void setUsername(String newusername) {
username = newusername;
}
public String getPasswd() {
return passwd;
}
public void setPasswd(String newpasswd) {
passwd = newpasswd;
}
/**
* int excute()
* 執(zhí)行查詢,1代表此用戶名是管理員在使用的,2代表此用戶名是顧客在使用的,3代表此用戶名沒有被使用
* @return int
* @throws java.lang.Exception
*/
public int excute() throws Exception {
int flag = 3;//1 represents admin,2 represents customer,3 represents that the use isn't exsited
sqlStr = "select * from administrators where username = '" +
username + "' and password = '" +
passwd + "'";
ResultSet rs = myConnection.runQuery(sqlStr);
if (rs.next()){
flag = 1;
}
else{
sqlStr = "select * from customers where name = '" +
username + "' and password = '" +
passwd + "'";
rs = myConnection.runQuery(sqlStr);
if(rs.next()){
flag = 2;
}
else{
flag = 3;
}
}
rs.close();
return flag;
}
};
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -