Skip to content

Instantly share code, notes, and snippets.

@relistan
Last active February 16, 2022 11:21
Show Gist options
  • Save relistan/868761aae7f92300ad319b07e5648cc9 to your computer and use it in GitHub Desktop.
Save relistan/868761aae7f92300ad319b07e5648cc9 to your computer and use it in GitHub Desktop.
Connecting to Cassandra/SSL from JRuby with Datastax driver
def connect(addresses, dc_name)
builder = CqlSession.builder()
.withLocalDatacenter(dc_name)
addresses.each do |a|
(host, port) = a.split(/:/)
port ||= 9042
builder
.addContactPoint(InetSocketAddress.new(host.to_java_string, port.to_i))
.withAuthCredentials('[redacted]', '[redacted]')
.withSslContext(SSLContext.getDefault)
end
builder.build
end
session = connect(%w{the-db-adddress.aivencloud.com:11172}, 'aiven')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment