Work with DynamoDB - Amazon SDK for Java 2.x
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Work with DynamoDB

DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability. This section shows you how to work with DynamoDB using the Amazon SDK for Java 2.x.

Choose your DynamoDB client

The SDK provides two main approaches for working with DynamoDB:

Low-level client (DynamoDbClient)

Provides direct access to DynamoDB operations with full control over requests and responses. Use this client when you need fine-grained control or work with dynamic schemas.

Enhanced client (DynamoDbEnhancedClient)

Offers object-oriented programming with automatic mapping between Java objects and DynamoDB items. Also provides document-oriented capabilities for working with JSON-like data that doesn't follow a fixed schema. Use this client when working with well-defined data models or document-type data.

Configure DynamoDB clients

Before working with DynamoDB, configure your client for optimal performance and reliability.

Understand DynamoDB retry behavior

DynamoDB clients use a default maximum retry count of 8, which is higher than other Amazon Web Services service clients. This higher retry count helps handle DynamoDB's distributed nature and temporary capacity limitations. For more information about retry strategies, see Configure retry behavior in the Amazon SDK for Java 2.x.

Optimize performance with account-based endpoints

DynamoDB offers Amazon account-based endpoints that improve performance by using your Amazon account ID to streamline request routing.

To use this feature, you need version 2.28.4 or greater of the Amazon SDK for Java 2.x. You can find the latest version in the Maven central repository. Supported SDK versions automatically use the new endpoints.

To opt out of account-based routing, choose one of these options:

  • Configure a DynamoDB service client with AccountIdEndpointMode set to DISABLED.

  • Set an environment variable.

  • Set a JVM system property.

  • Update the shared Amazon config file setting.

The following example shows how to disable account-based routing by configuring a DynamoDB service client:

DynamoDbClient.builder() .accountIdEndpointMode(AccountIdEndpointMode.DISABLED) .build();

For more information about the other configuration options, see Account-based endpoints in the Amazon SDKs and Tools Reference Guide.

What's covered in this topic

The following sections show you how to work with DynamoDB:

For additional DynamoDB code examples, see DynamoDB code examples in the Amazon Code Examples Library.