I have Cassandra 1.2.11 working on my laptop. I can connect to it using nodetooland cqlsh, but when I try to use the Java DataStax 1.0.4 API to connect using CQL 3.0, I get the following error:
com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: localhost/127.0.0.1 ([localhost/127.0.0.1] Unexpected error during transport initialization (com.datastax.driver.core.TransportException: [localhost/127.0.0.1] Channel has been closed)))
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:186)
I use the following connection code taken from the DataStax documentation. I tried several port numbers, including leaving a call withPort(), but nothing works.
Cluster cluster = new Cluster.Builder()
.addContactPoints("localhost")
.withPort(9160)
.build();
Using telnet, I can verify that the Cassandra server is definitely listening on each of the ports that I specified. I also verified that all the necessary jar file libraries are in my class path, as described in the documentation.