Question

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
Était-ce utile?

La solution 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.

Autres conseils

Try enclosing the keyspace within quotes ""

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top