Connect Quarkus (Reactive) to Neon
Learn how to connect to Neon from Quarkus using a Reactive SQL Client
Quarkus is a Java framework optimized for cloud environments. This guide shows how to connect to Neon from a Quarkus project using a Reactive SQL Client.
To connect to Neon from a Quarkus application:
- Create a Neon Project
- Create a Quarkus project and add dependencies
- Configure a PostgreSQL data source
- Use the Reactive PostgreSQL client
- Run the application
Create a Neon project
If you do not have one already, create a Neon project.
- Navigate to the Projects page in the Neon Console.
- Click New Project.
- Specify your project settings and click Create Project.
Create a Quarkus project
Create a Quarkus project using the Quarkus CLI:
You now have a Quarkus project in a folder named
neon-with-quarkus with the Reactive Postgres client and RESTEasy Reactive extensions installed.
Configure a PostgreSQL data source
.env file in the root of your Quarkus project directory. Configure a reactive data source using your Neon database connection string and specifying the database kind as shown:
You can find the connection string for your database in the Connection Details widget on the Neon Dashboard. For more information, see Connect from any application.
Use the Reactive PostgreSQL client
PostgresResource.java file in the same directory as the
GreetingResource.java that was generated by Quarkus during project creation. Paste the following content into the
This code defines a HTTP endpoint that will query the database version and return it as a response to incoming requests.
Run the application
Start the application in development mode using the Quarkus CLI from the root of the project directory:
Visit localhost:8080/postgres/version in your web browser. Your Neon database's Postgres version will be returned. For example:
Last updated on