From: Warren Young Date: August 6 2009 9:08pm Subject: Re: Automatic Reconnect List-Archive: http://lists.mysql.com/plusplus/8696 Message-Id: MIME-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit On Aug 6, 2009, at 2:10 PM, Dan Cook (dancook) wrote: > Would a connection pool help here? Yeah, you could abuse it that way. :) There's logic in there to let you tell it what the idle timeout is for connections, so it will automatically close and restart them if it detects that this has happened. The stock code doesn't help with the cases where the remote DB server is restarted, or your network link to it bounces. In the custom ConnectionPool subclass -- which you had to derive anyway -- you could do a ping-on-grab(), automatically closing the connection and creating a fresh one if the ping fails. This feels like abuse to me, though, because ConnecitonPool exists to deal with cases where you would otherwise have unjustifiably many connections open. You can run into the "lonely program dies over the weekend" case with just one connection. With a single thread, that may be all there ever is. So, you end up with this complicated pool mechanism just to manage a single connection. A pool for one. Call it ConnectionTub, if you must do it that way, then.