Error while connecting to Cassandra using Java Driver for Apache Cassandra 1.0 from com.example.cassandra












26















While connecting to Cassandra client using java driver for Cannsandra by DataStax, it is throwing following error..



Exception in thread "main" com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: [/127.0.0.1])



Please suggest...



Thanks!



My java code is like this:



package com.example.cassandra;

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Host;
import com.datastax.driver.core.Metadata;

public class SimpleClient {

private Cluster cluster;

public void connect(String node){

cluster = Cluster.builder().addContactPoint(node).build();
Metadata metadata = cluster.getMetadata();
System.out.println(metadata.getClusterName());
}


public void close()
{
cluster.shutdown();
}

public static void main(String args) {

SimpleClient client = new SimpleClient();
client.connect("127.0.0.1");
client.close();
}









share|improve this question




















  • 1





    Just to add more clarity: I am sure that I am connected to cassandra. Still it is showing this error

    – Saurabh Deshpande
    May 28 '13 at 4:12
















26















While connecting to Cassandra client using java driver for Cannsandra by DataStax, it is throwing following error..



Exception in thread "main" com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: [/127.0.0.1])



Please suggest...



Thanks!



My java code is like this:



package com.example.cassandra;

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Host;
import com.datastax.driver.core.Metadata;

public class SimpleClient {

private Cluster cluster;

public void connect(String node){

cluster = Cluster.builder().addContactPoint(node).build();
Metadata metadata = cluster.getMetadata();
System.out.println(metadata.getClusterName());
}


public void close()
{
cluster.shutdown();
}

public static void main(String args) {

SimpleClient client = new SimpleClient();
client.connect("127.0.0.1");
client.close();
}









share|improve this question




















  • 1





    Just to add more clarity: I am sure that I am connected to cassandra. Still it is showing this error

    – Saurabh Deshpande
    May 28 '13 at 4:12














26












26








26


5






While connecting to Cassandra client using java driver for Cannsandra by DataStax, it is throwing following error..



Exception in thread "main" com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: [/127.0.0.1])



Please suggest...



Thanks!



My java code is like this:



package com.example.cassandra;

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Host;
import com.datastax.driver.core.Metadata;

public class SimpleClient {

private Cluster cluster;

public void connect(String node){

cluster = Cluster.builder().addContactPoint(node).build();
Metadata metadata = cluster.getMetadata();
System.out.println(metadata.getClusterName());
}


public void close()
{
cluster.shutdown();
}

public static void main(String args) {

SimpleClient client = new SimpleClient();
client.connect("127.0.0.1");
client.close();
}









share|improve this question
















While connecting to Cassandra client using java driver for Cannsandra by DataStax, it is throwing following error..



Exception in thread "main" com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: [/127.0.0.1])



Please suggest...



Thanks!



My java code is like this:



package com.example.cassandra;

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Host;
import com.datastax.driver.core.Metadata;

public class SimpleClient {

private Cluster cluster;

public void connect(String node){

cluster = Cluster.builder().addContactPoint(node).build();
Metadata metadata = cluster.getMetadata();
System.out.println(metadata.getClusterName());
}


public void close()
{
cluster.shutdown();
}

public static void main(String args) {

SimpleClient client = new SimpleClient();
client.connect("127.0.0.1");
client.close();
}






cassandra datastax-java-driver






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 22 '13 at 3:18









su-

2,72932338




2,72932338










asked May 28 '13 at 4:11









Saurabh DeshpandeSaurabh Deshpande

3073927




3073927








  • 1





    Just to add more clarity: I am sure that I am connected to cassandra. Still it is showing this error

    – Saurabh Deshpande
    May 28 '13 at 4:12














  • 1





    Just to add more clarity: I am sure that I am connected to cassandra. Still it is showing this error

