Improve reliability of PostgreSQL connections

This patch adds support for detecting that a query failed due to
the DB connection being down and attempts to reconnect before
retrying the query.  It does this for opening transactions,
safeExec(), and prepareAndExecuteQuery().
Merge pull request #103 from mamarley/psqlrefactor2

Improve reliability of PostgreSQL connections