Java SQL ResultSet Read getArrayAsSet(ResultSet rs, String columnLabel)

Here you can find the source of getArrayAsSet(ResultSet rs, String columnLabel)

Description

Returns a string set for the given result set and column.

License

Open Source License

Parameter

Parameter Description
rs the result set.
columnLabel the column label.

Return

a string set.

Declaration

public static Set<String> getArrayAsSet(ResultSet rs, String columnLabel) throws SQLException 

Method Source Code


//package com.java2s;
import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Set;

import com.google.common.collect.Sets;

public class Main {
    /**/*from   www .j ava  2 s.c o  m*/
     * Returns a string set for the given result set and column. Assumes
     * that the SQL type is an array of text values.
     *
     * @param rs the result set.
     * @param columnLabel the column label.
     * @return a string set.
     */
    public static Set<String> getArrayAsSet(ResultSet rs, String columnLabel) throws SQLException {
        Array sqlArray = rs.getArray(columnLabel);
        String[] array = (String[]) sqlArray.getArray();
        return Sets.newHashSet(array);
    }
}

Related

  1. getAllRow(ResultSet rs)
  2. getAllValueMaps(ResultSet input)
  3. getArray(ResultSet resultSet, String columnLabel, Class clazz)
  4. getArray(ResultSet rs, int index)
  5. getArray(ResultSet rs, String columnName, Class cls)
  6. getArrayFromResultSet(ResultSet rs, String field)
  7. getAsString(ResultSet res, String field)
  8. getBestRowId(String schema, String tableName, int scope, String nullable, ResultSet[] rs)
  9. getBigInteger(ResultSet resultSet, int columnIndex)