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

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

Get Tasks (Historic) (POST) | docs.camunda.org

Get Task Count (POST) | docs.camunda.org

[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.