We will learn about the Create, Retrieve, Update, and Delete operations on the DynamoDB table using the Java SDK.
We will put items into the awsbootcamp
table that we created in the previous section.
- Using
AmazonDynamoDB
:
Let's create an item using the AmazonDynamoDB
object:
Map<String, AttributeValue> item = new HashMap<>(); item.put("id", new AttributeValue().withN("1")); item.put("name", new AttributeValue().withS("Sunil")); item.put("lastName", new AttributeValue().withS("Gulabani")); createItem(tableName, item); ........ public void createItem( String tableName, Map<String, AttributeValue> item) { PutItemRequest request = new PutItemRequest() .withTableName(tableName) .withItem(item); PutItemResult result = amazonDynamoDB.putItem(request); }
- Using
DynamoDB
:
Let's create an item using the DynamoDB
object:
Item item2 = new Item() .withPrimaryKey("id", 2, "name...