Cassandra Database has been installed on a server machine with following configurations : cqlsh 4.1.1 | Cassandra 2.0.7.31 | CQL spec 3.1.1 | Thrift protocol 19.39.0
I wanted to connect to a keyspace say "X" via eclipse through java.
Following is my code :
package cassandraConnectivity;
import java.sql.DriverManager;
import java.sql.SQLException;
public class connect{
public static java.sql.Connection con = null;
public static void main(String[] a)throws ClassNotFoundException, SQLException{
try {
Class.forName("org.apache.cassandra.cql.jdbc.CassandraDriver");
con=DriverManager.getConnection("jdbc:cassandra:username/pswd@<IP>/<KS>");
System.out.println("cassandra connection established");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
I have also added following jar files to my eclipse build path :
- apache-cassandra-0.8.4.jar
- apache-cassandra-cql-1.0.3.jar
- apache-cassandra-thrift-0.8.4.jar
- casssandra-clientutil-1.2.1.jar
- cassandra-jdbc-1.2.5.jar
- commons-lang-2.4.jar
- guava-r08.jar
- libthrift-0.6.jar
- log4j-1.2.16.jar
- slf4j-log4j12-1.6.1.jar
- slf4j.api-1.6.1.jar
I have also disabled the firewall at the remote location where cassandra is installed
But despite this I am getting an error :
Exception in thread "main" org.apache.cassandra.cql.jdbc.DriverResolverException: java.net.ConnectException: Connection refused: connect at org.apache.cassandra.cql.jdbc.CassandraConnection.(CassandraConnection.java:91) at org.apache.cassandra.cql.jdbc.CassandraDriver.connect(CassandraDriver.java:86) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at cassandraConnectivity.connect.main(connect.java:15)
Also it is not able to find the source for the above jar files that were added externally
Kindly let me know where i am going wrong