简体   繁体   English

Cassandra数据库连接问题

[英]Cassandra DB Connection Issue

I am unable to connect to Cassandra DB. 我无法连接到Cassandra DB。 I have tried with port number 9042 but it is throwing an exception given below 我尝试使用端口号9042,但是它引发了下面给出的异常

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

Due to that I am using port number 9160 for the same. 因此,我将端口号9160用于相同的端口。 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);

The URL is not correct you have a problem in this URL : URL不正确,您对此网址有疑问:

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

Here is the syntax you should to follow : 这是您应遵循的语法:

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

So for example : 因此,例如:

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

So in place of server name you should to specify the @IP of your database or the right host. 因此,应使用server name的@IP或正确的主机代替server name

Second after the port number 9160/schema you should to specify the name of your database and not the schema. 在端口号9160/schema之后的第二个位置,您应该指定数据库的名称,而不是模式。

Take a look at : 看一眼 :

EDIT 编辑

As @Mark Rotteveel mention : ..Or the port is wrong, or the port isn't open on the accessible IP address for that hostname 就像@Mark Rotteveel提到的那样:..或者端口错误,或者该主机名的可访问IP地址上的端口未打开

so make sure that this port is open on the accessible IP address for that host name. 因此,请确保在该主机名的可访问IP地址上打开此端口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM