Ahmed Ben Khelifa
Ahmed Ben Khelifa

Reputation: 11

How to Connect to GridDB Cloud from a Remote Java Application?

I recently started exploring GridDB Cloud, and I want to connect to my instance from a Java application running on a different machine. I've followed the GridDB Cloud Quick Start Guide and performed the following steps:

1-Whitelisted my IP on the GridDB Cloud portal.

2-Created a database user with the necessary credentials.

3-Checked my database URL, which follows this pattern:

griddb://<host>:<port>/defaultCluster

4-Used the Java GridDB Client to attempt a connection:

import com.toshiba.mwcloud.gs.*;

public class GridDBCloudTest {
    public static void main(String[] args) {
        try {
            Properties properties = new Properties();
            properties.setProperty("host", "<my-cloud-host>");
            properties.setProperty("port", "10001");
            properties.setProperty("clusterName", "defaultCluster");
            properties.setProperty("user", "<my-user>");
            properties.setProperty("password", "<my-password>");

            GridStoreFactory factory = GridStoreFactory.getInstance();
            GridStore store = factory.getGridStore(properties);
            System.out.println("Connected successfully!");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

**Issue: ** When running the Java application, I get the following error:

com.toshiba.mwcloud.gs.GSException: Failed to connect to GridDB Caused by: java.net.UnknownHostException:

**What I've Tried: **- Double-checked that my IP is whitelisted on the GridDB Cloud settings.

**Questions: **

  1. Is there a different connection string format I should use for GridDB Cloud?
  2. Do I need to configure additional firewall rules beyond IP whitelisting?
  3. Is there a specific Java client version required for GridDB Cloud?

Any guidance would be greatly appreciated!

Upvotes: 1

Views: 24

Answers (0)

Related Questions