Kona Laxman Deepak
Kona Laxman Deepak

Reputation: 280

How to get the keyspace name from cassandra session

While i am creating the session giving the keyspace_name as input for the API cluster.connect(keyspaceName).Is there anyway/api where i can get the keyspace_name from the session?

Session Creation

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

How to get keyspace from existing cassandra DB session?

session.getXXXXX?

Upvotes: 2

Views: 987

Answers (1)

Dmytro Nosan
Dmytro Nosan

Reputation: 196

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();

Upvotes: 3

Related Questions