public User findUser(String uName,String uPass) {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "select * from TBL_USER where uName=? and uPass = uPass";
User user = null;
try {
conn = this.getConn();
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, uName);
rs = pstmt.executeQuery();
while( rs.next() ) {
user = new User();
user.setUName( rs.getString("uName") );
user.setUPass( rs.getString("uPass") );
}
} catch (Exception e) {
e.printStackTrace();
} finally {try{
if(rs != null)rs.close()} catch (Exception e) {
} finally {try{
if(pstmt != null)pstmt.close()}catch (Exception e) {
e.printStackTrace();
} finally {try{
if(conn != null)conn.close()}catch(SQLException e){ conn.close();}
}
return user;
}
user是否为空来判断是否登陆成功