//snippet-sourcedescription:[ListQueryExecutionsExample.java demonstrates how to obtain a list of query execution IDs.]
//snippet-keyword:[Java]
//snippet-sourcesyntax:[java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon Athena]
//snippet-service:[athena]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[2019-04-15]
//snippet-sourceauthor:[jschwarzwalder AWS]
/*
 * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
//snippet-start:[athena.java2.ListNamedQueryExecutionsExample.complete]
//snippet-start:[athena.java.ListNamedQueryExecutionsExample.complete]
package aws.example.athena;

//snippet-start:[athena.java2.ListNamedQueryExecutionsExample.import]
import software.amazon.awssdk.services.athena.AthenaClient;
import software.amazon.awssdk.services.athena.model.ListQueryExecutionsRequest;
import software.amazon.awssdk.services.athena.model.ListQueryExecutionsResponse;
import software.amazon.awssdk.services.athena.paginators.ListQueryExecutionsIterable;

import java.util.List;
//snippet-end:[athena.java2.ListNamedQueryExecutionsExample.import]

/**
 * ListQueryExecutionsExample
 * -------------------------------------
 * This code shows how to obtain a list of query execution IDs.
 */
public class ListQueryExecutionsExample {
    
    public static void main(String[] args) throws Exception {
        //snippet-start:[athena.java2.ListNamedQueryExecutionsExample.main]
        // Build an Athena client
        AthenaClientFactory factory = new AthenaClientFactory();
        AthenaClient athenaClient = factory.createClient();

        // Build the request
        ListQueryExecutionsRequest listQueryExecutionsRequest = ListQueryExecutionsRequest.builder().build();

        // Get the list results.
        ListQueryExecutionsIterable listQueryExecutionResponses = athenaClient.listQueryExecutionsPaginator(listQueryExecutionsRequest);

        for (ListQueryExecutionsResponse listQueryExecutionResponse : listQueryExecutionResponses) {
            List<String> queryExecutionIds = listQueryExecutionResponse.queryExecutionIds();
            // process queryExecutionIds.

            System.out.println(queryExecutionIds);
        }
        //snippet-end:[athena.java2.ListNamedQueryExecutionsExample.main]

    }
}
//snippet-end:[athena.java.ListNamedQueryExecutionsExample.complete]
//snippet-end:[athena.java2.ListNamedQueryExecutionsExample.complete]

@@ -253,17 +253,24 @@
 ervice:%5B
-a
+Amazon A
 thena%5D%0A/
@@ -330,18 +330,17 @@
 te:%5B
-2019-04-15
+4/30/2020
 %5D%0A//
@@ -365,22 +365,18 @@
 or:%5B
-j
 sc
-hwarzwalder
+macdon -
  AWS
@@ -397,18 +397,8 @@
 ght 
-2010-2019 
 Amaz
@@ -952,16 +952,17 @@
 se.%0A */%0A
+%0A
 //snippe
@@ -1195,16 +1195,62 @@
 import%5D%0A
+import software.amazon.awssdk.regions.Region;%0A
 import s
@@ -1301,16 +1301,85 @@
 Client;%0A
+import software.amazon.awssdk.services.athena.model.AthenaException;%0A
 import s
@@ -1617,17 +1617,16 @@
 erable;%0A
-%0A
 import j
@@ -1894,20 +1894,16 @@
 ample %7B%0A
-    
 %0A    pub
@@ -1957,16 +1957,17 @@
 ption %7B%0A
+%0A
         
@@ -1972,242 +1972,363 @@
   //
-snippet-start:%5Bathena.java2.ListNamedQueryExecutionsExample.main%5D%0A        // Build an A
+ Build an Athena client%0A        AthenaClient athenaClient = AthenaClient.builder()%0A                .region(Region.US_WEST_2)%0A                .build();%0A%0A        listQueryIds(a
 thena
- c
+C
 lient
+);
 %0A    
+%7D%0A%0A
     
-AthenaClientFactory factory = new AthenaClientFactory();%0A        AthenaClient athenaClient = factory.createClient();%0A%0A
+//snippet-start:%5Bathena.java2.listNamedQueryExecutionsExample.main%5D%0A    public static void listQueryIds(AthenaClient athenaClient) %7B%0A%0A       try %7B%0A 
         
 // B
@@ -2315,32 +2315,34 @@
  try %7B%0A         
+  
 // Build the req
@@ -2346,16 +2346,20 @@
 request%0A
+    
         
@@ -2469,16 +2469,20 @@
         
+  
+  
 // Get t
@@ -2498,16 +2498,20 @@
 esults.%0A
+    
         
@@ -2648,16 +2648,20 @@
         
+ 
+   
 for (Lis
@@ -2753,24 +2753,28 @@
             
+    
 List%3CString%3E
@@ -2858,19 +2858,37 @@
     
+ 
-// process 
+   System.out.println(%22%5Cn%22 +
 quer
@@ -2900,18 +2900,18 @@
 utionIds
-.%0A
+);
 %0A       
@@ -2915,65 +2915,103 @@
     
+%7D%0A
     
-System.out.println(queryExecutionIds);%0A        %7D
+%7D catch (AthenaException e) %7B%0A        e.printStackTrace();%0A        System.exit(1);
 %0A    
+%7D%0A
     
@@ -3076,19 +3076,16 @@
 e.main%5D%0A
-%0A  
   %7D%0A%7D%0A//

Update ListQueryExecutionsExample.java