# Connecting with Java This guide explains how to establish a connection between a **Java** application and a **PostgreSQL** database using the **JDBC driver**. It walks through the necessary setup, configuration, and execution of a simple SQL query. ## **Variables** Certain parameters must be provided to establish a successful connection to a PostgreSQL database. Below is a breakdown of each required variable, its purpose, and where to find it. Here’s what each variable represents:
**Variable** | **Description** | **Purpose** |
`USER` | PostgreSQL username, from the Elestio service overview page | Identifies the database user who has permission to access the PostgreSQL database. |
`PASSWORD` | PostgreSQL password, from the Elestio service overview page | The authentication key required for the specified `USER` to access the database |
`HOST` | Hostname for PostgreSQL connection, from the Elestio service overview page | The address of the server hosting the PostgreSQL database. |
`PORT` | Port for PostgreSQL connection, from the Elestio service overview page | The network port is used to connect to PostgreSQL. The default port is `5432`. |
`DATABASE` | Database Name for PostgreSQL connection, from the Elestio service overview page | The name of the database being accessed. A PostgreSQL instance can contain multiple databases. |