You're iterating over two resultsets at the same time:
while (resultSet.next()) {
while (tables.next()) {
According to the error message, this is not allowed.
You could fix it by putting the result of the first iteration in a List<String> databaseNames
and then iterating over that list to list the tables.
Alternatively, if you're using SQL Server 2005, you might want to try enabling a feature in SQL Server called "Multiple Active Result Sets".