Add more detailed error messages on SQL connection failure.

Fixes #1322