Suggestion: Instead, make this check:

if (rs.getMetaData() == null || rs.getMetaData().getColumnCount() == 1)