www.pudn.com > liberSystem.rar > LoginService.java, change:2012-06-06,size:1147b


package com.ccl.service; 
 
import java.sql.Connection; 
 
import com.ccl.domin.Operator; 
import com.ccl.util.ConnectionFactory; 
import com.ccl.util.ConnectionUtil; 
import com.ccl.util.JdbcUtil; 
 
public class LoginService { 
	 
	/** 
	 * 校验用户名密码是否一致 
	 * @param username 
	 * @param password 
	 * @return 
	 */ 
	public boolean validateAdminLogin(String username,String password){ 
		Connection conn=ConnectionFactory.getConnection(); 
		Operator o=(Operator) JdbcUtil.queryOne(new Operator(),"select * from operator_t where name=? and password =?", new Object[]{username,password}, conn); 
		ConnectionUtil.close(conn); 
		if(o==null) 
			return false; 
		else  
			return true; 
	}  
	 
	/** 
	 * 从数据库中根据指定的用户名获取一个管理员对象,该用户名必须存在 
	 * @param username 
	 * @return 
	 */ 
	public Operator getAdminLogin(String username){ 
		Connection conn=ConnectionFactory.getConnection(); 
		Operator o=(Operator) JdbcUtil.queryOne(new Operator(),"select * from operator_t where name=?", new Object[]{username}, conn); 
		ConnectionUtil.close(conn); 
		return o; 
	} 
	 
}