page:guides:quarkus:database connection
Connect Postgres for Quarkus
Summary
Database connection for a Quarkus app on Ample. Verified on Quarkus: a managed PostgreSQL database auto-provisioned and injected as DATABASE_URL, with real queries succeeding at request time (records=ok).
Prerequisites
- A Quarkus project (./mvnw -q -DskipTests package producing one uber-jar (quarkus.package.jar.type=uber-jar), then java -jar on the jvm-21 template (Temurin JDK 21) with quarkus.http.port read from PORT)
- A PostgreSQL driver reading DATABASE_URL at runtime
- An Ample account token with servers:write, databases:read
Resource Requirements
- Compute: Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.
- Postgres: Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when an app needs a database and no DATABASE_URL is supplied.
Workflow Steps
- Build and start
./mvnw -q -DskipTests package producing one uber-jar (quarkus.package.jar.type=uber-jar), then java -jar on the jvm-21 template (Temurin JDK 21) with quarkus.http.port read from PORT; the server must bind 0.0.0.0 on PORT. - Read DATABASE_URL at runtime
Open connections from the environment inside handlers or a pool; omit DATABASE_URL to auto-provision a managed database or pass --env DATABASE_URL=... for an existing one. - Verify
Fetch the live URL and /p/relational-records on the example; on failure read the build and runtime logs.
Command:ample logs --kind build
Success Checks
- app responds on its public URL (expect:
ample canary quarkus patterns) - relational-records check from the example (expect:
see the pattern fixture checks)
Limitations
- Verified on the jvm-21 template at s-1vcpu-2gb; other sizes and Quarkus major versions are not verified.
- Region, compliance attestations and request-duration limits are unknown and not claimed.
- Managed PostgreSQL 16 only; extensions, connection limits and backup or restore procedures are not verified.
Cost Estimate
- Currency: USD
- Monthly Amount: 10.0
- Basis: size prices from pricing.toml (loaded by the API)
Components
- App server: s-1vcpu-1gb, quantity: 1.0, monthly amount: 5.0
- Managed PostgreSQL database: s-1vcpu-1gb, quantity: 1.0, monthly amount: 5.0
Evidence Summary
- Kind: canary_run
Summary: Quarkus pattern fixture deployed on Ample (./mvnw -q -DskipTests package producing one uber-jar (quarkus.package.jar.type=uber-jar), then java -jar on the jvm-21 template (Temurin JDK 21) with quarkus.http.port read from PORT); for this guide: a managed PostgreSQL database auto-provisioned and injected as DATABASE_URL, with real queries succeeding at request time (records=ok).
Observed At: 2026-09-21T00:35:31Z
Next Actions
- Browse the catalog index:
Method: GET, Path:/v1/catalog- Search published recipes by intent, stack and constraints:
Method: POST, Path:/v1/catalog/search
Parameters: { "limit": 5, "query": "Connect Postgres for Quarkus" } - Prepare a side-effect-free deployment plan for an authorized project:
Method: POST, Path:/v1/catalog/plan
Parameters: { "inputs": {}, "projectId": "", "recipeId": "page:guides:quarkus:database-connection", "recipeRevision": "r1" } - Read the existing agent authentication setup:
Method: GET, Path:/mcp/setup - Browse Quarkus:
Method: GET, Path:/v1/catalog/nodes/stack%3Aframework-quarkus - Browse Connect app to database:
Method: GET, Path:/v1/catalog/nodes/intent%3Aconnect-app-to-database - Browse Relational records:
Method: GET, Path:/v1/catalog/nodes/pattern%3Arelational-records
- Search published recipes by intent, stack and constraints:
Formats
- HTML: https://ample.computer/guides/quarkus/database-connection
- Markdown: https://ample.computer/guides/quarkus/database-connection.md
- JSON: https://api.ample.computer/v1/catalog/recipes/page%3Aguides%3Aquarkus%3Adatabase-connection
Additional Information
- Framework: Quarkus
- Workload: Connect Postgres
- Release Status: published
- Support Status: verified
- Execution Status: ready