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?

A Beginner
  • 393
  • 2
  • 12

2 Answers2

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.

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.

A Beginner
  • 393
  • 2
  • 12