How to Connect to GridDB Cloud from a Remote Java Application? - Stack Overflow

admin2025-04-15  1

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
  1. 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.UnknownHostException:

What I've tried:

  • Double-checked that my IP is whitelisted on the GridDB Cloud settings.
  • Verified that the database user and password are correct.
  • Ensured that port 10001 is open on my network.
  • Tried pinging the GridDB Cloud host, but got no response.

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?
转载请注明原文地址:http://www.anycun.com/QandA/1744721159a86698.html