2

I'm using Cassandra 1.2.6 with Astyanax. I created a keyspace named DummyKeyspace with using Java. I can reach that keyspace from cassandra-cli but not from cqlsh. Why?

Here is my Java code:

public void createKeyspace(Cluster cluster,String KEYSPACE_NAME,String STRATEGY, String REPLICA_FACTOR) throws ConnectionException
    {
        if(cluster.describeKeyspace(KEYSPACE_NAME) == null)
        {
            KeyspaceDefinition ksDef = cluster.makeKeyspaceDefinition();

            Map<String,String> stratOptions = new HashMap<String,String>();
            stratOptions.put("replication_factor", REPLICA_FACTOR);

            ksDef.setName(KEYSPACE_NAME)
                .setStrategyOptions(stratOptions)
                .setStrategyClass(STRATEGY);

            cluster.addKeyspace(ksDef);
            System.out.println("Keyspace " + KEYSPACE_NAME + " created and added to cluster.");
        }
        else
        {
            System.out.println("Keyspace " + KEYSPACE_NAME + " already existed.");
        }
    }

Here is the error when I tried to reach it:

cqlsh> USE DummyKeyspace;
Bad Request: Keyspace 'dummykeyspace' does not exist
shyos
  • 1,390
  • 1
  • 16
  • 29
  • 2
    Is that copypasta? How did you get bad request for 'twitter2' when you did use 'DummyKeyspace'? – Richard Aug 12 '13 at 08:53
  • oh sorry, I forgot to change that part. I usually dont use actual names of the code segments when I sharing it in public. So thats why it is there. edited. – shyos Aug 12 '13 at 09:09
  • and yes its my code not copypasta. – shyos Aug 12 '13 at 09:10
  • What does `describe keyspaces;` output in cqlsh? – Richard Aug 12 '13 at 09:14
  • output: `DummyKeyspace system tempks system_auth tempks1 system_traces` – shyos Aug 12 '13 at 09:16
  • Okey, so we can say it is visible but not reachable. – shyos Aug 12 '13 at 09:19
  • 1
    Well, thanks to your comment, I realized that cql lowercases the keyspace name, thus I can't reach it. I tried to create keyspace with lowercase and it worked. Then looked-up for uppercase solution and here it is: `USE "DummyKeyspace"` – shyos Aug 12 '13 at 09:31

2 Answers2

3

Try enclosing the keyspace within quotes ""

Piyush Mattoo
  • 15,454
  • 6
  • 47
  • 56
2

I created a ticket about this (CASSANDRA-5879). Maybe the intention is to use quotes, but it is unintuitive. You can also use the -k command line argument to cqlsh.

Richard
  • 11,050
  • 2
  • 46
  • 33