📄 loginbean.java
字号:
package bookmanager;
import java.sql.ResultSet;
/**
* <p>Title: 图书管理</p>
*
* <p>Description: 大型软件实习项目</p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: 武汉大学计算机学院</p>
*
* @author 王佳
* @version 1.0
*/
public class LoginBean {
private String username;
private String password;
private String authority="";;
private ResultSet rs=null;
private long uid;
private String name="";;
public LoginBean(){
username="";
password="";
uid=0;
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();System.out.println("jbinit()");
}
}
//"fail"表示操作失败,“error”表示出现异常,“none”表示用户不存在,“allowed”表示允许登陆
public String execute(){
dbconnBean dbconnbean=new dbconnBean();
String sql="select * from bookuser where username=" + "'"+username+"'"
+"and password ="+"'"+password+"'";
try {
rs = dbconnbean.executeQuery(sql);
} catch (Exception ex) {
System.out.println("error");
return "error";
}
try {
if (rs.next()) {
uid = rs.getLong("uid");
name = rs.getString("name");
authority = rs.getString("authority");
return "allowed";
}
return "none";
} catch (Exception ex) {
ex.printStackTrace();
//System.out.println("none~~~~~~~~~~~~~~~~~");
}
return "fail";
}
//Access sample property
public String getUsername() {
return username;
}
public String getPassword() {
return password;
}
public String getAuthority() {
return authority;
}
public long getUid() {
return uid;
} //Access sample property
public String getName() {
return name;
}
public void setUsername(String username) {
this.username = username;
}
public void setPassword(String password) {
this.password = password;
}
public void setAuthority(String authority) {
this.authority = authority;
}
public void setUid(long uid) {
this.uid = uid;
}
public void setName(String name) {
this.name = name;
}
private void jbInit() throws Exception {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -