Java SQL ResultSet Double Read getDoubleNotZero(ResultSet rs, String columnLabel)

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

Description

get Double Not Zero

License

Apache License

Declaration

public static Double getDoubleNotZero(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 Double getDoubleNotZero(ResultSet rs, String columnLabel) throws SQLException {
        return nullIfZero(getDouble(rs, columnLabel));
    }/*from   ww w .  java 2 s.c  om*/

    public static Long nullIfZero(Long number) {
        if (number == null || number == 0) {
            return null;
        } else {
            return number;
        }
    }

    public static Double nullIfZero(Double number) {
        if (number == null || number == 0) {
            return null;
        } else {
            return number;
        }
    }

    public static Double getDouble(ResultSet rs, String columnLabel) throws SQLException {
        double value = rs.getDouble(columnLabel);
        if (rs.wasNull()) {
            return null;
        } else {
            return value;
        }
    }
}

Related

  1. getDouble(ResultSet rs, String colName)
  2. getDouble(ResultSet rs, String column)
  3. getDouble(ResultSet rs, String columnName)
  4. getDouble2(ResultSet rs, int index)
  5. getDoubleList(ResultSet resultSet, String columnName)
  6. getDoubleOrNanFromResultSet(ResultSet rs, int index)
  7. getDoubleOrNull(ResultSet rs, String columnName)
  8. getDoubleValue(ResultSet resultSet, int columnIndex)
  9. readDouble(ResultSet resultSet, String columnName)