javaspringspring-bootsupabasesupabase-database

How to configure Supabase as a database for a Spring Boot application?


I’m working on a Spring Boot application and I’d like to use Supabase database as my database.

I’ve successfully set up Supabase and created a project, but I’m having trouble configuring it in my Spring Boot application, and also trouble with an endpoint of mine.

My current setup:

What I’ve tried:

  1. Added the necessary PostgreSQL dependencies to my pom.xml:

    <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId></dependency>

  2. Configured my application.properties with the details provided by Supabase:

spring.datasource.url=jdbc:postgresql://<supabase-host>:5432/<database-name>
spring.datasource.username=<supabase-user> 
spring.datasource.password=<supabase-password>
spring.datasource.driver-class-name=org.postgresql.Driver

I’m not sure if this configuration is sufficient or if there are additional settings required to fully integrate Supabase with Spring Boot.


Solution

  • spring.datasource.driver-class-name=org.postgresql.Driver
    spring.datasource.url={YOUR JDBC URL}&password={YOUR SUPABASE DB PASSWORD}
    spring.datasource.username={Your DB User Name From Supabase}
    spring.datasource.password={Your DB Password From Supabase}
    spring.jpa.show-sql=true
    spring.jpa.hibernate.ddl-auto=none
    

    You need to get the JDBC connection String from connect --> Type --> JDBC and scroll to Session Pooler to get the JDBC URL and credentials.

    For step by step process please see my blog below:https://medium.com/@khan.abdulwasey99/step-by-step-process-on-how-to-connect-a-spring-boot-application-to-supabase-f1791e1d2402

    Re-posting I was not aware of Stackoverflow guidelines for external blogs.