A lot of drivers have been written to use the erlang supervision tree to
get restarted if it crashes. However this assumes the database will be
always up and running. Something isn't always the case (in fact quite
the opposite actually).
Once you need to deal with errors in the database having a connection directly
under a supervisor doesn't make sense.
The solution to this depends a little bit on how the underlying
connection and pooling is implemented but generally you'd hold the
connection in a gen_server and traps exits from the connection. Your
gen_server then keeps track on reconnection logic and similar.
Finally the gen_server you write to keep track on this runs under a
supervisor so that it gets restarted in case it crashes.
supervisor -> gen_server with re-connect logic -> connection process
If you have a process pool you can either have each process in the pool
take care of re-connect logic or have the process pool simply remove
processes from the pool if they cannot connect.