means.java~4~

来自「一个Java编写的挺不错的人事管理系统」· JAVA~4~ 代码 · 共 58 行

JAVA~4~
58
字号
package work;

import java.sql.*;

public class Means {
    public Means() {
    }


    public boolean login(String username, String password) {
        Connection con = null;
        PreparedStatement st = null;
        ResultSet rs = null;
        Conn c = new Conn();
        try {
            con = c.getcon();
            st = con.prepareStatement(
                    "select * from userInfo where name=? and password=?");
            st.setString(1, username);
            st.setString(2, password);
            rs = st.executeQuery();
            if (rs.next()) {
                return true;
            } else {
                return false;
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return false;
    }

    public UserBean userinfo() {
        Connection con = null;
        PreparedStatement st = null;
        ResultSet rs = null;
        Conn c = new Conn();
        UserBean u = new UserBean();
        con = c.getcon();
        try {
            st = con.prepareStatement("select * from userInfo");
            rs = st.executeQuery();
            if (rs != null) {
                u.setName(rs.getString(1));
                u.setPassword(rs.getString(2));
                u.setType(rs.getString(3));
                return u;
            } else {
                return null;
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return null;

    }
}

⌨️ 快捷键说明

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