    – Saurabh Deshpande
    May 28 '13 at 4:12








1




1





Just to add more clarity: I am sure that I am connected to cassandra. Still it is showing this error

– Saurabh Deshpande
May 28 '13 at 4:12





Just to add more clarity: I am sure that I am connected to cassandra. Still it is showing this error

– Saurabh Deshpande
May 28 '13 at 4:12












11 Answers
11






active

oldest

votes


















13














In my case, I ran into this issue as I used the default RPC port of 9160 during connection. One can find a different port for CQL in cassandra.yaml -



start_native_transport: true
# port for the CQL native transport to listen for clients on
native_transport_port: 9042


Once I changed the code to use port 9042 the connection attempt succeeded -



public BinaryDriverTest(String cassandraHost, int cassandraPort, String keyspaceName) {
m_cassandraHost = cassandraHost;
m_cassandraPort = cassandraPort;
m_keyspaceName = keyspaceName;

LOG.info("Connecting to {}:{}...", cassandraHost, cassandraPort);
cluster = Cluster.builder().withPort(m_cassandraPort).addContactPoint(cassandraHost).build();
session = cluster.connect(m_keyspaceName);
LOG.info("Connected.");
}

public static void main(String args) {
BinaryDriverTest bdt = new BinaryDriverTest("127.0.0.1", 9042, "Tutorial");
}





share|improve this answer































    5














    I had this issue and it was sorted by setting the ReadTimeout in SocketOptions:



    Cluster cluster = Cluster.builder().addContactPoint("localhost").build();
    cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(HIGHER_TIMEOUT);





    share|improve this answer

































      4














      Go to your Apache Cassandra conf directory and enable the binary protocol



      Cassandra binary protocol
      The Java driver uses the binary protocol that was introduced in Cassandra 1.2. It only works with a version of Cassandra greater than or equal to 1.2. Furthermore, the binary protocol server is not started with the default configuration file in Cassandr a 1.2. You must edit the cassandra.yaml file for each node:



      start_native_transport: true


      Then restart the node.






      share|improve this answer

































        4














        I was also having same problem. I have installed Cassandra in a separate Linux pc and tried to connect via Window pc. I was not allowed to create the connection.



        But when we edit cassandra.yaml, set my linux pc ip address to rpc_address and restart, it allows me to connect successfully,



        # The address or interface to bind the Thrift RPC service and native transport
        # server to.
        #
        # Set rpc_address OR rpc_interface, not both. Interfaces must correspond
        # to a single address, IP aliasing is not supported.
        #
        # Leaving rpc_address blank has the same effect as on listen_address
        # (i.e. it will be based on the configured hostname of the node).
        #
        # Note that unlike listen_address, you can specify 0.0.0.0, but you must also
        # set broadcast_rpc_address to a value other than 0.0.0.0.
        #rpc_address: localhost
        rpc_address: 192.168.0.10





        share|improve this answer































          3














          Just posting this for people who might have the same problem as I did, when I got that error message. Turned out my complex dependency tree brought about an old version of com.google.collections, which broke the CQL driver. Removing this dependency and relying entirely on guava solved my problem.






          share|improve this answer



















          • 1





            Thanks for your hint, it solved my problem

            – Harsha
            Jan 27 '15 at 14:45



















          3














          I was having the same issue testing a new cluster with one node.



          After removing this from the Cluster builder I was able to connect:



          .withLoadBalancingPolicy(new DCAwareRoundRobinPolicy("US_EAST"))


          It was able to connect.






          share|improve this answer































            2














            In my case this was a port issue, which I forgot to update



            Old RPC port is 9160

            New binary port is 9042






            share|improve this answer































              2














              I too encountered this problem, and it was caused by a simple error in the statement that was being submitted.



              session.prepare(null);


              Obviously, the error message is misleading.






              share|improve this answer































                1














                Edit



                /etc/cassandra/cassandra.yaml 


                and change



                rpc_address to 0.0.0.0,broadcast_rpc_address and listen_address to ip address of the cluster.






                share|improve this answer

































                  0














                  Check below points:



