0

I have created a web application in Java and hosted it on a VM. It is getting hosted as I can see the start page of web application. But the problem arises when the hosted web application tries to connect to the Postgres database.

This web application is properly getting connected on the local host if I use the following connection string for JDBC:

DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres",
            "postgres", "password");

But when hosted on VM it is not getting connected. I tried everything from other stackoverflow thread like this to change the configuration files of Postgres in VM but still it is not working.

Note: Postgres is also running on VM.

I have converted my web application from local host to .war file and deployed this file on the VM.

Can anyone tell if I have to do any other additional settings in order for the hosted web application to query the database in the VM?

2 Answers 2

0

Resolved this issue. The problem was that I didn't include some of the jar files that I was using in the web application in Apache Tomcat lib folder.

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

Comments

0

Do you also run Postgres on VM ? If not you can not connect it through localhost since the localhost for your web app is VM's address. If so check the firewall and allow the 5432 port to be able to connect.

3 Comments

Yes, I also run Postgre on VM.
Is your firewall up on VM? If so open the 5432 port as I said.
Can you please tell how to check that and then open the port if it is blocked?

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.