This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
The SQL statement in your first attempt was better. Anf the while loop in your new attempt is better.
Your new SQL query is invalid. You did not give a table name. (you need to select <from table>). And if you write a where clause in your query (justl like you did in your first example), you only get records where the city is london, and you don't have to perform the extra check in the while loop.
And follow Paul's advise: close your resources after use, and use a PreparedStatement.