Join us on March 29th for Developer Days!Learn More

Connect a Java application to Neon

Set up a Neon project in seconds and connect with JDBC or Spring Data

This guide describes how to create a Neon project and connect to it with Java Database Connectivity (JDBC) or from a Spring Data project that uses JDBC.

The JDBC API is a Java API for relational databases. PostgreSQL has a well-supported open-source JDBC driver which can be used to access Neon. All popular Java frameworks use JDBC internally. To connect to Neon, you are only required to provide a connection URL.

For additional information about JDBC, refer to the standard JDBC API documentation and PostgreSQL JDBC Driver documentation.

To connect to Neon with JDBC or from a Spring Data project:

  1. Create a Neon project
  2. Connect with JDBC or Connect from Spring Data

Create a Neon project

If you do not have one already, create a Neon project. Save your connection details including your password. They are required when defining connection settings.

To create a Neon project:

  1. Navigate to the Projects page in the Neon Console.
  2. Click New Project.
  3. Specify a name, a PostgreSQL version, a region, and click Create Project.

For additional information about creating projects, see Set up a project.

Connect with JDBC

For a JDBC connection URL, replace the variables in the following URL string with your Neon project ID, database name, user, and password:



  • <hostname> the hostname of the branch's compute endpoint. The hostname has an ep- prefix and appears similar to this:
  • <dbname> is the name of the database. The default Neon database is neondb.
  • <user> is the database user.
  • <password> is the database user's password, which is provided to you when you create a project.

You can find all of the connection details listed above, except for your password, in the Connection Details widget on the Neon Dashboard. For more information, see Connect from any application. If you have misplaced your password, see Reset a password.

Connect from Spring Data

Spring Data relies on JDBC and PostgreSQL drivers to connect to PostgreSQL databases, such as Neon. If you are starting your project with Spring Initializr or connecting from an existing Spring Data project, ensure that the PostgreSQL database driver dependency is installed.

Connecting from a Spring Data project requires specifying the datasource URL in your file, as shown in the following example:


Refer to the Connect with JDBC section above for information about obtaining connection details for your Neon database.

Need help?

Send a request to, or join the Neon community forum.

Edit this page
Was this page helpful?