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

📄 mlogin.java

📁 一个人才简历资源中心系统
💻 JAVA
字号:
/*
 * This product includes software developed by the
 * Apache Software Foundation (http://www.apache.org/).
 */
package ch06.module;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.*;

import javax.servlet.http.HttpSession;

import ch06.*;

/**
 * 针对登录页面的后台处理类
 * @author ShenYK
 * @version 1.0
 */
public class MLogin extends MCommon
{
    public boolean getUserInfo ( HttpSession mySession, 
    		                       String username, 
    		                       String password )
    {
        //设置用户信息
        Hashtable myValues = (Hashtable)mySession.getAttribute(CommonConst.VIEWID_LOGIN);
        myValues.put("username", username);
        
        //获得数据库连接
        Connection conn = this.getDBConnection( mySession );
        if ( conn == null )
        {
            return false;
        }
        Statement stmt = null;
        ResultSet rs = null;
        
        try
        {
            //检查数据库中是否已经有该用户了
            stmt = conn.createStatement();
            //执行SQL语句
            String sQuery = "select realname from user "
                          + "where username='" + username + "' "
                          + "and password='" + password +"'";
            rs = stmt.executeQuery( sQuery );
            if ( rs.next() )
            {
                mySession.setAttribute("username",username);
                mySession.setAttribute("realname",rs.getString(1) );
                
                //获取用户设置
                sQuery = "select count_per_page from setting where username='" + username + "'";
                rs = stmt.executeQuery( sQuery );
                if ( rs.next() )
                {
                    mySession.setAttribute( "countPerPage", new Integer(rs.getInt(1)) );
                }
                else
                {
                    //默认每页10条
                    mySession.setAttribute( "countPerPage", new Integer(10) );
                }
                return true;
            }
            else
            {
                mySession.setAttribute("errMsg","用户名密码不正确!");
                return false;
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
            mySession.setAttribute("errMsg","出现错误,请联系技术人员!");
            return false;
        }
        finally
        {
            try
            {
                rs.close();
                stmt.close();
                conn.close();
            }catch(Exception ex)
            {
            }
        }
    }
}

⌨️ 快捷键说明

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