【问题标题】:Can't connect to local cassandra via java driver无法通过 java 驱动程序连接到本地 cassandra
【发布时间】:2016-09-28 18:30:30
【问题描述】:

(新手问题)我刚刚安装了 cassandra 3.5(在 linux 上,使用通用包)。目前,它是一个完全原版的安装——我没有修改 conf 文件,也没有创建或添加任何东西。

我可以使用 cqlsh 进行连接,但不能使用 javax java 驱动程序(版本 2.0.2)。例如。如果我跑

BasicConfigurator.configure();
集群集群 = Cluster.builder().addContactPoint("127.0.0.1").build(); System.out.println("\n集群名称:" + cluster.getClusterName()+"\n");
会话会话 = cluster.connect();

结果是

0 [main] 调试 com.datastax.driver.core.Cluster - 使用接触点启动新集群 [/127.0.0.1:9042]

集群名称:cluster1

112 [新 I/O 工作人员 #1] 调试 com.datastax.driver.core.Connection - 与 /127.0.0.1:9042 的连接失效 com.datastax.driver.core.TransportException:[/127.0.0.1:9042] 触发了意外异常(java.lang.IndexOutOfBoundsException:没有足够的可读字节 - 需要 4,最大值为 0)
在 com.datastax.driver.core.Connection$Dispatcher.exceptionCaught(Connection.java:601)
在 org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:112)
...

cluster.connect() 抛出异常。

我怀疑我遗漏了什么。任何建议,将不胜感激。谢谢。

【问题讨论】:

    标签: cassandra datastax-java-driver


    【解决方案1】:

    datastax java 驱动程序 2.0.2 无法连接到 cassandra 3.x+ 集群。升级到 3.0.x(即最新的 3.0.2)应该可以解决此问题。

    您可以在DataStax drivers matrix page 上查看驱动程序版本支持哪些 C* 版本。

    【讨论】:

    • @Andy 你能帮我解决这个question。试图弄清楚我应该使用什么配置来连接到本地 cassandra 节点。
    猜你喜欢
    • 2021-02-09
    • 1970-01-01
    • 2018-04-16
    • 2017-06-23
    • 2015-08-16
    • 1970-01-01
    • 2016-02-18
    • 1970-01-01
    • 2019-02-25
    相关资源
    最近更新 更多