Java Utililty Methods SQL ResultSet Int Read

List of utility methods to do SQL ResultSet Int Read

Description

The list of methods to do SQL ResultSet Int Read are organized into topic(s).

Method

IntegergetInteger(ResultSet rs, String columnName)
get an Integer object from a result set column with given name
int value = rs.getInt(columnName);
if (rs.wasNull()) {
    return null;
return value;
IntegergetInteger(ResultSet rs, String strColName)
This method will return a null rather than zero if the database has a null value for the column.
int nValue = rs.getInt(strColName);
return rs.wasNull() ? null : nValue;
IntegergetInteger(ResultSet s, int idx)
Get the Integer result in slot 'idx' of ResultSet 's', being careful to return null when it's NULL.
if (s.getString(idx) == null) {
    return null;
} else {
    return s.getInt(idx);
IntegergetIntegerFromResultSet(ResultSet rs, String db_name)
get Integer From Result Set
int n = rs.getInt(db_name);
return rs.wasNull() ? null : Integer.valueOf(n);
ListgetIntegerList(ResultSet resultSet, String columnName)
Returns a list of integer values using a given SQL result set and column name.
List<Integer> values = null;
if (resultSet != null && columnName != null) {
    values = new ArrayList<Integer>();
    while (resultSet.next()) {
        values.add(getInteger(resultSet, columnName));
return values;
...
IntegergetIntegerNotZeroNotMinValue(ResultSet rs, String columnLabel)
get Integer Not Zero Not Min Value
return nullIfZeroOrMinValue(getInteger(rs, columnLabel));
ListgetIntegers(ResultSet rs, String column)
get Integers
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
    throw new IllegalArgumentException("Incompatible type with Integer[]: " + array.getClass());
IntegergetIntegerValue(ResultSet resultSet, String columnName)
Return any integer value.
int value = resultSet.getInt(columnName);
if (resultSet.wasNull()) {
    return null;
return Integer.valueOf(value);
IntegergetIntegerValue(ResultSet rs, int columnIndex)
Retrieves the value of the designated column in the current row of this ResultSet object as an Integer in the Java programming language.
return rs.getObject(columnIndex) == null ? null : rs.getInt(columnIndex);
IntegergetIntFromResultSet(ResultSet rs, String field)
get Int From Result Set
Integer result = null;
try {
    Object value = rs.getObject(field);
    if (value != null) {
        result = (Integer) value;
} catch (Exception e) {
return result;