【发布时间】:2021-05-02 07:00:03
【问题描述】:
我想确保我可以不时地从 Java 服务连接到数据库(例如 ping)。这个answer 建议使用show version。
我的 Java 服务正在使用 Cassandra thrift 客户端(已弃用),但我找不到如何执行此类查询的示例。
我有一个client 类型的org.apache.cassandra.thrift.Cassandra.Client。
这些是我发现的类似方法:
System.out.println("describe_schema_versions: " + nativeClient.describe_schema_versions());
System.out.println("describe_version: " + nativeClient.describe_version());
System.out.println("describe_snitch: " + nativeClient.describe_snitch());
System.out.println("describe_cluster_name: " + nativeClient.describe_cluster_name());
System.out.println("describe_keyspaces: " + nativeClient.describe_keyspaces());
System.out.println("describe_partitioner: " + nativeClient.describe_partitioner());
System.out.println("describe_token_map: " + nativeClient.describe_token_map());
如何执行查询以获取这样的 Cassandra 服务器版本?
cqlsh> show version;
[cqlsh 3.1.8 | Cassandra 1.2.19 | CQL spec 3.0.5 | Thrift protocol 19.36.2]
或者是否有首选的替代查询作为“ping”?
【问题讨论】:
-
这个答案可能会有所帮助:stackoverflow.com/questions/10246287/…