code: private static int querySingleInteger(Connection connection, String sql,
  			String[] args, boolean allowEmptyResults) {
  
  		int result = 0;
  
  		Object value = querySingleResult(connection, sql, args, 0,
  				GeoPackageDataType.MEDIUMINT);
  		if (value != null) {
  			result = ((Number) value).intValue();
  		} else if (!allowEmptyResults) {
  			throw new GeoPackageException(
  					"Failed to query for single result. SQL: " + sql);
  		}
  
  		return result;
  	}
docs: Query the SQL for a single integer result
  
  @param connection
  connection
  @param sql
  sql
  @param args
  query arguments
  @param allowEmptyResults
  true to accept empty results as a 0 return
  @return Integer result, null if no result