//验证用户名和密码是否正确。当前用户名,密码和库中的对比。
public boolean validate(User user){
Connection conn = null;
PreparedStatement ppst = null;
ResultSet rs = null;
try{
conn = DAOUtil.getConnection();
ppst = conn.prepareStatement("select * from user where nickname=? and password=?");
//
ppst.setString(1, nickname);
rs = ppst.executeQuery();//
while(rs.next()){
return true;
}
}
catch(SQLException e){e.printStackTrace();}
finally{
try{
if(rs!=null){rs.close();}
if(ppst!=null){ppst.close();}
if(conn!=null){conn.close();}
}
catch(SQLException e){e.printStackTrace();}
}return false;
}