private ResultSet execQuery(Query query) {
		ResultSet result = null;
		boolean error = false;
		String url = service.getUrl();
		QueryEngineHTTP qexec = new QueryEngineHTTP(url,query);
		if(Config.log)
			Logging.out();//record the number of outgoing requests
		qexec.addParam("timeout", String.valueOf(timeout));
		int n = 0;
		while(n < MAXTRIES) {
			try {
				error = false;
				if(query.isSelectType()) {
					result =new ResultSetMem(qexec.execSelect());
					if(Config.log)
						Logging.in(((ResultSetMem)result).size());
				}
				else
					throw new ARQException("Wrong query type.");
				break;
			} catch (QueryExceptionHTTP e) {
				//System.out.println(query);
				error = true;
				try {
					n++;
					Thread.sleep(200 * n);
				} catch (InterruptedException e1) {
					e1.printStackTrace();
				}
			}
		}
		
		if(error) {
			result =new ResultSetMem();
			System.err.println("Error:\nremote service: " + url +"\nquery:\n" + query);
		}
		qexec.close();
		return result;
	}