I'm trying to connect to the DSE 5.1 Cluster with Authentication from Java client. The Cassandra driver I have used is
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.1.4</version>
</dependency>
Have added a simple Test which tries to connect to a particular 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);
}
I end up with com.datastax.driver.core.exceptions.AuthenticationException
From the terminal, I'm able to connect to this node with the same credentials but from my Java code, I'm unable to get past this exception.
Stacktrace
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)
Please advise on what I'm missing.