when i run my code, i get this exception:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully
I was not unable to figure out the exact cause, but I realized that it was because of some thread pools since I was able to connect to the db using the terminal. for checking the connectivity you can use the below command.
psql -h hostname -U username -d database
so restarting the server worked for me.