Here you can find the source of getNullableLong(ResultSet rs, String columnName)
Parameter | Description |
---|---|
rs | the result set to read from |
columnName | the name of the column to retrieve |
Parameter | Description |
---|---|
SQLException | :) |
public static Long getNullableLong(ResultSet rs, String columnName) throws SQLException
//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; } }