Chinmay Pawar
Chinmay Pawar

Reputation: 11

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

Upvotes: 1

Views: 1526

Answers (1)

Youcef LAIDANI
Youcef LAIDANI

Reputation: 59950

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.

Upvotes: 1

Related Questions