You might consider using @Transactional
over your methods in DAO
or Service from where the DAO
is being called.
Transactions ensures the atomicity of the sequence of operations. That precisely means, either everything is successful or in case of exception all the queries are rolled back. When there is a failure in the transaction, Spring closes the connection and releases the resource. If there is no transaction, then no one guarantees when the connection is closed ( It might also get closed after one call returns successfully from the DB and for the next call another connection might be acquired.
As you state that the problem is solved, I stop writing here, for more on Spring refer my blog:TechieMe