我正在尝试使用来自 Java 客户端的身份验证连接到 DSE 5.1 集群。我使用的 Cassandra 驱动程序是
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.1.4</version>
</dependency>
添加了一个尝试连接到特定 KeySpace 的简单测试:
@Test
public void testConnection() {
String user = "****";
String pswd = "*******";
String host = "********"
Cluster cluster = Cluster.builder().addContactPoints(host)
.withPort(9042)
.withCredentials(user.trim(), pswd.trim())
.build();
Session session = cluster.connect(QueryBuilder.quote("TestKS"));
Assert.assertNotNull(session);
}
我最终得到com.datastax.driver.core.exceptions.AuthenticationException
从终端,我可以使用相同的凭据连接到此节点,但从我的 Java 代码中,我无法通过此异常。
堆栈跟踪
com.datastax.driver.core.exceptions.AuthenticationException: Authentication error on host /<host>:9042: Failed to login. Please re-try.
at com.datastax.driver.core.Connection$8.apply(Connection.java:390)
at com.datastax.driver.core.Connection$8.apply(Connection.java:359)
at com.google.common.util.concurrent.AbstractTransformFuture$AsyncTransformFuture.doTransform(AbstractTransformFuture.java:211)
请告知我所缺少的。