【问题标题】:How to get the keyspace name from cassandra session如何从 cassandra 会话中获取键空间名称
【发布时间】:2019-10-14 23:20:52
【问题描述】:

当我创建会话时,将 keyspace_name 作为 API cluster.connect(keyspaceName) 的输入。无论如何/api 我可以从会话中获取 keyspace_name 吗?

会话创建

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

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

session.getXXXXX?

【问题讨论】:

    标签: database cassandra datastax-java-driver


    【解决方案1】:
    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();
    

    【讨论】:

      猜你喜欢
      • 2016-02-13
      • 2015-06-16
      • 2011-11-30
      • 2011-05-17
      • 2015-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-12
      相关资源
      最近更新 更多