1

I am trying to retrieve a GridDB record through a simple Java program. Below shown is my Java program:

package gsSample;
import java.util.Arrays;
import java.util.Properties;

import com.toshiba.mwcloud.gs.Collection;
import com.toshiba.mwcloud.gs.GSException;
import com.toshiba.mwcloud.gs.GridStore;
import com.toshiba.mwcloud.gs.GridStoreFactory;
import com.toshiba.mwcloud.gs.Query;
import com.toshiba.mwcloud.gs.RowKey;
import com.toshiba.mwcloud.gs.RowSet;

public class MyApp1{
//The container schema is defined as a static Class in Java
static class Person{
        @RowKey String name;
        int age;
}

static class HeartRate{
        @RowKey Date ts;
        int heartRate;
        String activity;
}

public static void main (String[ ] args) {

Properties props = new Properties();
Props.setProperty(“notificationAddress”, “239.0.0.1”);
Props.setProperty(“notificationPort”, “31999”);
Props.setProperty(“clusterName”, “defaultCluster”);
Props.setProperty(“user”, “administrator”);
Props.setProperty(“password”, “password”);
GridStore store = GridStoreFactory.getInstance().getGridStore(props);

//Container to perform queries or write records
Collection<String, Person> people = store.putCollection(“PEOPLE”,Person.class);

// Querying
Query<Person> query = col.query(“select * where name = ‘John’”);
RowSet<Person> rs = query.fetch(false);
While (rs.hasNext()){
    //update the searched Row
    Person person1 = rs.next();
    System.out.println(“Name: “+ person1.name + “ Age: “+ person1.age);
}
}
}


But, I get below error when I run my program in CentOS 7.6 terminal. Could you please help me to fix this error?

This is the error message I get in the console screen when I run my Java program.

In this message it shows two errors when I compile my Java program as below:

$ javac MyApp1.java

Error messages:

  1. MyApp1.java:22: error: cannot find symbol @RowKey Date ts;

    symbol: class Date location: class HeartRate

  2. MyApp1.java:46: error: cannot find symbol Query query = col.query("select * where name = 'John'");

symbol: variable col location: class MyApp1

  • The variable `col` is missing. Should it perhaps be `people` instead? – nekman Nov 05 '21 at 14:52
  • Welcome to StackOverflow! It might be more useful to people if you could include the actual error message you get in the question rather than via a link :) – William Patton Nov 05 '21 at 15:58

0 Answers0