com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Getting below error when calling Rest Api for TaskCount(POST) and TaskList(POST):

https://docs.camunda.org/manual/7.10/reference/rest/history/task/post-task-query/

https://docs.camunda.org/manual/7.10/reference/rest/history/task/post-task-query-count/

[org.camunda.bpm.engine.context] [logError] @ 156 : ENGINE-16004 Exception while closing command context: 
Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 718 milliseconds ago.  The last packet sent successfully to the server was 717 milliseconds ago.
The error may exist in org/camunda/bpm/engine/impl/mapping/entity/Incident.xml
The error may involve defaultParameterMap
The error occurred while setting parameters
SQL: select *     from ACT_RU_INCIDENT I     where I.CONFIGURATION_ = ?
Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 718 milliseconds ago.  The last packet sent successfully to the server was 717 milliseconds ago. 
org.apache.ibatis.exceptions.PersistenceException:

This com.mysql.jdbc.exceptions.jdbc4.CommunicationsException exception occurs if your database connection is idle for long time.

This idle connection returns true on connection.isClosed(); but if we try to execute statement then it will fire this exception so I will suggest to go with database pooling.