ListNamedQueryExample.java - AWS Code Sample

ListNamedQueryExample.java

ListNamedQueryExample.java demonstrates how to obtain a list of named query Id values.

Note

To run this Java (SDK V2) code example, ensure that you have set up your development environment, including your credentials. For more information, see AWS SDK for Java 2.x Developer Guide.

/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ package aws.example.athena; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.athena.AthenaClient; import software.amazon.awssdk.services.athena.model.AthenaException; import software.amazon.awssdk.services.athena.model.ListNamedQueriesRequest; import software.amazon.awssdk.services.athena.model.ListNamedQueriesResponse; import software.amazon.awssdk.services.athena.paginators.ListNamedQueriesIterable; import java.util.List; /** * To run this Java V2 code example, ensure that you have setup your development environment, including your credentials. * * For information, see this documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class ListNamedQueryExample { public static void main(String[] args) throws Exception { AthenaClient athenaClient = AthenaClient.builder() .region(Region.US_WEST_2) .build(); listNamedQueries(athenaClient) ; athenaClient.close(); } public static void listNamedQueries(AthenaClient athenaClient) { try{ ListNamedQueriesRequest listNamedQueriesRequest = ListNamedQueriesRequest.builder() .build(); ListNamedQueriesIterable listNamedQueriesResponses = athenaClient.listNamedQueriesPaginator(listNamedQueriesRequest); for (ListNamedQueriesResponse listNamedQueriesResponse : listNamedQueriesResponses) { List<String> namedQueryIds = listNamedQueriesResponse.namedQueryIds(); System.out.println(namedQueryIds); } } catch (AthenaException e) { e.printStackTrace(); System.exit(1); } } }

Sample Details

Last tested: 11/02/2020

Author: scmacdon - aws

Type: full-example