简体   繁体   中英

Cassandra DB Connection Issue

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)!. 

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);

The URL is not correct you have a problem in this 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.

Second after the port number 9160/schema you should to specify the name of your database and not the 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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