【发布时间】:2015-04-11 00:53:25
【问题描述】:
我在 cassandra.yaml 文件中将 Cassandra 数据库的身份验证器值更改为“PasswordAuthenticator”。 以前我使用以下代码使用 java 连接到数据库。
public void connect(String node) {
cluster = Cluster.builder()
.addContactPoint(node).build();
Metadata metadata = cluster.getMetadata();
System.out.printf("Connected to cluster: %s\n",
metadata.getClusterName());
for ( Host host : metadata.getAllHosts() ) {
System.out.printf("Datatacenter: %s; Host: %s; Rack: %s\n",
host.getDatacenter(), host.getAddress(), host.getRack());
}
session = cluster.connect();
}
现在这段代码给了我错误提示
Exception in thread "main" com.datastax.driver.core.exceptions.AuthenticationException: Authentication error on host /127.0.0.1: Host /127.0.0.1 requires authentication, but no authenticator found in Cluster configuration
我了解我需要使用我的超级用户用户名和密码连接到数据库。使用 java 连接数据库时如何提供这些详细信息?
【问题讨论】:
标签: java cassandra datastax-java-driver