Java SQL ResultSet Boolean Read getBooleanValue(ResultSet resultSet, int columnIndex)

Here you can find the source of getBooleanValue(ResultSet resultSet, int columnIndex)

Description

Return any boolean value.

License

Apache License

Declaration

@SuppressWarnings("UnnecessaryBoxing")
public static Boolean getBooleanValue(ResultSet resultSet, int columnIndex) throws SQLException 

Method Source Code


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

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

public class Main {
    /**//  www . j  av  a 2  s.c  o  m
     * Return any boolean value.
     */
    @SuppressWarnings("UnnecessaryBoxing")
    public static Boolean getBooleanValue(ResultSet resultSet, int columnIndex) throws SQLException {
        boolean value = resultSet.getBoolean(columnIndex);
        if (resultSet.wasNull()) {
            return null;
        }
        return Boolean.valueOf(value);
    }

    /**
     * Return any boolean value.
     */
    @SuppressWarnings("UnnecessaryBoxing")
    public static Boolean getBooleanValue(ResultSet resultSet, String columnName) throws SQLException {
        boolean value = resultSet.getBoolean(columnName);
        if (resultSet.wasNull()) {
            return null;
        }
        return Boolean.valueOf(value);
    }
}

Related

  1. getBoolean(ResultSet rs, String columnName)
  2. getBoolean(ResultSet rs, String name)
  3. getBooleanFromResultSet(ResultSet rset, String field)
  4. getBooleanOrNull(ResultSet rs, String column)
  5. getBooleanSuppressSQLException(final ResultSet rs, final String columnLabel)