Check the connecton before we use the database.

This fixes #3