It is failing me when creating a table, the code is this:
public class MoviesCreateTable {
public static void main(String[] args) throws Exception {
AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration("http://localhost:8000", "us-east-2")).build();
System.out.println("registra bien");
DynamoDB dynamoDB = new DynamoDB(client);
System.out.println("se conecta con la bdd");
String tableName = "Movies";
try {
System.out.println("Attempting to create table; please wait...");
Table table = dynamoDB.createTable(tableName,
//partition key
Arrays.asList(new KeySchemaElement("year", KeyType.HASH), 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());
}
}
}
This is the log I get:
registra bien
se conecta con la bdd
Attempting to create table; please wait...
Unable to create table:
Unable to execute HTTP request: Connect to localhost:8000 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
EDIT2 : I HAVE FOUND THE SOLUTION IN CASE SOMEONE SERVES HIM,
I have simply removed the client line, because there I was testing on localhost and I have replaced it with this:
AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
.withRegion(Regions.US_WEST_2)
.build();
I HAVE FOUND THE SOLUTION IN CASE ANYBODY SERVES HIM,
I have simply removed the client line, because there I was testing on localhost and I have replaced it with this: