code: public long queryForLong(DatabaseConnection databaseConnection, String query, String[] arguments)
  			throws SQLException {
  		logger.debug("executing raw query for long: {}", query);
  		if (arguments.length > 0) {
  			// need to do the (Object) cast to force args to be a single object
  			logger.trace("query arguments: {}", (Object) arguments);
  		}
  		CompiledStatement compiledStatement = null;
  		DatabaseResults results = null;
  		try {
  			compiledStatement = databaseConnection.compileStatement(query, StatementType.SELECT, noFieldTypes,
  					DatabaseConnection.DEFAULT_RESULT_FLAGS, false);
  			assignStatementArguments(compiledStatement, arguments);
  			results = compiledStatement.runQuery(null);
  			if (results.first()) {
  				return results.getLong(0);
  			} else {
  				throw new SQLException("No result found in queryForLong: " + query);
  			}
  		} finally {
  			IOUtils.closeThrowSqlException(results, "results");
  			IOUtils.closeThrowSqlException(compiledStatement, "compiled statement");
  		}
  	}
docs: Return a long from a raw query with String[] arguments.