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
JavaBot
JavaBot5w ago
This post has been reserved for your question.
Hey @Swarnavo! Please use /close or the Close Post button 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.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
ayylmao123xdd
ayylmao123xdd5w ago
you sure your remote server isnt blocking connections
Swarnavo
SwarnavoOP5w ago
I don't think so
ayylmao123xdd
ayylmao123xdd5w ago
what error do you get btw invalid credentials or what
Swarnavo
SwarnavoOP5w ago
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
Swarnavo
SwarnavoOP5w ago
No description
ayylmao123xdd
ayylmao123xdd5w ago
yea says in the error you didnt specify the url show your config file
Swarnavo
SwarnavoOP5w ago
but it is specified in the application-prod.properties wait let me show you the application.properties and application-prod.properties
ayylmao123xdd
ayylmao123xdd5w ago
ok
Swarnavo
SwarnavoOP5w ago
application.properties
No description
Swarnavo
SwarnavoOP5w ago
application-prod.properties
No description
ayylmao123xdd
ayylmao123xdd5w ago
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
Swarnavo
SwarnavoOP5w ago
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
ayylmao123xdd
ayylmao123xdd5w ago
i think you are missing one second
Swarnavo
SwarnavoOP5w ago
Sure sure
ayylmao123xdd
ayylmao123xdd5w ago
i think you are missing this line
driver-class-name:
driver-class-name:
in your case spring.datasource.driver-class-name and you need to add the driver for postgres
Swarnavo
SwarnavoOP5w ago
I have already added driver for postgres okay let me try with this
ayylmao123xdd
ayylmao123xdd5w ago
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
Swarnavo
SwarnavoOP5w ago
yes
ayylmao123xdd
ayylmao123xdd5w ago
or community
Swarnavo
SwarnavoOP5w ago
community version
ayylmao123xdd
ayylmao123xdd5w ago
oh then nevermind ok add this
Swarnavo
SwarnavoOP5w ago
do I need to add this too spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
ayylmao123xdd
ayylmao123xdd5w ago
spring.datasource.driver-class-name=org.postgresql.Driver no only driver class name see if it works
Swarnavo
SwarnavoOP5w ago
I have to add it in application-prod.properties right?
ayylmao123xdd
ayylmao123xdd5w ago
yes
Swarnavo
SwarnavoOP5w ago
same issue
ayylmao123xdd
ayylmao123xdd5w ago
interesting
Swarnavo
SwarnavoOP5w ago
but the question is it connected to dbeaver so why is it not connecting to the application strange😂
ayylmao123xdd
ayylmao123xdd5w ago
are you launching the app with the prod profile
Swarnavo
SwarnavoOP5w ago
I guess so yes
ayylmao123xdd
ayylmao123xdd5w ago
show your launch config
Swarnavo
SwarnavoOP5w ago
Do i need to make some extra configuration other than using this line spring.profiles.active=prod
ayylmao123xdd
ayylmao123xdd5w ago
no
Swarnavo
SwarnavoOP5w ago
like what you want to see
ayylmao123xdd
ayylmao123xdd5w ago
1 sec
Swarnavo
SwarnavoOP5w ago
Are you talking about this stuff
No description
ayylmao123xdd
ayylmao123xdd5w ago
ok so here in program arguments add this --spring.profiles.active=prod and click run see if that is gonna work
Swarnavo
SwarnavoOP5w ago
okay I am doing it
Swarnavo
SwarnavoOP5w ago
I think nothing changed much
No description
Swarnavo
SwarnavoOP5w ago
After adding it I ran the application but same
ayylmao123xdd
ayylmao123xdd5w ago
press ctrl f in that console output and type prod it should say something like The following 1 profile is active: "prod"
Swarnavo
SwarnavoOP5w ago
No description
ayylmao123xdd
ayylmao123xdd5w ago
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
Swarnavo
SwarnavoOP5w ago
not comming only this is coming
ayylmao123xdd
ayylmao123xdd5w ago
interesting do you have the postgres dependencies in your pom/gradle
Swarnavo
SwarnavoOP5w ago
yes
ayylmao123xdd
ayylmao123xdd5w ago
show and also show if you have spring boot data jpa
Swarnavo
SwarnavoOP5w ago
No description
Swarnavo
SwarnavoOP5w ago
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
ayylmao123xdd
ayylmao123xdd5w ago
hmmmm 1 sec does connecting with dbeaver work like to that remote url
Swarnavo
SwarnavoOP5w ago
yes wait wait I think its done
ayylmao123xdd
ayylmao123xdd5w ago
wdym done
Swarnavo
SwarnavoOP5w ago
its done maybe I had done some issue with the url when I was copying from dbeaver
ayylmao123xdd
ayylmao123xdd5w ago
so now it works yes
Swarnavo
SwarnavoOP5w ago
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
ayylmao123xdd
ayylmao123xdd5w ago
nice
Swarnavo
SwarnavoOP5w ago
thanks for taking time
JavaBot
JavaBot5w ago
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.
Swarnavo
SwarnavoOP5w ago
and helping me out
ayylmao123xdd
ayylmao123xdd5w ago
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
Swarnavo
SwarnavoOP5w ago
Well I don't thing removing it will cause any error later on mainly I think the error was on the url part only
ayylmao123xdd
ayylmao123xdd5w ago
oh yea maybe
Swarnavo
SwarnavoOP5w ago
Anyways thank you
JavaBot
JavaBot5w ago
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.
JavaBot
JavaBot5w ago
Post Closed
This post has been closed by <@866566353329979394>.

Did you find this page helpful?