Wanderer
Wanderer

Reputation: 1647

Cassandra 0.7.4 - Using Java, how to I associate a keyspace for a request?

Formerly, the Java interface for Cassandra included the keyspace in the calls... so an insert was performed by using the Cassandra.Client.insert(keyspace, etc...). Now (at least in 0.7.4) the keyspace has been removed. I have read that this was considered redundant. Ok... but how do I provide the keyspace to my Java app will run?

I still connect via the TSocket and TBinaryProtocol, I assume. I can still create the Cassandra.Client object ok.... but when I make a call, such as an insert, I cannot find a place to specified (or use) which keyspace I want. The app fails now, and I assume it is because I have not supplied a keyspace anywhere.

Thanks, in advance

Upvotes: 0

Views: 394

Answers (1)

DNA
DNA

Reputation: 42586

In Cassandra 0.7.4, you generally login to the Keyspace separately, before making ColumnFamily operations.

In the CLI, you do "use MyKeyspace;"

It seems from example code in another question and also this that you do the following in the Java Thrift interface:

client.set_keyspace(KEYSPACE_NAME);

Upvotes: 2

Related Questions