📄 mlogin.java
字号:
/**
*
*/
package webMail.module;
/**
* 引用数据库连接包
*/
import webMail.DBCommon;
import java.sql.*;
import javax.servlet.http.HttpSession;
/**
* @author up
*
*/
public class MLogin
{
public Statement stmt = null;
public ResultSet rs = null;
public Connection conn = null;
public boolean GetUserInfo(
HttpSession mySession,
String username,
String password
)
{
try
{
conn=DBCommon.getDBConnection();
stmt = conn.createStatement();
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) );
return true;
}
else
{
mySession.setAttribute("errMsg","用户名密码不正确!");
return false;
}
}
catch(Exception ex)
{
ex.printStackTrace();
return false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -