Can't connect to local cassandra via java driver

谁说我不能喝 提交于 2019-12-12 03:04:12

问题


(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.


回答1:


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.



来源:https://stackoverflow.com/questions/37533926/cant-connect-to-local-cassandra-via-java-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!