cassandra本地连接失败_无法通过java驱动程序连接到本地cassandra

(neophyte question) I've just installed cassandra 3.5 (on linux, using the generic package). At present, it's a completely vanilla installation - I haven't modified the conf file and haven't created or added anything yet.

I can connect using cqlsh but not using the javax java driver (version 2.0.2). E.g. if I run

BasicConfigurator.configure();

Cluster cluster = Cluster.builder().addContactPoint("127.0.0.1").build();

System.out.println("\nCluster name: " + cluster.getClusterName()+"\n");

Session session = cluster.connect();

the result is

0 [main] DEBUG com.datastax.driver.core.Cluster - Starting new cluster with contact points [/127.0.0.1:9042]

Cluster name: cluster1

112 [New I/O worker #1] DEBUG com.datastax.driver.core.Connection - Defuncting connection to /127.0.0.1:9042

com.datastax.driver.core.TransportException: [/127.0.0.1:9042] Unexpected exception triggered (java.lang.IndexOutOfBoundsException: Not enough readable bytes - Need 4, maximum is 0)

at com.datastax.driver.core.Connection$Dispatcher.exceptionCaught(Connection.java:601)

at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:112)

...

The exception is being thrown by cluster.connect().

I suspect I've left something out. Any suggestions would be appreciated. Thanks.

解决方案

datastax java driver 2.0.2 is not capable of connecting to cassandra 3.x+ clusters. Upgrading to 3.0.x (i.e. 3.0.2 which is the latest) should resolve this issue.

For future reference you can see what versions of C* are supported with driver versions on the DataStax drivers matrix page.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值