Reputation: 21897
Is there any way to specify the 'retry' count in Spring - DBCP connection pooling?
If the connection is not obtained for the first time, I want to try it atleast 3 times.
Upvotes: 1
Views: 2257
Reputation: 3061
BasicDataSource has a handful of methods that are protected and exist so subclasses can make their own implementation changes. One of these methods is createConnectionFactory() which creates a simple object to do the underlying connection to the driver. You can override that to point to your own connection retry logic.
Upvotes: 1
Reputation: 3975
One of the approach
write an spring aop aspect which will catch such transient DB related exceptions and retry for pre-configured number of times. Apply this aspect on methods.
Upvotes: 1