www.pudn.com > restrant.zip > AdminDao.java, change:2013-12-21,size:1068b


package com.alex.restrantol.dao; 
 
import java.sql.Connection; 
import java.sql.PreparedStatement; 
import java.sql.ResultSet; 
 
import com.alex.restrantol.base.BaseDao; 
import com.alex.restrantol.entity.AdminEntity; 
 
public class AdminDao { 
	Connection con; 
	PreparedStatement ps; 
	ResultSet rs; 
	 
	public AdminEntity findAdminIsExist(String aname,String apwd) { 
		AdminEntity adminEntity=null; 
		try { 
			con=new BaseDao().getConn(); 
			ps=con.prepareStatement("select AdminId,LoginName,LoginPwd,Purview from Admin where LoginName=? and LoginPwd=?"); 
			ps.setString(1, aname); 
			ps.setString(2, apwd); 
			rs=ps.executeQuery(); 
			if(rs.next()){ 
				adminEntity=new AdminEntity(); 
				adminEntity.setAdminId(rs.getInt("id")); 
				adminEntity.setAdminName(rs.getString("username")); 
				adminEntity.setAdminPwd(rs.getString("password")); 
				if(rs.getInt("isSuper")==1) 
					adminEntity.setSuper(true); 
				else 
					adminEntity.setSuper(false); 
			} 
		} catch (Exception e) { 
			e.printStackTrace(); 
		} 
		return adminEntity; 
	} 
}