Amazon DynamoDB
Developer Guide (API Version 2012-08-10)

Using the AWS SDK for Java

The AWS SDK for Java provides APIs for the DynamoDB item and table operations. The SDK allows you to choose from among three different APIs for DynamoDB:

  • Document API

  • DynamoDB Mapper

  • Low-Level API


These APIs provide thread-safe clients for accessing DynamoDB. As a best practice, your applications should create one client and reuse the client between threads.

Document API

The Document API provides an intuitive interface for DynamoDB operations. With this API, you work with tables, items, attributes, and other objects that closely resemble their counterparts in the DynamoDB. The Document API also provides utilities for working with document data types, such as Lists and Maps. Finally, the document API makes it easy to store and retrieve JSON documents in DynamoDB.

The following sections describe the Document API, and also provide code samples:


The DynamoDBMapper class uses object persistence programming techniques to map Java objects to DynamoDB tables and attributes. The DynamoDBMapper class provides an object-oriented view of your data: You define getter and setter methods for items in a table, and DynamoDBMapper insulates your application from low-level DynamoDB operations. You cannot create tables using the high-level API, but you can create, read, update, and delete table items.

Low-level API

The methods in the low-level API correspond closely to the underlying DynamoDB API. The low-level API allows you to perform the same operations that you can perform using DynamoDB operations for managing tables (creating, updating, deleting) and items in the tables (creating, reading, updating, deleting).

Running Java Code Samples for DynamoDB

To Run the Java Code Samples (using Eclipse)

  1. Download and install the AWS Toolkit for Eclipse. This toolkit includes the AWS SDK for Java, along with preconfigured templates for building applications.

  2. From the Eclipse menu, click File, New, Other....

    In the Select a wizard box, click File, AWS Java Project, Click Next.In the Project name field, type a name for your project. Click Finish to create the project. Note that the project is pre-configured, and includes the AWS SDK for Java .jar files.

  3. You will now need to create a default credential profiles file. This file enhances security by storing your credentials separately from your project directories, so that they cannot be unintentionally committed to a public repository. For more information, see Using the Default Credential Provider Chain in the AWS SDK for Java Developer Guide.

    The credential properties file should be saved as ~/.aws/credentials, where the tilde character represents your home directory. In this file, you can store multiple sets of credentials from any number of accounts. Each set is referred to as a profile. The following is an example of a credential properties file with a profile named default:

    aws_access_key_id = <Your Access Key ID>
    aws_secret_access_key = <Your Secret Key>

    The code examples in this document use the default client constructors that read your AWS credentials stored in the credential properties file.

  4. Copy the code from the section that you are reading to your project.

  5. Run the code.