我有一段简单的代码用于从 cassandra 2 中删除数据
Cluster myCluster = Cluster.builder().addContactPoint(myhost).withPort(myport).build();
Session session = myCluster.connect(keyspaceName);
session.excecute(deleteStatement); -- it is just simple Delete.Where
基本上,当我尝试在(例如)keyspaceName =“test”上做某事时 它会很容易地执行我的删除语句,但是如果我尝试对(例如)keyspace =“\”DONT_WORK\“”(因为我在cassandra中的引号中包含键空间名称)执行相同的操作,它将不起作用,并且会抛出
com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: localhost/127.0.0.1:16660 (com.datastax.driver.core.ConnectionException: [localhost/127.0.0.1:16660] Pool is shutdown))
at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:84)
at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37)
at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:214)
我需要帮助
PS。我什至使用了 datastax 库中的 Metadata.quote() 静态方法 - 仍然不起作用。最佳答案
您不需要引用键空间名称来进行连接。引号对于保护 CQL 字符串上下文中的大小写敏感非常重要,但如果您将键空间名称作为 API 参数传递,则无需保护它。
关于java - Cassandra Java datastax 2.1.8 无法使用引号连接到键空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40306320/