Exception connecting to Cassandra using CQL using the DataStax Java 1.0.4 driver

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.

+4
3

, documentation.

cassandra.yaml Cassandra Native Transport. , :

# Whether to start the native transport server.
start_native_transport: true
# port for the CQL native transport to listen for clients on
native_transport_port: 9042 

Cassandra CQL 3.0. , , , :

Cluster cluster = new Cluster.Builder()
        .addContactPoints("localhost")
        .withPort(9042)
        .build();

, Cassandra 1.2.5 .

+11

java cassandra.

+3

I have the same problem on Ubuntu. I recently installed the command below which was a datastax directive

apt-get install cassandra = 2.0.11 dsc20 = 2.0.11-1

before that I only used

apt-get install cassandra

then for me the same problem. I just uninstalled and installed it using the first command (datastax directive).

PS To remove cassandra use the command

apt-get purge cassandra

0
source

All Articles