Why can't I connect to cassandra

I have a basic cassandra installation on my laptop and I can connect to it using command line tools, however in java the following errors:

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

Any hints would be really helpful, thanks! 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) 
+4
source share
2 answers

It looks like your cassandra server is not working. Make sure that the server is running through the task manager or telnet 127.0.0.1 9160

If you get the lower cassandra, it does not work:

 telnet: Unable to connect to remote host: Connection refused 

As for the jdbc library, 1st tip, use the DataStax driver (you can just add the maven dependency ), second part of the tip ... use maven for jdbc too. Add the dependency to the maven project, and then use the codepage on the wiki .

Dependence:

 <dependency> <groupId>org.apache-extras.cassandra-jdbc</groupId> <artifactId>cassandra-jdbc</artifactId> <version>1.2.5</version> </dependency> 
+6
source

Make sure Cassandra is working! :)

0
source

Source: https://habr.com/ru/post/1496140/


All Articles