The only way to know that a connection is bad is by trying to interact with it and timeout, which is hard to recover from seamlessly. You can do retries, but if you do that by getting a new connection from the pool, chances are that you will get another connection that is bad, and by that time, or by the time of the third try, you are no longer completing your task within a reasonable time frame.
It's not clear what the problem is. If your connections can drop, potentially an indefinite number of times in series, then there is no guarantee that your machine's task will be completed under its own steam in any timeframe at all, let alone a "reasonable" one.
Computers are awash with internal hardware connections, but these are rarely seen explicitly by software developers because they are engineered to have a high level of reliability provided the computer is kept under normal environmental conditions.
"Connections" are revealed to software developers invariably because they are fundamentally shaky and intermittent connections, and the developer needs to proceed to program on the assumption of coping with the indefinite loss of a connection.
Ultimately it is the job of the system supervisers to intervene against abnormal conditions that break connections indefinitely stop the system working, and it is the job of the system designers to ensure (amongst other things) that the system is amenable to supervision and intervention, and that the risk, frequency, and urgency of superviser intervention being required is sufficiently low as to be suitable for the application.
It's often crucial to control complexity and limit extravagant assumptions about reliability, rather than to assume there are crafty solutions which do not at all require complexity to be controlled or extravagant assumptions to be limited.
I see in the comments that the main concern centres around cloud providers. Unfortunately, the use of cloud providers and their hardware means ceding control and losing coordination over a variety of matters that are normally under more control when the hardware belongs to you and/or is geographically co-located at your centres of business.