Looks like you need to configure check-valid-connection in -ds.xml file .
It is explained here
<check-valid-connection-sql> - an sql statement that is executed before it is checked out from the pool to make sure it is still valid. If the sql fails, the connection is closed and new ones created.
For more details please refer to the following link I have pulled the above contents from here
I hope this is what you have been asking for .