Connect applications
Applications connect to and interact with YugabyteDB using API client libraries (also known as client drivers). Before you can connect an application, you need to install the correct driver.
Yugabyte Cloud clusters have SSL (encryption in-transit) enabled so make sure your driver details include SSL parameters.
For examples of applications that connect to Yugabyte Cloud using common drivers, refer to Build an application.
For examples of connecting applications to Yugabyte Cloud, refer to Example applications.
Note
Before you can connect, your application has to be able to reach your Yugabyte Cloud cluster. To add inbound network access from your application environment to a cluster, you need to add the public IP addresses to the cluster IP access list. If you are using VPC peering, you need to add the public IP addresses of the peered application VPC to the cluster IP allow list.Connect an application
To connect a cluster to an application:
-
On the Clusters tab, select the cluster.
-
Click Connect.
-
Click Connect to your Application.
-
Click Download CA Cert and install the certificate on the computer running the application.
-
Choose the API used by your application - YSQL or YCQL.
-
Choosing YSQL displays a connection string you can add to your application.
-
Choosing YCQL displays connection parameters that you will use to connect your application.
-
YSQL
YSQL applications can use the connection string to connect. Here's an example of a generated ysqlsh
string:
postgresql://<DB USER>:<DB PASSWORD>@4242424.aws.ybdb.io:5433/yugabyte? \
ssl=true& \
sslmode=verify-full& \
sslrootcert=<ROOT_CERT_PATH>
Add the string to your application, replacing
<DB USER>
with your database username.<DB PASSWORD>
with your database password.yugabyte
with the database name, if you're connecting to a database other than the default (yugabyte).<ROOT_CERT_PATH>
with the path to the root certificate on your computer.
For example:
postgresql://admin:qwerty@4242424.aws.ybdb.io:5433/yugabyte?ssl=true& \
sslmode=verify-full&sslrootcert=~/.postgresql/root.crt
The connection string includes parameters for TLS settings (ssl
, sslmode
and sslrootcert
). The generated ysqlsh
connection string uses the verify-full
SSL mode by default.
If you're connecting to a Hasura Cloud project, which doesn't use the CA certificate, select Optimize for Hasura Cloud to modify the string. Before using the string to connect in a Hasura project, be sure to encode any special characters. For an example of connecting a Hasura Cloud project to Yugabyte Cloud, refer to Connect Hasura Cloud to Yugabyte Cloud.
For information on using other SSL modes, refer to SSL modes in YSQL.
YCQL
To connect a YCQL application, use the connection parameters in your application to connect to your cluster. The parameters are:
- LocalDatacenter - The name of the local datacenter for the cluster.
- Host - The cluster host name.
- Port - The port number of the YCQL client API on the YugabyteDB database (9042).
To connect your application, do the following:
- Download the CA certificate.
- Add the YCQL java driver to your dependencies.
- Initialize SSLContext using the downloaded root certificate.
For an example of building a Java application connected to Yugabyte Cloud using the Yugabyte Java Driver for YCQL v4.6, refer to Connect a YCQL Java application.