use of software.amazon.awssdk.services.dynamodb.model.DeleteItemRequest in project aws-doc-sdk-examples by awsdocs.
the class DeleteItem method deleteDymamoDBItem.
// snippet-start:[dynamodb.java2.delete_item.main]
public static void deleteDymamoDBItem(DynamoDbClient ddb, String tableName, String key, String keyVal) {
HashMap<String, AttributeValue> keyToGet = new HashMap<String, AttributeValue>();
keyToGet.put(key, AttributeValue.builder().s(keyVal).build());
DeleteItemRequest deleteReq = DeleteItemRequest.builder().tableName(tableName).key(keyToGet).build();
try {
ddb.deleteItem(deleteReq);
} catch (DynamoDbException e) {
System.err.println(e.getMessage());
System.exit(1);
}
}
Aggregations