try (Connection connection = DriverManager.getConnection(url, username, password)) {
trySetConnectionProperties(query, connection);
long start = System.nanoTime();
try (Statement statement = connection.createStatement()) {
TimeLimiter limiter = new SimpleTimeLimiter();
Stopwatch stopwatch = Stopwatch.createStarted();
Statement limitedStatement = limiter.newProxy(statement, Statement.class, timeout.toMillis(), TimeUnit.MILLISECONDS);
try (final ResultSet resultSet = limitedStatement.executeQuery(query.getQuery())) {
List<List<Object>> results = limiter.callWithTimeout(getResultSetConverter(resultSet), timeout.toMillis() - stopwatch.elapsed(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS, true);
return new QueryResult(State.SUCCESS, null, nanosSince(start), results);
}
catch (AssertionError e) {
if (e.getMessage().startsWith("unimplemented type:")) {
return new QueryResult(State.INVALID, null, null, ImmutableList.<List<Object>>of());