Java SQL ResultSet Read getNullableByte(ResultSet resultSet, String columnLabel)

Here you can find the source of getNullableByte(ResultSet resultSet, String columnLabel)

Description

Returns the value of the specified column from the ResultSet or null if the value is nullable and was null.

License

Open Source License

Parameter

Parameter Description
resultSet The ResultSet from which to retrieve the column.
columnLabel The label of the column.

Exception

Parameter Description
SQLException If the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set.

Return

The value for the column or null if it was null.

Declaration

public static Byte getNullableByte(ResultSet resultSet, String columnLabel) throws SQLException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**/*from w  w w .  j a va  2 s. co  m*/
     * Returns the value of the specified column from the ResultSet or null if the value is nullable and was null.
     * @param resultSet The ResultSet from which to retrieve the column.
     * @param columnLabel The label of the column.
     * @return The value for the column or null if it was null.
     * @throws SQLException If the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set.
     */
    public static Byte getNullableByte(ResultSet resultSet, String columnLabel) throws SQLException {
        byte value = resultSet.getByte(columnLabel);
        return resultSet.wasNull() ? null : value;
    }

    /**
     * Returns the value of the specified column from the ResultSet or null if the value is nullable and was null.
     * @param resultSet The ResultSet from which to retrieve the column.
     * @param columnIndex The numerical index of the column (starting with 1 for the first column).
     * @return The value for the column or null if it was null.
     * @throws SQLException If the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set.
     */
    public static Byte getNullableByte(ResultSet resultSet, int columnIndex) throws SQLException {
        byte value = resultSet.getByte(columnIndex);
        return resultSet.wasNull() ? null : value;
    }
}

Related

  1. getMap(ResultSet resultSet)
  2. getMap(ResultSet rs, ResultSetMetaData metaData, int cols_len)
  3. getMetaData(ResultSet rs)
  4. getNullable(final ResultSet resultSet, final T value)
  5. getNullableBooleanFromResultSet(ResultSet rset, Enum field)
  6. getNullableInt(ResultSet resultSet, String column, int fallback)
  7. getNullableLong(ResultSet rs, String columnName)
  8. getNullDate(ResultSet result, String columnName)
  9. getNumber(ResultSet rs, String name)