简体   繁体   中英

How to get Gemfire data into Resultset and iterate in java?

String queryString = "SELECT * FROM /items";
ClientCache cache = new ClientCacheFactory().create();
QueryService queryService = cache.getQueryService();
Query query = queryService.newQuery(queryString);

SelectResults results = (SelectResults)query.execute();

I want to get the results data into resultset like rdbms. Is there any way to get the data in resultset and iterate using java?

I believe you really need to go through the GemFire User Guide if you want to get proficient on its usage and understand how things work. Regarding this particular question, please have a look at the Querying chapter, it contains useful examples and explanations.

In short, you can iterate through SelectResults doing something like the following:

SelectResults<YourEntity> results = (SelectResults<YourEntity>) query.execute();
for (Iterator<YourEntity> iterator = results.iterator(); iterator.hasNext();) {
    YourEntity entity = iterator.next();
    System.out.println(entity);
}

The code above assumes, among other things, that the region items is populated with instances of the class YourEntity and that the class itself is deployed to the server's class path. Cheers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM