Connecting Spring application to remote Postgresql database
So basically when I am connecting my spring boot application to my self hosted mysql database it is working properly but when I am trying to use the remote postgresql database url it is continuously showing error connection failes tries a ot of ways but still the same. The databse I am using is render postgresql database.
66 Replies
⌛ This post has been reserved for your question.
Hey @Swarnavo! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
you sure your remote server isnt blocking connections
I don't think so
what error do you get btw
invalid credentials
or what
I dont know if the problem was anything with the enviornment variables but then again I watched a video in youtube followed along in the video it was running fine
No no not invalid credentials
wait let me paste the error stack it would be easy for you to understand

yea
says in the error
you didnt specify the url
show your config file
but it is specified in the application-prod.properties
wait let me show you the application.properties and application-prod.properties
ok
application.properties

application-prod.properties

you can hide the url too
anyway
did you specify for that application prod to be launched
are you launching the app with the prod profile
yes see application.properties last line
I have specified it
I don't know is there anything else I need to do apart from adding that line spring.properties.active=prod
if yes let me know
i think you are missing
one second
Sure sure
i think you are missing this line
in your case
spring.datasource.driver-class-name
and you need to add the driver for postgres
I have already added driver for postgres
okay let me try with this
there you need to add the actual like
postgres driver class
actually
i assume you are using intellij right
do you have the ultimate version
yes
or community
community version
oh then nevermind
ok add this
do I need to add this too
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.driver-class-name=org.postgresql.Driver
no
only driver class name
see if it works
I have to add it in application-prod.properties right?
yes
same issue
interesting
but the question is it connected to dbeaver so why is it not connecting to the application
strange😂
are you launching the app with the prod profile
I guess so yes
show your launch config
Do i need to make some extra configuration other than using this line
spring.profiles.active=prod
no
like what you want to see
1 sec
Are you talking about this stuff

ok so here
in program arguments
add this
--spring.profiles.active=prod
and click run
see if that is gonna work
okay I am doing it
I think nothing changed much

After adding it I ran the application but same
press ctrl f in that console output
and type
prod
it should say something like
The following 1 profile is active: "prod"

uhhh
when you run the app
and where that jdbc error was
what i pasted should appear
run the app and click anywhere in that error and press ctrl f and type
prod
not comming
only this is coming
interesting
do you have the
postgres dependencies
in your pom/gradle
yes
show
and also show if you have spring boot data jpa

yes
My whole project is working in local mysql db
The whole problem started arising when I started connecting it to the postsql db I created in render
hmmmm
1 sec
does connecting with dbeaver work
like to that remote url
yes
wait wait
I think its done
wdym done
its done maybe I had done some issue with the url when I was copying from dbeaver
so now it works yes
secondly I removed the line which you gave me and added this line
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
It is finally working great
nice
thanks for taking time
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
and helping me out
i thought dialect isnt needed btw
since usually it can fetch that stuff from the
url connection
but ig in this case it needed that setting
Well I don't thing removing it will cause any error later on mainly I think the error was on the url part only
oh
yea maybe
Anyways thank you
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Post Closed
This post has been closed by <@866566353329979394>.