What is Xata?
Spring Boot

Connect to Postgres with Spring Boot

Edit on GitHub

To connect to Xata with Spring Boot you to adjust your application config as follows.

application.properties
spring.datasource.url=jdbc:postgresql://<REGION>.sql.xata.sh:5432/<DATABASE_NAME>:<BRANCH>
spring.datasource.username=<WORKSPACE_ID>
spring.datasource.password=<API_KEY>

Analogous, if you are using a yaml file:

application.yml
spring:
  datasource:
    url: jdbc:postgresql://<REGION>.sql.xata.sh:5432/<DATABASE_NAME>:<BRANCH>
    username: <WORKSPACE_ID>
    password: <API_KEY>

Please replace the parameters as indicated on the connect to Postgres page.

With a shared cluster you are subject to connection limits, meaning how many connections can be active concurrently. In order to avoid running into max open connection limit reached, please adjust the maximum pool size to 20 for free plan - and 60 for pro plan users.

application.properties
spring.datasource.hikari.maximum-pool-size=20

A dedicated cluster does not have any connection limits in place.