Cassandra数据库连接问题 [英] Cassandra DB Connection Issue

查看:295
本文介绍了Cassandra数据库连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法连接到Cassandra DB.我已经尝试使用端口号9042,但是它引发了下面给出的异常

I am unable to connect to Cassandra DB. I have tried with port number 9042 but it is throwing an exception given below

java.sql.SQLNonTransientConnectionException: org.apache.thrift.transport.TTransportException: Read a negative frame size (-2097152000)!. 

由于我使用的是9160端口.但这给了我下面的例外

Due to that I am using port number 9160 for the same. But it is giving me below exception

[main] ERROR org.bigsql.cassandra2.jdbc.CassandraConnection - Impossible to connect to server Server Name : org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection timed out: connect

请提供相同的解决方案.请参见下面我用于连接的代码.

Please provide the solution on the same. Please see below code that I am using for connection.

URL="jdbc:cassandra://server name:9160/schema";
address =address;
user=Username;
pass=Password;
Class.forName("org.bigsql.cassandra2.jdbc.CassandraDriver");
conn = DriverManager.getConnection(URL,user,pass);

推荐答案

URL不正确,说明您在此URL中有问题:

The URL is not correct you have a problem in this URL :

URL="jdbc:cassandra://server name:9160/schema";

这是您应遵循的语法:

jdbc:cassandra://host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[keyspace][?options]]

例如:

URL="jdbc:cassandra://10.6.99.99:9160/dbname";

因此,代替server name,您应该指定数据库的@IP或正确的主机.

So in place of server name you should to specify the @IP of your database or the right host.

在端口号9160/schema的第二个之后,您应该指定数据库的名称,而不是模式.

Second after the port number 9160/schema you should to specify the name of your database and not the schema.

看看:

  • cassandra jdbc driver
  • cassandra jdbc

编辑

就像@Mark Rotteveel提到的那样:..或者端口错误,或者端口不是 在该主机名的可访问IP地址上打开

As @Mark Rotteveel mention : ..Or the port is wrong, or the port isn't open on the accessible IP address for that hostname

因此请确保在该主机名的可访问IP地址上打开此端口.

so make sure that this port is open on the accessible IP address for that host name.

这篇关于Cassandra数据库连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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