当我试图运行我的java应用程序,它试图连接到cassandra时,我得到以下异常:
com.datastax.oss.driver.api.core.DriverTimeoutException: query 'SELECT * FROM system.local' timed out after PT0.5S
DriverConfigLoader configBuilder = DriverConfigLoader.programmaticBuilder()
.withClass(DefaultDriverOption.AUTH_PROVIDER_CLASS, PlainTextAuthProvider.class)
.withString(DefaultDriverOption.AUTH_PROVIDER_USER_NAME, user)
.withString(DefaultDriverOption.AUTH_PROVIDER_PASSWORD, pass)
.withBoolean(DefaultDriverOption.CONNECTION_WARN_INIT_ERROR, false)
.withInt(DefaultDriverOption.CONNECTION_MAX_REQUESTS, 32768)
.withDuration(DefaultDriverOption.REQUEST_TIMEOUT, Duration.ofSeconds(30))
.withDuration(DefaultDriverOption.CONNECTION_INIT_QUERY_TIMEOUT, Duration.ofSeconds(10)).build();
try {
cqlSession = CqlSession.builder().addContactPoints(hostsList).withKeyspace(keyspace)
.withLocalDatacenter(dataCenter).withConfigLoader(configBuilder).build();
} catch (Exception e) {
logger.error("CassandraConfig >> Unable to connect to database {}", e);
}
暂无答案!
目前还没有任何答案,快来回答吧!