Java SQL ResultSet Long Read getLong(ResultSet res, String name)

Here you can find the source of getLong(ResultSet res, String name)

Description

Returns the values of the specified column as a Long.

License

MIT License

Parameter

Parameter Description
res a result set.
name a name of the column.

Exception

Parameter Description
SQLException if an error occurs.

Return

the value of the column.

Declaration

public static Long getLong(ResultSet res, String name) throws SQLException 

Method Source Code

//package com.java2s;
/*//  w  ww  .  j a  v a 2s.  c  om
 * Copyright (c) 2015-2016 QuartzDesk.com.
 * Licensed under the MIT license (https://opensource.org/licenses/MIT).
 */

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

public class Main {
    /**
     * Returns the values of the specified column as a Long. If the column
     * value is null, this method returns null.
     *
     * @param res  a result set.
     * @param name a name of the column.
     * @return the value of the column.
     * @throws SQLException if an error occurs.
     */
    public static Long getLong(ResultSet res, String name) throws SQLException {
        long v = res.getLong(name);
        return res.wasNull() ? null : v;
    }
}

Related

  1. getLong(ResultSet results, int parameterIndex)
  2. getLong(ResultSet resultSet, int index)
  3. getLong(ResultSet resultSet, String columnName)
  4. getLong(ResultSet rs, String colName)