Updated on 2026-07-10 GMT+08:00

Connecting to a GeminiDB DynamoDB-Compatible Instance Using Java

This section describes how to connect to a GeminiDB DynamoDB-Compatible instance using Java.

Usage Notes

  • The instance and ECS must be in the same region, VPC, and subnet.
  • The ECS must be allowed by the security group associated with the instance.

    Scenario 1: If the instance is associated with the default security group, you do not need to set security group rules.

    Scenario 2: If the instance is not associated with the default security group, check whether the security group rules allow access from the ECS.

Prerequisites

  • A GeminiDB DynamoDB-Compatible instance has been created.
  • An ECS has been created. For details about how to create an ECS, see Purchasing an ECS in the Elastic Cloud Server documentation.
  • JDK has been installed on the ECS.

Obtaining the Connection Address of a GeminiDB DynamoDB-Compatible Instance

  1. Log in to the Huawei Cloud console.
  2. On the Instances page, click the target instance name. On the displayed Basic Information page, view the load balancer address.

    If no load balancer address is available, submit a service ticket on the console to contact the customer service.

    Figure 1 Viewing the IP address

Java Connection Code

Replace the IP address in the following code example with the load balancer address queried in 2.

Java code example:

public class ClientExample {  
    public static AWSCredentialsProvider myCredentials = new AWSStaticCredentialsProvider(new BasicAWSCredentials("rwuser", "your_pwd"));  
    public static void main(String[] args) {  
        AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()  
            .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("http://ip", "cn-north-1"))
            .withCredentials(myCredentials)  
            .build();  
        DynamoDB dynamoDB = new DynamoDB(client);  
        TableCollection res = dynamoDB.listTables();  
        System.out.println(res);  
    }  
}