【发布时间】:2013-12-22 22:51:45
【问题描述】:
我的笔记本电脑上运行着 Cassandra 1.2.11。我可以使用 nodetool 和 cqlsh 连接到它,但是当我尝试使用 DataStax 1.0.4 Java API 使用 CQL 3.0 进行连接时,我收到以下错误:
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)
我使用以下代码进行连接,取自 DataStax 文档。我已经尝试了几个端口号,包括将 withPort() 呼叫保留,但似乎没有任何效果。
Cluster cluster = new Cluster.Builder()
.addContactPoints("localhost")
.withPort(9160)
.build();
使用telnet 我可以验证Cassandra 服务器确实在监听我指定的每个端口。我还验证了所有必需的库 jar 文件都在我的类路径中,如文档中所述。
【问题讨论】:
标签: java cassandra cql3 datastax-java-driver