Java SQL ResultSet to resultSetToSet(PreparedStatement statement)

Here you can find the source of resultSetToSet(PreparedStatement statement)

Description

result Set To Set

License

Open Source License

Declaration

public static Set<String> resultSetToSet(PreparedStatement statement) throws SQLException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import java.util.HashSet;

import java.util.Set;

public class Main {
    public static Set<String> resultSetToSet(PreparedStatement statement) throws SQLException {
        ResultSet results = statement.executeQuery();
        try {/*from w w w  .  ja  v a  2 s. co m*/
            Set<String> strings = new HashSet<String>();
            while (results.next()) {
                strings.add(results.getString(1));
            }
            return strings;
        } finally {
            statement.close();
        }
    }
}

Related

  1. resultSetToArrayList(ResultSet rs)
  2. resultSetToHtmlTable(java.sql.ResultSet rs)
  3. resultSetToMap(Map mappedValues, java.sql.ResultSet rs, int key, int value)
  4. resultSetToMap(Map mappedValues, ResultSet rs)
  5. resultSetToOrderedMap(ResultSet rs)
  6. resultSetToString(ResultSet resultSet)
  7. resultSetToString(ResultSet resultSet)
  8. resultSetToXML(ResultSet rs)
  9. toArrayList(ResultSet rs)