Batch write operations using the AWS SDK for Java

Let's understand how to put or delete multiple items from the DynamoDB table using the AWS SDK for Java.

Getting ready

To perform this operation, you can use the IDE of your choice.

How to do it…

Let's try to understand how to put/delete items from the DynamoDB table using Java:

  1. Create an instance of the DynamoDB class and initialize it with the desired AWS region and credentials:
    AmazonDynamoDBClient client = new AmazonDynamoDBClient(new ProfileCredentialsProvider());
        client.setRegion(Region.getRegion(Regions.US_EAST_1));
    DynamoDB dynamoDB = new DynamoDB(client);
  2. Create instance of TableWriteItems and specify if you wish to put or delete items from the DynamoDB table:
    TableWriteItems productItems = new ...

Get DynamoDB Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.