Building the Connection URL
Use the connection URL to supply connection information to the database that you are accessing. Depending on whether you are connecting to a database that is hosted on a Cassandra server or an Astra instance, different connection properties are required.
- Properties are case-sensitive.
- Do not duplicate properties in the connection URL.
Cassandra Connection URLs
When connecting to Cassandra, at minimum you must specify the DNS or IP address of the Cassandra server. Depending on the server configuration, other settings such as those related to authentication and SSL encryption might also be required.
The following is the format of a basic connection URL for connecting to Cassandra, where [Host] is the DNS or IP address of the server:
jdbc:cassandra://[Host]
By default, the connector connects to port 9042.
You can specify optional settings such as the number of the TCP port to connect to or any of the connection properties supported by the connector. For a list of the properties available in the connector, see .
The following is the format of a Cassandra connection URL that specifies some optional settings:
jdbc:cassandra:[Host1]:[Port1],[Host2]:[Port2],...;[Property1]=[Value]; [Property2]=[Value];...
For example, to connect to port 9000 on a Cassandra server installed on the local machine, and authenticate the connection using a user name and password, you would use the following connection URL:
jdbc:cassandra://localhost:9000;AuthMech=1;UID=simba;PWD=simba123
The host connection attribute accepts multiple servers. You can specify a comma-separated list of host names or IP addresses and ports. The connector attempts to connect to all the servers concurrently and then keeps the first connection that is successfully established. The connector does not maintain a connection with any of the other servers in the list.
Astra Connection URLs
When connecting to Astra, at minimum you must provide credentials for authentication and SSL encryption.
For more information about configuring authentication and SSL, see the following:
The following is the format of a basic connection URL for connecting to Astra:
jdbc:cassandra://;AuthMech=2;UID=[UserName];PWD=[Password];SecureConnectionBundlePath="[BundlePath]"
The variables are defined as follows:
- [UserName] is the user name that you use to access the Astra database.
- [Password] is the password corresponding to your user name.
- [BundlePath] is the full path and name of the secure connection bundle associated with your Astra database.
To make sure that the connection URL is compatible with all JDBC applications, escape the backslashes (
\
) in your file path by typing another backslash.
For example:
jdbc:cassandra://;AuthMech=2;UID=simba;PWD=simba123;SecureConnectionBundlePath="C:\\Users\\admin\\Documents\\Astra\\secure-connect-simba_database.zip"
You can also specify optional settings, such as SSL settings for overriding the SSL certificates in the secure connection bundle. For a list of the properties available in the connector, see .
The following is the format of an Astra connection URL that specifies some optional settings:
jdbc:cassandra://;AuthMech=2;UID=simba;PWD=simba123;SecureConnectionBundlePath="C:\\Users\\admin\\Documents\\Astra\\secure-connect-simba_database.zip";SSLMode=2;SSLTruststorePath="C:\\Users\\admin\\Documents\\Astra\\astra_trust.jks";SSLTrustStorePwd=jsmith123;SSLKeystorePath="C:\\Users\\admin\\Documents\\Astra\\astra_keys.jks";SSLKeystorePwd=jsmithkeys123