code: public static long firstLong(PreparedStatement stmt) throws SQLException {
  		ResultSet rs = stmt.executeQuery();
  		long l = rs.next() ? rs.getLong(1) : Long.MIN_VALUE;
  		stmt.close();
  		return l;
  	}
docs: Execute the query, get the long value in the first row and column of the result set, and
  close the statement.
  
  @param stmt
  must already have parameters set
  @return {@link Long#MIN_VALUE} if the result set is empty