N
Neon2y ago
plain-purple

JDBC: Connection problems

Hi guys! I'm having some troubles using Spring Boot and the PostgreSql database connection, could someone help me? The JPA Hibernate make this select: Hibernate: select c1_0.id,c1_0.cnpj,c1_0.firm_value,c1_0.foundation_year,c1_0.ipo,c1_0.market_segment,c1_0.name,c1_0.number_of_papers,c1_0.sector,c1_0.segment from public.companies c1_0 And I'm getting this Exception message: org.postgresql.util.PSQLException: ERROR: relation "public.companies" does not exist The table companies already exists at the public schema
9 Replies
deep-jade
deep-jade2y ago
did you double check if you are connected to the correct database?
plain-purple
plain-purpleOP2y ago
Yep! Here is my application.properties spring.datasource.url=jdbc:postgresql://ep-tight-math-a5csxlts.us-east-2.aws.neon.tech/stock-compass-db?user=[user]&password=[password]&sslmode=require
deep-jade
deep-jade2y ago
hm are you using multiple schemas? or just the public one
plain-purple
plain-purpleOP2y ago
Just the public one @Entity @Table(name = "companies", schema = "public") @Data @NoArgsConstructor @AllArgsConstructor public class Companies { code here }
deep-jade
deep-jade2y ago
and the table shows up in the neon table overview too? project -> your branch -> tables and then select the stock-compass-db Database
plain-purple
plain-purpleOP2y ago
Using the IntelliJ I was able to see the schema and the tables
No description
deep-jade
deep-jade2y ago
thats odd I'm not familiar with spring boot but from what I can see is that they often use
spring.datasource.url=jdbc:postgresql://localhost:5432/mydatabase
spring.datasource.username=db_username
spring.datasource.password=db_password
spring.datasource.url=jdbc:postgresql://localhost:5432/mydatabase
spring.datasource.username=db_username
spring.datasource.password=db_password
instead of the user password params any chance it could be this? Error seems a bit odd if the table 100% exists, also any chance it collects to some local db instead sorry if thats of no help
plain-purple
plain-purpleOP2y ago
I tested using this configs And still didn't get any progress 😭 But thank you for the time searching for a solution
eastern-cyan
eastern-cyan2y ago
That's really odd. I would also assume the Java application is connected to the wrong host/db based on that error message. If you print the spring.datasource.url to console from the Java application, does it look correct?

Did you find this page helpful?