Amazon QLDB driver for Java
Important
End of support notice: Existing customers will be able to use Amazon QLDB until end of support on 07/31/2025. For more details, see
Migrate an Amazon QLDB Ledger to Amazon Aurora PostgreSQL
To work with data in your ledger, you can connect to Amazon QLDB from your Java application by using an AWS provided driver. The following topics describe how to get started with the QLDB driver for Java.
Topics
Driver resources
For more information about the functionality supported by the Java driver, see the following resources:
Prerequisites
Before you get started with the QLDB driver for Java, you must do the following:
-
Follow the AWS setup instructions in Accessing Amazon QLDB. This includes the following:
-
Sign up for AWS.
-
Create a user with the appropriate QLDB permissions.
-
Grant programmatic access for development.
-
-
Set up a Java development environment by downloading and installing the following:
-
Java SE Development Kit 8, such as Amazon Corretto 8.
-
(Optional) Java integrated development environment (IDE) of your choice, such as Eclipse
or IntelliJ .
-
-
Configure your development environment for the AWS SDK for Java by Setting your default AWS credentials and Region.
Next, you can download the complete tutorial sample application—or you can install only the driver in a Java project and run short code examples.
-
To install the QLDB driver and the AWS SDK for Java in an existing project, proceed to Installation.
-
To set up a project and run short code examples that demonstrate basic data transactions on a ledger, see the Quick start tutorial.
-
To run more in-depth examples of both data and management API operations in the complete tutorial sample application, see the Java tutorial.
Setting your default AWS credentials and Region
The QLDB driver and the underlying AWS SDK for Java
As part of these steps, you should also set your default AWS Region to determine your default QLDB endpoint. The code examples connect to QLDB in your default AWS Region. For a complete list of Regions where QLDB is available, see Amazon QLDB endpoints and quotas in the AWS General Reference.
The following is an example of an AWS credentials file named
~/.aws/credentials
, where the tilde character (~
)
represents your home directory.
[default] aws_access_key_id =
your_access_key_id
aws_secret_access_key =your_secret_access_key
Substitute your own AWS credentials values for the values
your_access_key_id
and
your_secret_access_key
.
Installation
QLDB supports the following Java driver versions and their AWS SDK dependencies.
To install the QLDB driver, we recommend using a dependency management system, such as Gradle or Maven. For example, add the following artifact as a dependency in your Java project.
For short code examples of how to run basic data transactions on a ledger, see the Cookbook reference.
Other optional libraries
Optionally, you can also add the following useful libraries in your project. These artifacts are required dependencies in the Java tutorial sample application.
-
aws-java-sdk-qldb
– The QLDB module of the AWS SDK for Java. The minimum QLDB supported version is 1.11.785
.Use this module in your application to interact directly with the management API operations listed in the Amazon QLDB API reference.
-
jackson-dataformat-ion
– FasterXML's Jackson data format module for Ion. The sample application requires version 2.10.0
or later.