Database Reference
In-Depth Information
static AmazonDynamoDBClient client;
The following block will initialize the table name to the local variable. Then the if condi-
tion will check whether the table already exists with this name (on the client configured
region) and return the Boolean value. If the table already exists then the syso message will
be printed.
String tableName = "Tbl_Book";
if (Tables.doesTableExist(client, tableName)) {
System.out.println("Table " + tableName + " already
EXISTS");
}
The following block will create CreateTableRequest with attributes such as table
name, attribute definitions, key schema, provisioned throughput, and indexes:
CreateTableRequest request = new CreateTableRequest()
.withTableName(tableName)
.withAttributeDefinitions(attributeDefinitions)
.withKeySchema(keySchemaElements)
.withProvisionedThroughput(provisionedThroughput)
.withGlobalSecondaryIndexes(globalSecondaryIndex);
The following line will submit the table creation request through the DynamoDB client:
client.createTable(request);
The following line of code will pause the further execution of the code until the table be-
comes active (most probably used before adding items to the table):
Tables.waitForTableToBecomeActive(client, tableName);
The following code will request to describe the table name passed as a parameter to the
client:
client.describeTable(new DescribeTableRequest()
.withTableName(tableName))
.getTable();
Search WWH ::




Custom Search