Code examples for Amazon Redshift using AWS SDKs - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Code examples for Amazon Redshift using AWS SDKs

The following code examples show you how to use Amazon Redshift with an AWS software development kit (SDK).

Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios and cross-service examples.

Scenarios are code examples that show you how to accomplish a specific task by calling multiple functions within the same service.

Cross-service examples are sample applications that work across multiple AWS services.

More resources

Get started

The following code example shows how to get started using Amazon Redshift.

Java
SDK for Java 2.x
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.redshift.RedshiftClient; import software.amazon.awssdk.services.redshift.paginators.DescribeClustersIterable; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class HelloRedshift { public static void main(String[] args) { Region region = Region.US_EAST_1; RedshiftClient redshiftClient = RedshiftClient.builder() .region(region) .build(); listClustersPaginator(redshiftClient); } public static void listClustersPaginator(RedshiftClient redshiftClient) { DescribeClustersIterable clustersIterable = redshiftClient.describeClustersPaginator(); clustersIterable.stream() .flatMap(r -> r.clusters().stream()) .forEach(cluster -> System.out .println(" Cluster identifier: " + cluster.clusterIdentifier() + " status = " + cluster.clusterStatus())); } }