1

I'm encountering an error while executing a query in GridDB. The error message I receive is Statement execution failed, but I'm not sure what is causing this issue.

import com.toshiba.mwcloud.gs.*;

public class GridDBQueryExample {
    public static void main(String[] args) {
        try {
            // Establish a connection to GridDB
            GridStoreFactory factory = GridStoreFactory.getInstance();
            GridStore store = factory.getStore(new URI("griddb://<hostname>:<port>/<clusterName>"), "<username>", "<password>");

            // Get the container
            ContainerInfo containerInfo = new ContainerInfo();
            Container container = store.getContainer("my_container");

            // Execute the query
            Query<Row> query = container.query("SELECT * FROM my_container WHERE column_name = 'value'");
            RowSet<Row> rowSet = query.fetch();

            // Process the result
            while (rowSet.hasNext()) {
                Row row = rowSet.next();
                // Do something with the row data
            }

            // Close the connection
            store.close();

        } catch (GSException e) {
            e.printStackTrace();
            System.err.println("Error Message: " + e.getMessage()); // Error statement
        }
    }
}

I was expecting the query to retrieve the rows from my_container that match the specified condition.

Why does this error occur and how to resolve it?

desertnaut
  • 57,590
  • 26
  • 140
  • 166

0 Answers0