卡桑德拉(Cassandra)抛出了nohostavailable exception:所有主机(S)试图查询失败(尝试



我无法使用此代码连接到Cassandra群集:

public static boolean tableCreate() {
        // Query
        String query = "CREATE KEYSPACE store WITH replication "
                + "= {'class':'SimpleStrategy', 'replication_factor':1};";
        // creating Cluster object
        Cluster cluster = Cluster.builder().addContactPoint("127.0.0.1").withPort(9042).build();
        // Creating Session object
        Session session = cluster.connect("tutorialspoint");
        // Executing the query
        session.execute(query);
        // using the KeySpaceq
        session.execute("USE store");
        System.out.println("Keyspace created with store name");
        return true;
    }

它给我这个错误:

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

上面的代码中我的错误是什么?

Cassandra在我的本地Windows 10 64bit上运行,我也禁用了防火墙。

您可能需要检查并可能更新您正在使用的DataStax驱动程序的版本。我面临完全相同的错误(IE连接时相同的错误消息),在升级驱动程序" dataStax"版本后,问题消失了,我可以连接到db。

类似的问题:无法连接到在本地主机上运行的Cassandra群集

最新更新