Exception when connecting to Cassandra with CQL using DataStax Java driver 1.0.4

牧云@^-^@ 提交于 2019-12-04 12:47:53

It turns out I missed a section in the documentation.

I was using an old cassandra.yaml configuration file from an earlier version of Cassandra and it didn't enable the Native Transport binary protocol. The following snippet shows the settings that I needed to change:

# Whether to start the native transport server.
start_native_transport: true
# port for the CQL native transport to listen for clients on
native_transport_port: 9042 

After restarting Cassandra the client was able to connect successfully and run CQL 3.0 commands. Note that the code to create the connection must be changed to use the port specified in the file, like this:

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

Also, note that from Cassandra 1.2.5 and above, the native transport is enabled by default.

You also get this error when trying to use an old version of the java driver with a newer cassandra version.

I have the same issue in Ubuntu. I installed recently with the below command which was the datastax guideline

apt-get install cassandra=2.0.11 dsc20=2.0.11-1

before that I used just

apt-get install cassandra

then it makes the same issue for me. I just removed then installed it with the first command (datastax guideline).

P.S. For remove the cassandra use below command

apt-get purge cassandra

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