//snippet-sourcedescription:[ListNamedQueryExample.java demonstrates how to obtain a list of named query 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.ListNamedQueryExample.complete]
//snippet-start:[athena.java.ListNamedQueryExample.complete]
package aws.example.athena;

//snippet-start:[athena.java2.ListNamedQueryExample.import]
import software.amazon.awssdk.services.athena.AthenaClient;
import software.amazon.awssdk.services.athena.model.ListNamedQueriesRequest;
import software.amazon.awssdk.services.athena.model.ListNamedQueriesResponse;
import software.amazon.awssdk.services.athena.paginators.ListNamedQueriesIterable;
//snippet-end:[athena.java2.ListNamedQueryExample.import]

import java.util.List;

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

        // Build the request
        ListNamedQueriesRequest listNamedQueriesRequest = ListNamedQueriesRequest.builder().build();

        // Get the list results.
        ListNamedQueriesIterable listNamedQueriesResponses = athenaClient.listNamedQueriesPaginator(listNamedQueriesRequest);


        // Process the results.
        for (ListNamedQueriesResponse listNamedQueriesResponse : listNamedQueriesResponses) {
            List<String> namedQueryIds = listNamedQueriesResponse.namedQueryIds();
            // process named query IDs

            System.out.println(namedQueryIds);
        }


    }
    //snippet-end:[athena.java2.ListNamedQueryExample.main]
}
//snippet-end:[athena.java.ListNamedQueryExample.complete]
//snippet-end:[athena.java2.ListNamedQueryExample.complete]
@@ -314,18 +314,17 @@
 te:%5B
-2019-04-15
+4/10/2020
 %5D%0A//
@@ -349,22 +349,18 @@
 or:%5B
-j
 sc
-hwarzwalder
+macdon -
  AWS
@@ -381,18 +381,8 @@
 ght 
-2010-2019 
 Amaz
@@ -936,16 +936,17 @@
 se.%0A */%0A
+%0A
 //snippe
@@ -1149,16 +1149,62 @@
 import%5D%0A
+import software.amazon.awssdk.regions.Region;%0A
 import s
@@ -1255,16 +1255,85 @@
 Client;%0A
+import software.amazon.awssdk.services.athena.model.AthenaException;%0A
 import s
@@ -1820,69 +1820,8 @@
 e %7B%0A
-    //snippet-start:%5Bathena.java2.ListNamedQueryExample.main%5D
 %0A   
@@ -1937,61 +1937,124 @@
 ient
-Factory factory = new AthenaClientFactory
+ athenaClient = AthenaClient.builder()%0A                .region(Region.US_WEST_2)%0A                .build
 ();%0A
+%0A
         
 Athe
@@ -2053,61 +2053,196 @@
     
-AthenaClient athenaClient = factory.create
+listNamedQueries(athenaClient) ;%0A    %7D%0A%0A    //snippet-start:%5Bathena.java2.ListNamedQueryExample.main%5D%0A    public static void listNamedQueries(AthenaClient athena
 Client
-();
+) %7B
 %0A%0A
+       try%7B%0A%0A   
     
@@ -2266,32 +2266,35 @@
 request%0A        
+ 
+  
 ListNamedQueries
@@ -2379,16 +2379,19 @@
         
+   
 // Get t
@@ -2407,32 +2407,36 @@
 esults.%0A        
+  
+  
 ListNamedQueries
@@ -2538,17 +2538,20 @@
 uest);%0A%0A
-%0A
+    
         
@@ -2566,32 +2566,36 @@
 ss the results.%0A
+    
         for (Lis
@@ -2680,24 +2680,28 @@
             
+  
+  
 List%3CString%3E
@@ -2759,16 +2759,20 @@
 yIds();%0A
+    
         
@@ -2802,17 +2802,20 @@
 ery IDs%0A
-%0A
+    
         
@@ -2861,19 +2861,127 @@
         
-%7D%0A%0A
+    %7D%0A%0A       %7D catch (AthenaException e) %7B%0A           e.printStackTrace();%0A           System.exit(1);%0A       %7D
 %0A    %7D%0A 
@@ -3139,28 +3139,29 @@
 tNamedQueryExample.complete%5D
+%0A

Update ListNamedQueryExample.java