login.java~2~
资源名称:bookshop.zip [点击查看]
上传用户:sxlinghang
上传日期:2022-07-20
资源大小:1405k
文件大小:2k
源码类别:
数据库编程
开发平台:
Java
- package bookshop.run;
- /**
- * <p>Title: </p>
- * <p>Description: </p>
- * <p>Copyright: Copyright (c) 2004</p>
- * <p>Company: </p>
- * @author not attributable
- * @version 1.0
- */
- import bookshop.util.*;
- public class login extends DataBase {
- private String username; //登录用户名
- private String passwd; //登录密码
- private boolean isadmin; //是否管理员登录
- private long userid=0; //用户ID号
- public login() throws Exception{
- super();
- username = "";
- passwd = "";
- isadmin = false;
- }
- public String getUsername() {
- return username;
- }
- public void setUsername(String newusername) {
- username = newusername;
- }
- public String getPasswd() {
- return passwd;
- }
- public void setPasswd(String newpasswd) {
- passwd = newpasswd;
- }
- public boolean getIsadmin() {
- return isadmin;
- }
- public void setIsadmin(boolean newIsadmin) {
- isadmin = newIsadmin;
- }
- public long getUserid() {
- return userid;
- }
- public void setUserid (long uid) {
- userid = uid;
- }
- public String getSql() {
- if (isadmin) {
- sqlStr = "select * from my_BookAdminuser where adminuser = '" + dataFormat.toSql(username) + "' and adminpass = '" + strFormat.toSql(passwd) + "'";
- }else {
- sqlStr = "select * from my_users where username = '" + dataFormat.toSql(username) + "' and password = '" + strFormat.toSql(passwd) + "'";
- }
- return sqlStr;
- }
- public boolean excute() throws Exception {
- boolean flag = false;
- rs = stmt.executeQuery(getSql());
- if (rs.next()){
- if (!isadmin)
- {
- userid = rs.getLong("id");
- }
- flag = true;
- }
- rs.close();
- close();
- return flag;
- }
- };