List of usage examples for com.amazonaws.services.dynamodbv2.document DynamoDB createTable
public Table createTable(String tableName, List<KeySchemaElement> keySchema,
List<AttributeDefinition> attributeDefinitions, ProvisionedThroughput provisionedThroughput)
From source file:CreateUserLoginTable.java
License:Open Source License
public static void main(String[] args) throws Exception { AmazonDynamoDBClient client = new AmazonDynamoDBClient(new ProfileCredentialsProvider()); DynamoDB dynamoDB = new DynamoDB(client); String tableName = "UserLogin"; try {/*w ww . j a va2 s.co m*/ System.out.println("Attempting to create table; please wait..."); Table table = dynamoDB.createTable(tableName, Arrays.asList(new KeySchemaElement("UserID", KeyType.HASH)), //Partition key Arrays.asList(new AttributeDefinition("UserID", ScalarAttributeType.N)), new ProvisionedThroughput(10L, 10L)); table.waitForActive(); System.out.println("Success. Table status: " + table.getDescription().getTableStatus()); } catch (Exception e) { System.err.println("Unable to create table: "); System.err.println(e.getMessage()); } }
From source file:CreateUserFavoritesTable.java
License:Open Source License
public static void main(String[] args) throws Exception { AmazonDynamoDBClient client = new AmazonDynamoDBClient(new ProfileCredentialsProvider()); DynamoDB dynamoDB = new DynamoDB(client); String tableName = "UserFavorites"; try {// ww w . jav a 2s. com System.out.println("Attempting to create table; please wait..."); Table table = dynamoDB.createTable(tableName, Arrays.asList(new KeySchemaElement("UserID", KeyType.HASH)), //Partition key Arrays.asList(new AttributeDefinition("UserID", ScalarAttributeType.N)), new ProvisionedThroughput(10L, 10L)); table.waitForActive(); System.out.println("Success. Table status: " + table.getDescription().getTableStatus()); } catch (Exception e) { System.err.println("Unable to create table: "); System.err.println(e.getMessage()); } }
From source file:CreateUserInfoTable.java
License:Open Source License
public static void main(String[] args) throws Exception { AmazonDynamoDBClient client = new AmazonDynamoDBClient(new ProfileCredentialsProvider()); DynamoDB dynamoDB = new DynamoDB(client); String tableName = "UserInfo"; try {//w w w. ja va 2s . c om System.out.println("Attempting to create table; please wait..."); Table table = dynamoDB.createTable(tableName, Arrays.asList(new KeySchemaElement("UserID", KeyType.HASH)), //Partition key Arrays.asList(new AttributeDefinition("UserID", ScalarAttributeType.N)), new ProvisionedThroughput(10L, 10L)); table.waitForActive(); System.out.println("Success. Table status: " + table.getDescription().getTableStatus()); } catch (Exception e) { System.err.println("Unable to create table: "); System.err.println(e.getMessage()); } }
From source file:CreateUserRoutesTable.java
License:Open Source License
public static void main(String[] args) throws Exception { AmazonDynamoDBClient client = new AmazonDynamoDBClient(new ProfileCredentialsProvider()); DynamoDB dynamoDB = new DynamoDB(client); String tableName = "UserRoutes"; try {/* www .jav a 2 s .c o m*/ System.out.println("Attempting to create table; please wait..."); Table table = dynamoDB.createTable(tableName, Arrays.asList(new KeySchemaElement("UserID", KeyType.HASH)), //Partition key Arrays.asList(new AttributeDefinition("UserID", ScalarAttributeType.N)), new ProvisionedThroughput(10L, 10L)); table.waitForActive(); System.out.println("Success. Table status: " + table.getDescription().getTableStatus()); } catch (Exception e) { System.err.println("Unable to create table: "); System.err.println(e.getMessage()); } }
From source file:com.euclidespaim.dynamodb.CreateTableFunction.java
License:Open Source License
public static void main(String[] args) throws Exception { AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().withEndpointConfiguration( new AwsClientBuilder.EndpointConfiguration("https://dynamodb.us-east-1.amazonaws.com", "us-east-1")) .build();/*w w w. ja v a 2 s .c o m*/ DynamoDB dynamoDB = new DynamoDB(client); String tableName = "Movies"; try { System.out.println("Attempting to create table; please wait..."); Table table = dynamoDB.createTable(tableName, Arrays.asList(new KeySchemaElement("year", KeyType.HASH), // Partition // key new KeySchemaElement("title", KeyType.RANGE)), // Sort key Arrays.asList(new AttributeDefinition("year", ScalarAttributeType.N), new AttributeDefinition("title", ScalarAttributeType.S)), new ProvisionedThroughput(10L, 10L)); table.waitForActive(); System.out.println("Success. Table status: " + table.getDescription().getTableStatus()); } catch (Exception e) { System.err.println("Unable to create table: "); System.err.println(e.getMessage()); } }