                  i) check server ip



                  ii) check listening port



                  iii) data-stack client dependency must match the server version.



                  About the yaml file, latest versions has below properties enabled:



                      start_native_transport: true
                  native_transport_port: 9042





                  share|improve this answer































                    0














                    Assuming you have default configurations in place, check the driver version compatibility. Not all driver versions are compatible with all versions of Cassandra, though they claim backward compatibility. Please see the below link.



                    http://docs.datastax.com/en/developer/java-driver/3.1/manual/native_protocol/



                    I ran into a similar issue & changing the driver version solved my problem.



                    Note: Hopefully, you are using Maven (or something similar) to resolve dependencies. Otherwise, you may have to download a lot of dependencies for higher versions of the driver.






                    share|improve this answer























                      Your Answer






                      StackExchange.ifUsing("editor", function () {
                      StackExchange.using("externalEditor", function () {
                      StackExchange.using("snippets", function () {
                      StackExchange.snippets.init();
                      });
                      });
                      }, "code-snippets");

                      StackExchange.ready(function() {
                      var channelOptions = {
                      tags: "".split(" "),
                      id: "1"
                      };
                      initTagRenderer("".split(" "), "".split(" "), channelOptions);

                      StackExchange.using("externalEditor", function() {
                      // Have to fire editor after snippets, if snippets enabled
                      if (StackExchange.settings.snippets.snippetsEnabled) {
                      StackExchange.using("snippets", function() {
                      createEditor();
                      });
                      }
                      else {
                      createEditor();
                      }
                      });

                      function createEditor() {
                      StackExchange.prepareEditor({
                      heartbeatType: 'answer',
                      autoActivateHeartbeat: false,
                      convertImagesToLinks: true,
                      noModals: true,
                      showLowRepImageUploadWarning: true,
                      reputationToPostImages: 10,
                      bindNavPrevention: true,
                      postfix: "",
                      imageUploader: {
                      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                      allowUrls: true
                      },
                      onDemand: true,
                      discardSelector: ".discard-answer"
                      ,immediatelyShowMarkdownHelp:true
                      });


                      }
                      });














                      draft saved

                      draft discarded


















                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16783725%2ferror-while-connecting-to-cassandra-using-java-driver-for-apache-cassandra-1-0-f%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown

























                      11 Answers
                      11






                      active

                      oldest

                      votes








                      11 Answers
                      11






                      active

                      oldest

                      votes









                      active

                      oldest

                      votes






                      active

                      oldest

                      votes









                      13














                      In my case, I ran into this issue as I used the default RPC port of 9160 during connection. One can find a different port for CQL in cassandra.yaml -



                      start_native_transport: true
                      # port for the CQL native transport to listen for clients on
                      native_transport_port: 9042


                      Once I changed the code to use port 9042 the connection attempt succeeded -



                      public BinaryDriverTest(String cassandraHost, int cassandraPort, String keyspaceName) {
                      m_cassandraHost = cassandraHost;
                      m_cassandraPort = cassandraPort;
                      m_keyspaceName = keyspaceName;

                      LOG.info("Connecting to {}:{}...", cassandraHost, cassandraPort);
                      cluster = Cluster.builder().withPort(m_cassandraPort).addContactPoint(cassandraHost).build();
                      session = cluster.connect(m_keyspaceName);
                      LOG.info("Connected.");
                      }

                      public static void main(String args) {
                      BinaryDriverTest bdt = new BinaryDriverTest("127.0.0.1", 9042, "Tutorial");
                      }





                      share|improve this answer




























                        13














                        In my case, I ran into this issue as I used the default RPC port of 9160 during connection. One can find a different port for CQL in cassandra.yaml -



                        start_native_transport: true
                        # port for the CQL native transport to listen for clients on
                        native_transport_port: 9042


                        Once I changed the code to use port 9042 the connection attempt succeeded -



                        public BinaryDriverTest(String cassandraHost, int cassandraPort, String keyspaceName) {
                        m_cassandraHost = cassandraHost;
                        m_cassandraPort = cassandraPort;
                        m_keyspaceName = keyspaceName;

                        LOG.info("Connecting to {}:{}...", cassandraHost, cassandraPort);
                        cluster = Cluster.builder().withPort(m_cassandraPort).addContactPoint(cassandraHost).build();
                        session = cluster.connect(m_keyspaceName);
                        LOG.info("Connected.");
                        }

                        public static void main(String args) {
                        BinaryDriverTest bdt = new BinaryDriverTest("127.0.0.1", 9042, "Tutorial");
                        }





                        share|improve this answer


























                          13












                          13








                          13







                          In my case, I ran into this issue as I used the default RPC port of 9160 during connection. One can find a different port for CQL in cassandra.yaml -



                          start_native_transport: true
                          # port for the CQL native transport to listen for clients on
                          native_transport_port: 9042


                          Once I changed the code to use port 9042 the connection attempt succeeded -



                          public BinaryDriverTest(String cassandraHost, int cassandraPort, String keyspaceName) {
                          m_cassandraHost = cassandraHost;
                          m_cassandraPort = cassandraPort;
                          m_keyspaceName = keyspaceName;

                          LOG.info("Connecting to {}:{}...", cassandraHost, cassandraPort);
                          cluster = Cluster.builder().withPort(m_cassandraPort).addContactPoint(cassandraHost).build();
                          session = cluster.connect(m_keyspaceName);
                          LOG.info("Connected.");
                          }

                          public static void main(String args) {
                          BinaryDriverTest bdt = new BinaryDriverTest("127.0.0.1", 9042, "Tutorial");
                          }





                          share|improve this answer













                          In my case, I ran into this issue as I used the default RPC port of 9160 during connection. One can find a different port for CQL in cassandra.yaml -



                          start_native_transport: true
                          # port for the CQL native transport to listen for clients on
                          native_transport_port: 9042


                          Once I changed the code to use port 9042 the connection attempt succeeded -



                          public BinaryDriverTest(String cassandraHost, int cassandraPort, String keyspaceName) {
                          m_cassandraHost = cassandraHost;
                          m_cassandraPort = cassandraPort;
                          m_keyspaceName = keyspaceName;

                          LOG.info("Connecting to {}:{}...", cassandraHost, cassandraPort);
                          cluster = Cluster.builder().withPort(m_cassandraPort).addContactPoint(cassandraHost).build();
                          session = cluster.connect(m_keyspaceName);
                          LOG.info("Connected.");
                          }

                          public static void main(String args) {
                          BinaryDriverTest bdt = new BinaryDriverTest("127.0.0.1", 9042, "Tutorial");
                          }






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jun 25 '13 at 6:00









                          BharadwajBharadwaj

                          7941622




                          7941622

























                              5














                              I had this issue and it was sorted by setting the ReadTimeout in SocketOptions:



                              Cluster cluster = Cluster.builder().addContactPoint("localhost").build();
                              cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(HIGHER_TIMEOUT);





                              share|improve this answer






























                                5














                                I had this issue and it was sorted by setting the ReadTimeout in SocketOptions:



                                Cluster cluster = Cluster.builder().addContactPoint("localhost").build();
                                cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(HIGHER_TIMEOUT);





                                share|improve this answer




























                                  5












                                  5








                                  5







                                  I had this issue and it was sorted by setting the ReadTimeout in SocketOptions:



                                  Cluster cluster = Cluster.builder().addContactPoint("localhost").build();
                                  cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(HIGHER_TIMEOUT);





                                  share|improve this answer















                                  I had this issue and it was sorted by setting the ReadTimeout in SocketOptions:



                                  Cluster cluster = Cluster.builder().addContactPoint("localhost").build();
                                  cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(HIGHER_TIMEOUT);






                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited Dec 23 '15 at 10:12

























                                  answered Feb 25 '14 at 1:24









                                  Aneesh VijendranAneesh Vijendran

                                  2,33412239




                                  2,33412239























                                      4














                                      Go to your Apache Cassandra conf directory and enable the binary protocol



                                      Cassandra binary protocol
                                      The Java driver uses the binary protocol that was introduced in Cassandra 1.2. It only works with a version of Cassandra greater than or equal to 1.2. Furthermore, the binary protocol server is not started with the default configuration file in Cassandr a 1.2. You must edit the cassandra.yaml file for each node:



                                      start_native_transport: true


                                      Then restart the node.






                                      share|improve this answer






























                                        4














                                        Go to your Apache Cassandra conf directory and enable the binary protocol



                                        Cassandra binary protocol
                                        The Java driver uses the binary protocol that was introduced in Cassandra 1.2. It only works with a version of Cassandra greater than or equal to 1.2. Furthermore, the binary protocol server is not started with the default configuration file in Cassandr a 1.2. You must edit the cassandra.yaml file for each node:



                                        start_native_transport: true


                                        Then restart the node.






                                        share|improve this answer




























                                          4












                                          4








                                          4







                                          Go to your Apache Cassandra conf directory and enable the binary protocol



                                          Cassandra binary protocol
                                          The Java driver uses the binary protocol that was introduced in Cassandra 1.2. It only works with a version of Cassandra greater than or equal to 1.2. Furthermore, the binary protocol server is not started with the default configuration file in Cassandr a 1.2. You must edit the cassandra.yaml file for each node:



                                          start_native_transport: true


                                          Then restart the node.






                                          share|improve this answer















                                          Go to your Apache Cassandra conf directory and enable the binary protocol



                                          Cassandra binary protocol
                                          The Java driver uses the binary protocol that was introduced in Cassandra 1.2. It only works with a version of Cassandra greater than or equal to 1.2. Furthermore, the binary protocol server is not started with the default configuration file in Cassandr a 1.2. You must edit the cassandra.yaml file for each node:



                                          start_native_transport: true


                                          Then restart the node.







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited Jun 14 '13 at 13:01

























                                          answered May 28 '13 at 14:58









                                          OrbitaOrbita

                                          1397




                                          1397























                                              4














                                              I was also having same problem. I have installed Cassandra in a separate Linux pc and tried to connect via Window pc. I was not allowed to create the connection.



                                              But when we edit cassandra.yaml, set my linux pc ip address to rpc_address and restart, it allows me to connect successfully,



                                              # The address or interface to bind the Thrift RPC service and native transport
                                              # server to.
                                              #
                                              # Set rpc_address OR rpc_interface, not both. Interfaces must correspond
                                              # to a single address, IP aliasing is not supported.
                                              #
                                              # Leaving rpc_address blank has the same effect as on listen_address
                                              # (i.e. it will be based on the configured hostname of the node).
                                              #
                                              # Note that unlike listen_address, you can specify 0.0.0.0, but you must also
                                              # set broadcast_rpc_address to a value other than 0.0.0.0.
                                              #rpc_address: localhost
                                              rpc_address: 192.168.0.10





                                              share|improve this answer




























                                                4














                                                I was also having same problem. I have installed Cassandra in a separate Linux pc and tried to connect via Window pc. I was not allowed to create the connection.



                                                But when we edit cassandra.yaml, set my linux pc ip address to rpc_address and restart, it allows me to connect successfully,



                                                # The address or interface to bind the Thrift RPC service and native transport
                                                # server to.
                                                #
                                                # Set rpc_address OR rpc_interface, not both. Interfaces must correspond
                                                # to a single address, IP aliasing is not supported.
                                                #
                                                # Leaving rpc_address blank has the same effect as on listen_address
                                                # (i.e. it will be based on the configured hostname of the node).
                                                #
                                                # Note that unlike listen_address, you can specify 0.0.0.0, but you must also
                                                # set broadcast_rpc_address to a value other than 0.0.0.0.
                                                #rpc_address: localhost
                                                rpc_address: 192.168.0.10





                                                share|improve this answer


























                                                  4












                                                  4








                                                  4







                                                  I was also having same problem. I have installed Cassandra in a separate Linux pc and tried to connect via Window pc. I was not allowed to create the connection.



                                                  But when we edit cassandra.yaml, set my linux pc ip address to rpc_address and restart, it allows me to connect successfully,



                                                  # The address or interface to bind the Thrift RPC service and native transport
                                                  # server to.
                                                  #
                                                  # Set rpc_address OR rpc_interface, not both. Interfaces must correspond
                                                  # to a single address, IP aliasing is not supported.
                                                  #
                                                  # Leaving rpc_address blank has the same effect as on listen_address
                                                  # (i.e. it will be based on the configured hostname of the node).
                                                  #
                                                  # Note that unlike listen_address, you can specify 0.0.0.0, but you must also
                                                  # set broadcast_rpc_address to a value other than 0.0.0.0.
                                                  #rpc_address: localhost
                                                  rpc_address: 192.168.0.10





                                                  share|improve this answer













                                                  I was also having same problem. I have installed Cassandra in a separate Linux pc and tried to connect via Window pc. I was not allowed to create the connection.



                                                  But when we edit cassandra.yaml, set my linux pc ip address to rpc_address and restart, it allows me to connect successfully,



                                                  # The address or interface to bind the Thrift RPC service and native transport
                                                  # server to.
                                                  #
                                                  # Set rpc_address OR rpc_interface, not both. Interfaces must correspond
                                                  # to a single address, IP aliasing is not supported.
                                                  #
                                                  # Leaving rpc_address blank has the same effect as on listen_address
                                                  # (i.e. it will be based on the configured hostname of the node).
                                                  #
                                                  # Note that unlike listen_address, you can specify 0.0.0.0, but you must also
                                                  # set broadcast_rpc_address to a value other than 0.0.0.0.
                                                  #rpc_address: localhost
                                                  rpc_address: 192.168.0.10






                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered Nov 18 '14 at 13:30









                                                  Prasanna SujeewaPrasanna Sujeewa

                                                  15917




                                                  15917























                                                      3














                                                      Just posting this for people who might have the same problem as I did, when I got that error message. Turned out my complex dependency tree brought about an old version of com.google.collections, which broke the CQL driver. Removing this dependency and relying entirely on guava solved my problem.






                                                      share|improve this answer



















                                                      • 1





                                                        Thanks for your hint, it solved my problem

                                                        – Harsha
                                                        Jan 27 '15 at 14:45
















                                                      3














                                                      Just posting this for people who might have the same problem as I did, when I got that error message. Turned out my complex dependency tree brought about an old version of com.google.collections, which broke the CQL driver. Removing this dependency and relying entirely on guava solved my problem.






                                                      share|improve this answer



















                                                      • 1





                                                        Thanks for your hint, it solved my problem

                                                        – Harsha
                                                        Jan 27 '15 at 14:45














                                                      3












                                                      3








                                                      3







                                                      Just posting this for people who might have the same problem as I did, when I got that error message. Turned out my complex dependency tree brought about an old version of com.google.collections, which broke the CQL driver. Removing this dependency and relying entirely on guava solved my problem.






                                                      share|improve this answer













                                                      Just posting this for people who might have the same problem as I did, when I got that error message. Turned out my complex dependency tree brought about an old version of com.google.collections, which broke the CQL driver. Removing this dependency and relying entirely on guava solved my problem.







                                                      share|improve this answer












                                                      share|improve this answer



                                                      share|improve this answer










                                                      answered Mar 28 '14 at 19:21









                                                      VHristovVHristov

                                                      7201922




                                                      7201922








                                                      • 1





                                                        Thanks for your hint, it solved my problem

                                                        – Harsha
                                                        Jan 27 '15 at 14:45














                                                      • 1





                                                        Thanks for your hint, it solved my problem

                                                        – Harsha
                                                        Jan 27 '15 at 14:45








                                                      1




                                                      1





                                                      Thanks for your hint, it solved my problem

                                                      – Harsha
                                                      Jan 27 '15 at 14:45





                                                      Thanks for your hint, it solved my problem

                                                      – Harsha
                                                      Jan 27 '15 at 14:45











                                                      3














                                                      I was having the same issue testing a new cluster with one node.



                                                      After removing this from the Cluster builder I was able to connect:



                                                      .withLoadBalancingPolicy(new DCAwareRoundRobinPolicy("US_EAST"))


                                                      It was able to connect.






                                                      share|improve this answer




























                                                        3














                                                        I was having the same issue testing a new cluster with one node.



                                                        After removing this from the Cluster builder I was able to connect:



                                                        .withLoadBalancingPolicy(new DCAwareRoundRobinPolicy("US_EAST"))


                                                        It was able to connect.






                                                        share|improve this answer


























                                                          3












                                                          3








                                                          3







                                                          I was having the same issue testing a new cluster with one node.



                                                          After removing this from the Cluster builder I was able to connect:



                                                          .withLoadBalancingPolicy(new DCAwareRoundRobinPolicy("US_EAST"))


                                                          It was able to connect.






                                                          share|improve this answer













                                                          I was having the same issue testing a new cluster with one node.



                                                          After removing this from the Cluster builder I was able to connect:



                                                          .withLoadBalancingPolicy(new DCAwareRoundRobinPolicy("US_EAST"))


                                                          It was able to connect.







                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered Sep 20 '14 at 19:54









                                                          Brandon KearbyBrandon Kearby

                                                          46357




                                                          46357























                                                              2














                                                              In my case this was a port issue, which I forgot to update



                                                              Old RPC port is 9160

                                                              New binary port is 9042






                                                              share|improve this answer




























                                                                2














                                                                In my case this was a port issue, which I forgot to update



                                                                Old RPC port is 9160

                                                                New binary port is 9042






                                                                share|improve this answer


























                                                                  2












                                                                  2








                                                                  2







                                                                  In my case this was a port issue, which I forgot to update



                                                                  Old RPC port is 9160

                                                                  New binary port is 9042






                                                                  share|improve this answer













                                                                  In my case this was a port issue, which I forgot to update



                                                                  Old RPC port is 9160

                                                                  New binary port is 9042







                                                                  share|improve this answer












                                                                  share|improve this answer



                                                                  share|improve this answer










                                                                  answered Aug 21 '13 at 15:04









                                                                  oleksiioleksii

                                                                  27.8k864130




                                                                  27.8k864130























                                                                      2














                                                                      I too encountered this problem, and it was caused by a simple error in the statement that was being submitted.



                                                                      session.prepare(null);


                                                                      Obviously, the error message is misleading.






                                                                      share|improve this answer




























                                                                        2














                                                                        I too encountered this problem, and it was caused by a simple error in the statement that was being submitted.



                                                                        session.prepare(null);


                                                                        Obviously, the error message is misleading.






                                                                        share|improve this answer


























                                                                          2












                                                                          2








                                                                          2







                                                                          I too encountered this problem, and it was caused by a simple error in the statement that was being submitted.



                                                                          session.prepare(null);


                                                                          Obviously, the error message is misleading.






                                                                          share|improve this answer













                                                                          I too encountered this problem, and it was caused by a simple error in the statement that was being submitted.



                                                                          session.prepare(null);


                                                                          Obviously, the error message is misleading.







                                                                          share|improve this answer












                                                                          share|improve this answer



                                                                          share|improve this answer










                                                                          answered Feb 6 '16 at 13:30









                                                                          ernest_kernest_k

                                                                          21.3k42445




                                                                          21.3k42445























                                                                              1














                                                                              Edit



                                                                              /etc/cassandra/cassandra.yaml 


                                                                              and change



                                                                              rpc_address to 0.0.0.0,broadcast_rpc_address and listen_address to ip address of the cluster.






                                                                              share|improve this answer






























                                                                                1














                                                                                Edit



                                                                                /etc/cassandra/cassandra.yaml 


                                                                                and change



                                                                                rpc_address to 0.0.0.0,broadcast_rpc_address and listen_address to ip address of the cluster.






                                                                                share|improve this answer




























                                                                                  1












                                                                                  1








                                                                                  1







                                                                                  Edit



                                                                                  /etc/cassandra/cassandra.yaml 


                                                                                  and change



                                                                                  rpc_address to 0.0.0.0,broadcast_rpc_address and listen_address to ip address of the cluster.






                                                                                  share|improve this answer















                                                                                  Edit



                                                                                  /etc/cassandra/cassandra.yaml 


                                                                                  and change



                                                                                  rpc_address to 0.0.0.0,broadcast_rpc_address and listen_address to ip address of the cluster.







                                                                                  share|improve this answer














                                                                                  share|improve this answer



                                                                                  share|improve this answer








                                                                                  edited Nov 7 '16 at 16:29









                                                                                  Serjik

                                                                                  5,03964259




                                                                                  5,03964259










                                                                                  answered Nov 7 '16 at 13:50









                                                                                  Manjunatha H CManjunatha H C

                                                                                  111




                                                                                  111























                                                                                      0














                                                                                      Check below points:



                                                                                      i) check server ip



                                                                                      ii) check listening port



                                                                                      iii) data-stack client dependency must match the server version.



                                                                                      About the yaml file, latest versions has below properties enabled:



                                                                                          start_native_transport: true
                                                                                      native_transport_port: 9042





                                                                                      share|improve this answer




























                                                                                        0














                                                                                        Check below points:



                                                                                        i) check server ip



                                                                                        ii) check listening port



                                                                                        iii) data-stack client dependency must match the server version.



                                                                                        About the yaml file, latest versions has below properties enabled:



                                                                                            start_native_transport: true
                                                                                        native_transport_port: 9042





                                                                                        share|improve this answer


























                                                                                          0












                                                                                          0








                                                                                          0







                                                                                          Check below points:



                                                                                          i) check server ip



                                                                                          ii) check listening port



                                                                                          iii) data-stack client dependency must match the server version.



                                                                                          About the yaml file, latest versions has below properties enabled:



                                                                                              start_native_transport: true
                                                                                          native_transport_port: 9042





                                                                                          share|improve this answer













                                                                                          Check below points:



                                                                                          i) check server ip



                                                                                          ii) check listening port



                                                                                          iii) data-stack client dependency must match the server version.



                                                                                          About the yaml file, latest versions has below properties enabled:



                                                                                              start_native_transport: true
                                                                                          native_transport_port: 9042






                                                                                          share|improve this answer












                                                                                          share|improve this answer



                                                                                          share|improve this answer










                                                                                          answered Dec 27 '16 at 8:50









                                                                                          SonuSonu

                                                                                          24614




                                                                                          24614























                                                                                              0














                                                                                              Assuming you have default configurations in place, check the driver version compatibility. Not all driver versions are compatible with all versions of Cassandra, though they claim backward compatibility. Please see the below link.



                                                                                              http://docs.datastax.com/en/developer/java-driver/3.1/manual/native_protocol/



                                                                                              I ran into a similar issue & changing the driver version solved my problem.



                                                                                              Note: Hopefully, you are using Maven (or something similar) to resolve dependencies. Otherwise, you may have to download a lot of dependencies for higher versions of the driver.






                                                                                              share|improve this answer




























                                                                                                0














                                                                                                Assuming you have default configurations in place, check the driver version compatibility. Not all driver versions are compatible with all versions of Cassandra, though they claim backward compatibility. Please see the below link.



                                                                                                http://docs.datastax.com/en/developer/java-driver/3.1/manual/native_protocol/



                                                                                                I ran into a similar issue & changing the driver version solved my problem.



                                                                                                Note: Hopefully, you are using Maven (or something similar) to resolve dependencies. Otherwise, you may have to download a lot of dependencies for higher versions of the driver.






                                                                                                share|improve this answer


























                                                                                                  0












                                                                                                  0








                                                                                                  0







                                                                                                  Assuming you have default configurations in place, check the driver version compatibility. Not all driver versions are compatible with all versions of Cassandra, though they claim backward compatibility. Please see the below link.



                                                                                                  http://docs.datastax.com/en/developer/java-driver/3.1/manual/native_protocol/



                                                                                                  I ran into a similar issue & changing the driver version solved my problem.



                                                                                                  Note: Hopefully, you are using Maven (or something similar) to resolve dependencies. Otherwise, you may have to download a lot of dependencies for higher versions of the driver.






                                                                                                  share|improve this answer













                                                                                                  Assuming you have default configurations in place, check the driver version compatibility. Not all driver versions are compatible with all versions of Cassandra, though they claim backward compatibility. Please see the below link.



                                                                                                  http://docs.datastax.com/en/developer/java-driver/3.1/manual/native_protocol/



                                                                                                  I ran into a similar issue & changing the driver version solved my problem.



                                                                                                  Note: Hopefully, you are using Maven (or something similar) to resolve dependencies. Otherwise, you may have to download a lot of dependencies for higher versions of the driver.







                                                                                                  share|improve this answer












                                                                                                  share|improve this answer



                                                                                                  share|improve this answer










                                                                                                  answered Feb 22 '17 at 17:52









                                                                                                  MausamMausam

                                                                                                  1




                                                                                                  1






























                                                                                                      draft saved

                                                                                                      draft discarded




















































                                                                                                      Thanks for contributing an answer to Stack Overflow!


                                                                                                      • Please be sure to answer the question. Provide details and share your research!

                                                                                                      But avoid



                                                                                                      • Asking for help, clarification, or responding to other answers.

                                                                                                      • Making statements based on opinion; back them up with references or personal experience.


                                                                                                      To learn more, see our tips on writing great answers.




                                                                                                      draft saved


                                                                                                      draft discarded














                                                                                                      StackExchange.ready(
                                                                                                      function () {
                                                                                                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16783725%2ferror-while-connecting-to-cassandra-using-java-driver-for-apache-cassandra-1-0-f%23new-answer', 'question_page');
                                                                                                      }
                                                                                                      );

                                                                                                      Post as a guest















                                                                                                      Required, but never shown





















































                                                                                                      Required, but never shown














                                                                                                      Required, but never shown












                                                                                                      Required, but never shown







                                                                                                      Required, but never shown

































                                                                                                      Required, but never shown














                                                                                                      Required, but never shown












                                                                                                      Required, but never shown







                                                                                                      Required, but never shown







                                                                                                      Popular posts from this blog

                                                                                                      A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

                                                                                                      Calculate evaluation metrics using cross_val_predict sklearn

                                                                                                      Insert data from modal to MySQL (multiple modal on website)