Java SQL ResultSet BigDecimal Read getBigDecimal(ResultSet rs, String columnLabel)

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

Description

get Big Decimal

License

Apache License

Declaration

public static BigDecimal getBigDecimal(ResultSet rs, String columnLabel) throws SQLException 

Method Source Code


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

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Main {
    public static BigDecimal getBigDecimal(ResultSet rs, String columnLabel) throws SQLException {
        BigDecimal bigDecimal = rs.getBigDecimal(columnLabel);
        if (bigDecimal != null) {
            return bigDecimal;
        } else {//from   w  ww.j a v  a2s . c  o  m
            return null;
        }
    }

    public static BigDecimal getBigDecimal(ResultSet rs, String columnLabel, int scale, RoundingMode roundingMode)
            throws SQLException, ArithmeticException {
        BigDecimal bigDecimal = rs.getBigDecimal(columnLabel);
        if (bigDecimal != null) {
            return bigDecimal.setScale(scale, roundingMode);
        } else {
            return null;
        }
    }
}

Related

  1. getBigDecimal(ResultSet res, String name)
  2. getBigDecimalArray(final ResultSet resultSet, final int index)
  3. getBigDecimalNotZero(ResultSet rs, String columnLabel)