It's not related to your question - but why are you using an int as a flag? This is
Java - it's got a boolean type for that sort of thing.
Swastik's right, though. It's much better to query exactly the record you need than it is to get all the users and loop round all of them.
(Edit: by the way, the reason your code is formatted poorly is that you're using a mixture of tabs and spaces. I'd recommend switching to using spaces all the time. A couple of the lines also had a huge number of spaces at the end of them, which was why it was messing up the page width here. I've removed them to stop that happening).