InvalidRequestException Keyspace keyspace1 does not exist

2.8k views Asked by At

I'm trying to connect to a Datastax Community Edition server 2.1.2 via JDBC but I keep getting the following error no matter what I try to do, even when issuing a very basic command like select * from system_traces.events;

InvalidRequestException(why:Keyspace 'keyspace1' does not exist)

Issuing that same command via cqlsh works properly, so it seems to be a JDBC issue.

InvalidRequestException(why:Keyspace 'keyspace1' does not exist) 
    at org.apache.cassandra.cql.jdbc.CassandraConnection.<init>(CassandraConnection.java:229):229 
    at org.apache.cassandra.cql.jdbc.CassandraDriver.connect(CassandraDriver.java:92):92 
    at java.sql.DriverManager.getConnection(DriverManager.java:664):664 
    at java.sql.DriverManager.getConnection(DriverManager.java:270):270 
    at railo.commons.db.DBUtil.getConnection(DBUtil.java:109):109 
    at railo.runtime.db.DatasourceConnectionPool.loadDatasourceConnection(DatasourceConnectionPool.java:89):89 
    at railo.runtime.db.DatasourceConnectionPool.getDatasourceConnection(DatasourceConnectionPool.java:81):81 
    at railo.runtime.db.DatasourceManagerImpl.getConnection(DatasourceManagerImpl.java:65):65 
    at railo.runtime.tag.Query.executeDatasoure(Query.java:696):696 ...

Any ideas? TIA!

1

There are 1 answers

1
Lyuben Todorov On BEST ANSWER
InvalidRequestException(why:Keyspace 'keyspace1' does not exist) 

This exception means you are trying to query for a keyspace (in this case "Keyspace1") that hasn't yet been added to Cassandra. Try creating the keyspace before querying it.

You're probably doing a select (SELECT * FROM "Keyspace1"."Standard1") that you're not seeing or passing initialisation parameters to JDBC telling it to connect to Keyspace1. Verify that your code isn't looking for the non-existent keyspace by searching through the queries you have, specifically looking for Keyspace1 (or "Keyspace1" since in this case the keyspace name is case-sensitive).

On a side-note, "Keyspace1"."Standard1" tend to be the standard ks.cf pair used for cassandra examples so it would be good to scan your code for them to make sure that they are created before they are queried.