The answer is on my edit that was to add the following in my beans that have the connection data:
<!-- Configuration pool --><property name="validationQuery" value="SELECT 1" /><property name="validationInterval" value="34000" /><property name="testOnBorrow" value="true" /><property name="removeAbandoned" value="true" /><property name="removeAbandonedTimeout" value="55" />
I don't know why but @Paweł Głowacz 's answer didn't work for me.Thanks for your help guys