Merge pull request #1601 from rwillert/patch-1

Reconnect to PostgreSQL database if connection dropped.