如何在Java中的Gemfire 9.6区域上访问OQL查询

时间:2019-04-15 16:20:12

标签: unix gemfire oql

I am using Gemfire pivotal for the first time and I need someone who can help me with below question. The Gemfire Pivotal 9.6 is installed on Unix server and I am able to connect to Unix with no issue. I am inside unix now, but I can't access Gemfire. 

Q. How to Access OQL Query on a Gemfire 9.6 Region in java.

这是我连接到Unix的方式。

  

private String host =“主机名去了这里”;         private String port =“这里的端口号”;         private String user =“ userID”;         私人字符串密码=“密码”         private String SSH命令=“ ssh ------”         private String commandBah =“ bash”;         私人字串commandgfish =“ sh /data/gemfire9.6/pivotal-gemfire-9.6.0/bin/gfsh”;

        This is the way I am trying to connect to Gemfire which is not working properly now.



// Gemfire Connection URL, username and password 
            private String connect To Gemfire = "connect --locator=--------";
            private String username = "credential";--
            private String command Pass = "password"
            private String comman Setvariable  = "set variable --name=APP_RESULT_VIEWER --value=EXTERNAL";

1 个答案:

答案 0 :(得分:0)

要访问Java中的区域,您需要创建GemFire客户端。这是创建GemFire客户端并执行查询的基本Java代码段:

ClientCache cache = new ClientCacheFactory()
      .addPoolLocator(locator_host, 10334)
      .create()
cache.getQueryService().newQuery("select count(*) from /region").execute()

有关更完整的示例,您可以查看geode示例项目(GemFire基于Geode)。以下是从客户端查询的示例:https://github.com/apache/geode-examples/tree/master/indexes