Check we got a database name before trying to get its comment

Working from a bug report from Hervé Werner.