I am new to Cassandra. I have a Java 6 test program to "select * from table1" using Cassandra 1.1.6, accessing with the Cassandra-jdbc driver 1.1.2, all running on Windows 7. This works fine if table1 has a simple primary key, I get all the columns of all the rows. However, if it has a composite primary key, all I get back is the first column (the value of the key) of the first row and nothing else. If I try to select specific columns from the table with simple PK (e.g. "select user_id, object_type, created_at from table1"), it works fine. If I try this on the table with composite PK, I get errors:
Exception: java.lang.NullPointerException java.lang.NullPointerException at org.apache.cassandra.cql.jdbc.TypedColumn.(TypedColumn.java:45) at org.apache.cassandra.cql.jdbc.CassandraResultSet.createColumn(CassandraResultSet.java:972) at org.apache.cassandra.cql.jdbc.CassandraResultSet.populateColumns(CassandraResultSet.java:156) at org.apache.cassandra.cql.jdbc.CassandraResultSet.(CassandraResultSet.java:130) at org.apache.cassandra.cql.jdbc.CassandraStatement.doExecute(CassandraStatement.java:167) at org.apache.cassandra.cql.jdbc.CassandraStatement.executeQuery(CassandraStatement.java:227) at com.west.testjson.TestJson.TestCassandra(TestJson.java:60) at com.west.testjson.TestJson.main(TestJson.java:160)
Can anyone help me understand what I am doing wrong?
Cassandra-jdbc: cannot select * on column family with composite key
(3 posts) (2 voices)-
Posted 5 months ago #
-
The current cassandra-jdbc driver doesn't support CQL3 with composite keys. DataStax recently released an early version of a driver[1] for the native CQL protocol (which is new in Cassandra 1.2). I would expect adding a JDBC layer on top of the driver core will be happen at some point in the not to distant future, but until then I'm afraid your options are somewhat limited to CQL 2 if you want to access data in Cassandra using JDBC.
[1]http://github.com/datastax/java-driver
Posted 5 months ago # -
OK, thanks for the response. I've switched to using Hector for now.
Posted 5 months ago #
