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

📄 loginaction.java

📁 java(Swing) access做的成绩管理系统
💻 JAVA
字号:
package edu.xscj.action;

import java.sql.*;
import edu.xscj.conn.ConnectDataBase;
import edu.xscj.bean.*;

public class LoginAction {
    /**
     * LoginAction
     */
    Connection conn = null;

    public LoginAction() {
        if (conn == null) {
            conn = ConnectDataBase.getConn();
        }
    }

    public int isAvailabe(Admin admin) {
        Statement stmt = null;
        ResultSet rst = null;
        String sql = "select * from admin where adminNo='" + admin.getAdminNo() +
                     "'";
        try {
            stmt = conn.createStatement();
            rst = stmt.executeQuery(sql);
            if (rst.next()) {
                String pwd = rst.getString("adminPwd");
                if (pwd.equals(admin.getAdminPwd())) {
                    return 1; //登录成功
                } else {
                    return 2; //密码错误
                }
            } else {
                return 3;
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
            return 4; //出错了
        } finally {
            try {
                if (rst != null) {
                    rst.close();
                }
                if (stmt != null) {
                    stmt.close();
                }
                if (conn != null) {
                    conn.close();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }

}

⌨️ 快捷键说明

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