Create a free trial cluster
- . If this is your first CockroachDB Cloud organization, it will be credited with $400 in to get you started.
- On the Get Started page, click Create cluster.
- On the Select a plan page, select Standard.
- On the Cloud & Regions page, select a cloud provider (GCP or AWS).
- In the Regions section, select a region for the cluster. Refer to for the regions where CockroachDB Standard clusters can be deployed. To create a multi-region cluster, click Add region and select additional regions.
- Click Next: Capacity.
- On the Capacity page, keep the at the default value of 2 vCPUs. Click Next: Finalize.
- On the Finalize page, name your cluster. If an active free trial is listed in the right pane, you will not need to add a payment method, though you will need to do this by the to maintain your organization’s clusters. Click Create cluster. Your cluster will be created in a few seconds and the Create SQL user dialog will display.
Create a SQL user
The Create SQL user dialog allows you to create a new SQL user and password.- Enter a username in the SQL user field or use the one provided by default.
- Click Generate & save password.
- Copy the generated password and save it in a secure location.
- Click Next. Currently, all new SQL users are created with admin privileges. For more information and to change the default settings, see .
Connect to the cluster
Select a language to connect a sample application to your cluster. To connect to your cluster directly from the command line, refer to .- Java
- Node.js
Once you create a SQL user, the Connect to cluster dialog will show information about how to connect to your cluster.The code sample uses the connection string stored in the environment variable
- Select Java from the Select option/language dropdown.
- Copy the
JDBC_DATABASE_URLenvironment variable command provided and save it in a secure location.
The connection string is pre-populated with your username, password, cluster name, and other details. Your password, in particular, will be provided only once. Save it in a secure place (Cockroach Labs recommends a password manager) to connect to your cluster in the future. If you forget your password, a Cluster Admin can reset it. Refer to:
Configure the connection environment variable
In a terminal, set theJDBC_DATABASE_URL environment variable to the JDBC connection string:JDBC_DATABASE_URL to connect to your cluster.Run the Java sample code
-
Clone the
quickstart-code-samplesrepo: -
Navigate to the
javadirectory of the repo:The code sample in this directory does the following:- Connects to CockroachDB Cloud with the JDBC driver using the JDBC connection string set in the
JDBC_DATABASE_URLenvironment variable. - Creates a table.
- Inserts some data into the table.
- Reads the inserted data.
- Prints the data to the terminal.
- Connects to CockroachDB Cloud with the JDBC driver using the JDBC connection string set in the
-
Run the application using
gradlew:The output should look like this:
Learn more
Now that you have a CockroachDB Standard cluster running, try out the following:- Build a simple CRUD application in , , , or .
- Learn .
- .
- .
- To create a Self-Hosted cluster, see .
- To create a CockroachDB Advanced cluster, see .
- To create a CockroachDB Standard cluster with other configurations (e.g., a different cloud provider, region, or provisioned capacity), see .
- To connect to a CockroachDB Standard cluster with other options (e.g., a different SQL user) and connection methods (with an application or ), see .

