Those things should be more like keySet.addAll(queryResultSet);