Java SQL ResultSet Int Read getIntegers(ResultSet rs, String column)

Here you can find the source of getIntegers(ResultSet rs, String column)

Description

get Integers

License

Apache License

Declaration

public static List<Integer> getIntegers(ResultSet rs, String column) throws SQLException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.*;
import java.util.*;
import java.util.stream.*;
import static java.util.Arrays.*;
import static java.util.stream.Collectors.*;

public class Main {
    public static List<Integer> getIntegers(ResultSet rs, String column) throws SQLException {
        Object array = rs.getArray(column).getArray();
        if (array instanceof Integer[])
            return asList((Integer[]) array);
        else if (array instanceof Number[])
            return Stream.of((Number[]) array).map(Number::intValue).collect(toList());
        else// w  w w.j a v a  2 s  .  com
            throw new IllegalArgumentException("Incompatible type with Integer[]: " + array.getClass());
    }
}

Related

  1. getInteger(ResultSet rs, String strColName)
  2. getInteger(ResultSet s, int idx)
  3. getIntegerFromResultSet(ResultSet rs, String db_name)
  4. getIntegerList(ResultSet resultSet, String columnName)
  5. getIntegerNotZeroNotMinValue(ResultSet rs, String columnLabel)
  6. getIntegerValue(ResultSet resultSet, String columnName)
  7. getIntegerValue(ResultSet rs, int columnIndex)
  8. getIntFromResultSet(ResultSet rs, String field)
  9. getIntFromResultSet(ResultSet rset, Enum field)