I try to create a connection using given paramters.
CqlSessionBuilder builder = CqlSession.builder();
int port = 9042;
for ( String host : hosts ){
int idx = host.indexOf(":");
if ( idx > 0 ){
port = Integer.parseInt( host.substring( idx +1).trim() );
host = host.substring( 0, idx ).trim();
}
builder.addContactPoint( new InetSocketAddress( host, port ) );
if (sslEnabled) {
//builder.withSSL();
}
}
if ( dataCenter != null ) builder.withLocalDatacenter( dataCenter );
if ( userName != null && !userName.isEmpty() && password != null ) {
builder.withAuthCredentials(userName, password);
}
return builder.build();
When connecting, I get this error:
Since you provided explicit contact points, the local DC must be explicitly set.
There is a builder.withLocalDatacenter() in the code.
What could be wrong?