Here you can find the source of getLongFromResultSet(ResultSet rs, String field)
Parameter | Description |
---|---|
rs | ResultSet |
field | Field we want to obtain the value from |
public static Long getLongFromResultSet(ResultSet rs, String field)
//package com.java2s; //License from project: Apache License import java.sql.ResultSet; public class Main { /**//from w ww.ja v a2 s . c o m * Returns the Long value corresponding to the given field on the given * ResultSet. If the value cannot be parsed to Long, or does not exist, it * returns a null value. * * @param rs * ResultSet * @param field * Field we want to obtain the value from * @return Long value if the field exists and can be parsed to Long. Null otherwise. */ public static Long getLongFromResultSet(ResultSet rs, String field) { Long result = null; try { Object value = rs.getObject(field); if (value != null) { result = (Long) value; } } catch (Exception e) { } return result; } }