?? loginlogicbean.java
字號:
package org.langsin.news.logic;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.langsin.news.comm.DataSource;
public class LoginLogicBean {
/**
* 驗證登陸的方法,如果用戶名和密碼全部正確返加OK
* 如果用戶名正確密碼不正確返回PWD
* 如果用戶名不存在,就沒有必要判斷密碼返加NOUSER
* @param userName
* @param userPwd
* @return
*/
public String verify(String userName, String userPwd) {
String result = null;
Connection conn = null;
Statement st = null;
ResultSet rs = null;
conn = DataSource.getConnection();
try {
st = conn.createStatement();
rs = st.executeQuery("select password from user where username='"
+ userName + "'");
if (rs.next()) {
if (userPwd.equals(rs.getString(1))) {
result = "OK";
} else {
result = "PWD";
}
} else {
result = "NOUSER";
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
if(rs!=null)rs.close();
if(st!=null)st.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return result;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -