-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
ListQueryExecutionsExample.java
47 lines (39 loc) · 1.78 KB
/
ListQueryExecutionsExample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package aws.example.athena;
import com.amazonaws.services.athena.AmazonAthena;
import com.amazonaws.services.athena.model.ListQueryExecutionsRequest;
import com.amazonaws.services.athena.model.ListQueryExecutionsResult;
import java.util.List;
/**
* ListQueryExecutionsExample
* -------------------------------------
* This code shows how to obtain a list of query execution IDs.
*/
public class ListQueryExecutionsExample {
public static void main(String[] args) throws Exception {
// Build an Athena client
AthenaClientFactory factory = new AthenaClientFactory();
AmazonAthena athenaClient = factory.createClient();
// Build the request
ListQueryExecutionsRequest listQueryExecutionsRequest = new ListQueryExecutionsRequest();
// Get the list results.
ListQueryExecutionsResult listQueryExecutionsResult = athenaClient
.listQueryExecutions(listQueryExecutionsRequest);
// Process the results.
boolean hasMoreResults = true;
while (hasMoreResults) {
List<String> queryExecutionIds = listQueryExecutionsResult.getQueryExecutionIds();
// process queryExecutionIds.
System.out.println(queryExecutionIds);
// If nextToken is not null, then there are more results. Get the next page of
// results.
if (listQueryExecutionsResult.getNextToken() != null) {
listQueryExecutionsResult = athenaClient.listQueryExecutions(
listQueryExecutionsRequest.withNextToken(listQueryExecutionsResult.getNextToken()));
} else {
hasMoreResults = false;
}
}
}
}