3

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:

  • Spring Boot version: 3.2.5

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.

3 Answers 3

1
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.

Sign up to request clarification or add additional context in comments.

Comments

1

You can do something like that :

# Supabase configuration
supabase.url=${SUPABASE_URL}
supabase.anon=${SUPABASE_ANON_KEY}
supabase.jwt_secret=${SUPABASE_JWT_SIGNER}

# Spring application configuration
spring.application.name=Demo
spring.main.banner-mode=off

# Spring datasource configuration
spring.datasource.url=${SUPABASE_DATABASE_URL}
spring.datasource.username=${SUPABASE_DATABASE_USER}
spring.datasource.password=${SUPABASE_DATABASE_PASSWORD}
spring.datasource.driverClassName=org.postgresql.Driver

Comments

0

You can try using the connection string of type JDBC. Use either direct connection string or session pooler string. Remove the username and password fields from your code. Just this is enough-> spring: datasource: url: string as taken from supabase

make sure to include your db password in the connection string

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.