'How to build a Phantom CassandraConnection to ASTRA from datastax ClusterBuilder
I am running com.outworkers.phantom v 2.33.0 com.datastax.cassandra v 3.11.0
Trying to integrate DataStax Astra with my Scala code, I followed this: How to build a Phantom CassandraConnection from datastax ClusterBuilder
and wrote this:
def astraConnector(): KeySpaceDef = {
val cloudConfigFilePath = config.getString("cassandra.astra.secure_connect_bundle.path")
val cloudConfigFile: File = new File(cloudConfigFilePath)
ContactPoint.local.withClusterBuilder(builder => {
builder
.withCloudSecureConnectBundle( cloudConfigFile )
.withProtocolVersion(ProtocolVersion.fromInt(config.getInt("cassandra.protocolVersion")))
.withQueryOptions(queryOptions())
.withClusterName(config.getString("cassandra.cluster.name"))
//Optional Username and Password
(for {
password <- wrappedConfig.getOptional[String]("cassandra.astra.password")
username <- wrappedConfig.getOptional[String]("cassandra.astra.username")
} yield builder.withCredentials(username, password))
.getOrElse(builder)
}).keySpace(keySpace)
}
but at runtime it leads to
java.lang.IllegalStateException: Can't use withCloudSecureConnectBundle if you've already called addContactPoint(s)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
