//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
@@ -940,130 +940,8 @@
  */%0A
-//snippet-start:%5Bathena.java2.ListNamedQueryExample.complete%5D%0A//snippet-start:%5Bathena.java.ListNamedQueryExample.complete%5D
 %0Apac
@@ -1026,16 +1026,62 @@
 import%5D%0A
+import software.amazon.awssdk.regions.Region;%0A
 import s
@@ -1132,16 +1132,85 @@
 Client;%0A
+import software.amazon.awssdk.services.athena.model.AthenaException;%0A
 import s
@@ -1697,69 +1697,8 @@
 e %7B%0A
-    //snippet-start:%5Bathena.java2.ListNamedQueryExample.main%5D
 %0A   
@@ -1814,61 +1814,124 @@
 ient
-Factory factory = new AthenaClientFactory
+ athenaClient = AthenaClient.builder()%0A                .region(Region.US_WEST_2)%0A                .build
 ();%0A
+%0A
         
 Athe
@@ -1930,61 +1930,196 @@
     
-AthenaClient athenaClient = factory.createClient();%0A%0A
+listNamedQueries(athenaClient) ;%0A    %7D%0A%0A    //snippet-start:%5Bathena.java2.ListNamedQueryExample.main%5D%0A    public static void listNamedQueries(AthenaClient athenaClient) %7B%0A%0A       try%7B%0A%0A   
     
@@ -2143,16 +2143,19 @@
 request%0A
+   
         
@@ -2256,16 +2256,19 @@
         
+ 
+  
 // Get t
@@ -2276,32 +2276,36 @@
 e list results.%0A
+    
         ListName
@@ -2415,25 +2415,24 @@
 uest);%0A%0A
-%0A
         
 // Proce
@@ -2423,16 +2423,20 @@
         
+    
 // Proce
@@ -2443,32 +2443,36 @@
 ss the results.%0A
+    
         for (Lis
@@ -2557,24 +2557,28 @@
             
+    
 List%3CString%3E
@@ -2636,16 +2636,20 @@
 yIds();%0A
+    
         
@@ -2679,17 +2679,20 @@
 ery IDs%0A
-%0A
+    
         
@@ -2742,139 +2742,130 @@
     
+    
 %7D
-%0A
 %0A%0A    
-%7D%0A
    
- //snippet-end:%5Bathena.java2.ListNamedQueryExample.main%5D%0A%7D%0A//snippet-end:%5Bathena.java.ListNamedQueryExample.complete%5D%0A
+%7D catch (AthenaException e) %7B%0A           e.printStackTrace();%0A           System.exit(1);%0A       %7D%0A    %7D%0A    
 //sn
@@ -2914,13 +2914,12 @@
 ple.
-complete%5D
+main%5D%0A%7D%0A

Update ListNamedQueryExample.java