Java SQL ResultSet Read getNullableLong(ResultSet rs, String columnName)

Here you can find the source of getNullableLong(ResultSet rs, String columnName)

Description

Returns the long value of a column, or null when appropriate.

License

Open Source License

Parameter

Parameter Description
rs the result set to read from
columnName the name of the column to retrieve

Exception

Parameter Description
SQLException :)

Return

the value (which may be null)

Declaration

public static Long getNullableLong(ResultSet rs, String columnName) 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 ww.  ja va  2 s  .com
     * Returns the long value of a column, or null when appropriate. This method is necessary because
     * JDBC's {@link ResultSet#getLong} returns {@code 0} if the entry in the database is {@code null}.
     *
     * @param rs the result set to read from
     * @param columnName the name of the column to retrieve
     * @return the value (which may be null)
     * @throws SQLException :)
     */
    public static Long getNullableLong(ResultSet rs, String columnName) throws SQLException {
        long longValue = rs.getLong(columnName);
        return rs.wasNull() ? null : longValue;
    }
}

Related

  1. getMetaData(ResultSet rs)
  2. getNullable(final ResultSet resultSet, final T value)
  3. getNullableBooleanFromResultSet(ResultSet rset, Enum field)
  4. getNullableByte(ResultSet resultSet, String columnLabel)
  5. getNullableInt(ResultSet resultSet, String column, int fallback)
  6. getNullDate(ResultSet result, String columnName)
  7. getNumber(ResultSet rs, String name)
  8. getNumberColumns(ResultSet rs)
  9. getNumRows(ResultSet query)