-1

I was trying to access my java web app , which i have containerised with docker containers and i also have containerised my mysql database in a different container , both container are running on the default docker network , and i also tried to ping those containers from each other and i got positive results from it , but when i try to access it on my localhost (as i have mapped the ports of the tomcat server to the host ) machine it shows

Error

Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

I have read a little bit about this error , its related to some sort of connectivity issue with database but through pingcommand , i checked the connection.

What could be the reason of this error?

Arjun Sharma
  • 101
  • 2
  • 2
  • 10

1 Answers1

-1

1) If it is bound to 127.0.0.1 and you can't connect using "localhost", make sure it's not resolving to the IPv6 localhost address instead of IPv4. (or just use the IP address)

2) Check the port that MySQL is listening on (Default 3306).

3) Make sure you're using the right JDBC connector for your JDK.

Check this below code in your application.yml or application.properties

spring.datasource.url=jdbc:mysql://localhost:3306/<<DB_NAME>>
spring.datasource.username=root (In my case)
Ganesh A
  • 16
  • 2
  • https://github.com/ales-blaze/BookStore , may you look at my project , beacuse i don't have knowledge of java web app i haven taken it from web , for containerization. ``` **P.S** : its not a spring project ``` – Arjun Sharma Oct 01 '19 at 09:18