//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
@@ -956,151 +956,8 @@
  */%0A
-//snippet-start:%5Bathena.java2.ListNamedQueryExecutionsExample.complete%5D%0A//snippet-start:%5Bathena.java.ListNamedQueryExecutionsExample.complete%5D%0A
 pack
@@ -1051,16 +1051,62 @@
 import%5D%0A
+import software.amazon.awssdk.regions.Region;%0A
 import s
@@ -1157,16 +1157,85 @@
 Client;%0A
+import software.amazon.awssdk.services.athena.model.AthenaException;%0A
 import s
@@ -1473,17 +1473,16 @@
 erable;%0A
-%0A
 import j
@@ -1750,20 +1750,16 @@
 ample %7B%0A
-    
 %0A    pub
@@ -1813,16 +1813,17 @@
 ption %7B%0A
+%0A
         
@@ -1828,234 +1828,357 @@
   //
-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   
     
@@ -2202,16 +2202,20 @@
 request%0A
+    
         
@@ -2325,16 +2325,20 @@
         
+    
 // Get t
@@ -2354,32 +2354,36 @@
 esults.%0A        
+ 
+   
 ListQueryExecuti
@@ -2504,16 +2504,20 @@
         
+    
 for (Lis
@@ -2609,24 +2609,28 @@
             
+  
+  
 List%3CString%3E
@@ -2706,47 +2706,8 @@
     
-        // process queryExecutionIds.%0A%0A
     
@@ -2733,16 +2733,22 @@
 println(
+%22%5Cn%22 +
 queryExe
@@ -2777,156 +2777,105 @@
     
-    //snippet-end:%5Bathena.java2.ListNamedQueryExecutionsExample.main%5D%0A%0A    %7D%0A%7D%0A//snippet-end:%5Bathena.java.ListNamedQueryExecutionsExample.complete%5D%0A
+%7D catch (AthenaException e) %7B%0A        e.printStackTrace();%0A        System.exit(1);%0A    %7D%0A        
 //sn
@@ -2934,14 +2934,16 @@
 ple.
-complete%5D
+main%5D%0A  %7D%0A%7D
 %0A

Update ListQueryExecutionsExample.java