How to create postgresql docker container to accept connections from jdbc

Hello everyone, I have a problem, I state I’m a neophyte; I created two docker containers, one for tomcat and one for postgresql. The developers tell me that from jdbc they fail to connect from jdbc included in the tomcat docker container to the postgresql docker container generating this error:

“” org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:315) ~[postgresql-42.2.23.jar:42.2.23] “”

etc … etc …

  1. How can I create a postgresql container to accept connections from jdbc? If I look at the postgresql configuration file I find a * in the network connections section. So this parameter has already been set.

  2. I also know that it’s not up to me but I also wanted to test if everything worked correctly after creating the container; I don’t know how to use jdbc on the net, I can’t find a precise guide. Of course, this thing interests me in relation to me first of all that I can create a postgresql container that accepts all connections.

I think the “etc” would be important. The shared part of the message is just like “something happened with the connection” and we know that. It could be a parameter thaty ou need to set with JDBC or something that you need to disable. For example enabling or disabling secure (TLS) connection. Or it is possible that the two containers are in two different network.

Docker containers can be started multiple ways so it would be important to know how you do it in what kind of environment and how you try to access the container.