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

📄 a0ef25af8f41001c1778f36733325fc6

📁 是一个网上手机超市
💻
字号:
package hall;

import java.util.*;
import java.sql.*;

public class login{
        private String username;	//登录用户名
        private String passwd;		//登录密码
        private DBWrapper myConnection = null;
        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;
        }
        
        /**
         * 执行查询
         * @return
         * @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 name = '" +
                username + "' and password = '" +
                passwd + "'";
                try{
                	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;
                }catch(Exception e){
                	System.out.println(e);
                	return 3;
                }
                
                
        }
};

⌨️ 快捷键说明

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