Database Reference
In-Depth Information
By default, the DynamoDB Local service runs on port 8000.
6. In case you are using port 8000 for some other service, you can simply choose
your own port number by running the following command:
java -Djava.library.path=. -jar DynamoDBLocal.jar
--port <YourPortNumber>
Now, let's see how to use DynamoDB Local in the Java API. The complete implementa-
tion remains the same; the only thing that we need to do is set the endpoint in the client
configuration as http://localhost:8000 .
Using DynamoDB for development in Java is quite easy; you just need to set the previous
URL as the endpoint while creating DynamoDB Client, as shown in the following code:
// Instantiate AWS Client with proper credentials
AmazonDynamoDBClient dynamoDBClient = new
AmazonDynamoDBClient(
new ClasspathPropertiesFileCredentialsProvider());
Region usWest2 = Region.getRegion(Regions.US_WEST_2);
dynamoDBClient.setRegion(usWest2);
// Set DynamoDB Local Endpoint
dynamoDBClient.setEndpoint("http://localhost:8000");
Once you are comfortable with your development and you are ready to use the actual Dy-
namoDB, simply remove the highlighted line from the previous code snippet and you are
done. Everything will work as expected.
Search WWH ::




Custom Search