为什么我无法连接到 cassandra [英] Why cant I connect to cassandra

查看:27
本文介绍了为什么我无法连接到 cassandra的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的笔记本电脑上有一个基本的 cassandra 设置,它已启动,我可以使用命令行工具连接到它,但是在 java 中,以下失败:

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

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

任何线索都会非常有帮助,谢谢!错误是:

Any clues would be really helpful, thanks! The error is:

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)

推荐答案

听起来您的 cassandra 服务器没有运行.通过任务管理器或 telnet 127.0.0.1 9160

Sounds like your cassandra server isn't running. Check that the server is running via the task manager or telnet 127.0.0.1 9160

如果您得到以下 cassandra 未运行:

If you get the below cassandra isn't running:

telnet: Unable to connect to remote host: Connection refused

至于 jdbc 库,第一条建议,使用 DataStax 驱动程序(您可以添加一个 maven 依赖),第二条建议...也将 maven 用于 jdbc.将依赖项添加到 Maven 项目中,然后使用 上的代码页维基.

As for the jdbc library, 1st piece of advice, use the DataStax driver (you can just add a maven dependency), second piece of advice... use maven for jdbc too. Add the dependency into a maven project and then used the code page on the wiki.

依赖:

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

这篇关于为什么我无法连接到 cassandra的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