Java SQL ResultSet Int Read getIntegerNotZeroNotMinValue(ResultSet rs, String columnLabel)

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

Description

get Integer Not Zero Not Min Value

License

Apache License

Declaration

public static Integer getIntegerNotZeroNotMinValue(ResultSet rs, String columnLabel) throws SQLException 

Method Source Code

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

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

public class Main {
    public static Integer getIntegerNotZeroNotMinValue(ResultSet rs, String columnLabel) throws SQLException {
        return nullIfZeroOrMinValue(getInteger(rs, columnLabel));
    }/* w w  w  . jav a  2  s  .c  om*/

    public static Integer nullIfZeroOrMinValue(Integer number) {
        if (number == null || number == 0) {
            return null;
        } else if (number == Integer.MIN_VALUE || number == Short.MIN_VALUE) {
            return null;
        } else {
            return number;
        }
    }

    public static Integer getInteger(ResultSet rs, String columnLabel) throws SQLException {
        int value = rs.getInt(columnLabel);
        if (rs.wasNull()) {
            return null;
        } else {
            return value;
        }
    }
}

Related

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