如何从cassandra会话中获取密钥空间名称

时间:2019-05-29 10:59:08

标签: database cassandra datastax-java-driver

我正在创建将keyspace_name用作API cluster.connect(keyspaceName)输入的会话时,反正/ api是否可以从会话中获取keyspace_name?

会话创建

String cKeyspace="inventory_flip"
Session session = cluster.connect(cKeyspace);

如何从现有的cassandra DB会话中获取密钥空间?

session.getXXXXX?

1 个答案:

答案 0 :(得分:2)

public interface Session extends Closeable {

  /**
   * The keyspace to which this Session is currently logged in, if any.
   *
   * <p>This correspond to the name passed to {@link Cluster#connect(String)}, or to the last
   * keyspace logged into through a "USE" CQL query if one was used.
   *
   * @return the name of the keyspace to which this Session is currently logged in, or {@code null}
   *     if the session is logged to no keyspace.
   */
  String getLoggedKeyspace();