@@ -0,0 +1,2527 @@
+//snippet-sourcedescription:%5BCreateDatabase.java demonstrates how to create a database.%5D%0A//snippet-keyword:%5BAWS SDK for Java v2%5D%0A//snippet-keyword:%5BCode Sample%5D%0A//snippet-keyword:%5BAmazon Timestream%5D%0A//snippet-sourcetype:%5Bfull-example%5D%0A//snippet-sourcedate:%5B05-04-2022%5D%0A//snippet-sourceauthor:%5Bscmacdon- AWS%5D%0A%0A/*%0A   Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.%0A   SPDX-License-Identifier: Apache-2.0%0A*/%0A%0Apackage com.timestream.write;%0A%0A//snippet-start:%5Btimestream.java2.create_db.import%5D%0Aimport software.amazon.awssdk.regions.Region;%0Aimport software.amazon.awssdk.services.timestreamwrite.TimestreamWriteClient;%0Aimport software.amazon.awssdk.services.timestreamwrite.model.CreateDatabaseRequest;%0Aimport software.amazon.awssdk.services.timestreamwrite.model.TimestreamWriteException;%0A//snippet-end:%5Btimestream.java2.create_db.import%5D%0A%0A/**%0A * To run this Java V2 code example, ensure that you have set up your development environment, including your credentials.%0A *%0A * For information, see this documentation topic:%0A *%0A * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html%0A */%0A%0Apublic class CreateDatabase %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A        final String usage = %22%5Cn%22 +%0A                %22Usage: %22 +%0A                %22   %3CdbName%3E %5Cn%5Cn%22 +%0A                %22Where:%5Cn%22 +%0A                %22   dbName - the name of the database.%5Cn%5Cn%22 ;%0A%0A        if (args.length != 1) %7B%0A            System.out.println(usage);%0A            System.exit(1);%0A        %7D%0A%0A        String dbName = args%5B0%5D;%0A        TimestreamWriteClient timestreamWriteClient = TimestreamWriteClient.builder()%0A                .region(Region.US_EAST_1)%0A                .build();%0A%0A        createNewDatabase(timestreamWriteClient, dbName);%0A        timestreamWriteClient.close();%0A    %7D%0A%0A    //snippet-start:%5Btimestream.java2.create_db.main%5D%0A    public static void createNewDatabase( TimestreamWriteClient timestreamWriteClient, String dbName) %7B%0A%0A        try %7B%0A            System.out.println(%22Creating database%22);%0A            CreateDatabaseRequest request = CreateDatabaseRequest.builder()%0A                    .databaseName(dbName)%0A                    .build();%0A%0A            timestreamWriteClient.createDatabase(request);%0A            System.out.println(%22Database %22 + dbName + %22 created successfully.%22);%0A%0A        %7D catch (TimestreamWriteException e) %7B%0A            System.err.println(e.awsErrorDetails().errorMessage());%0A            System.exit(1);%0A        %7D%0A    %7D%0A    //snippet-end:%5Btimestream.java2.create_db.main%5D%0A%7D%0A

Create CreateDatabase.java