Throw an exception when no connection has been defined for a database (fixes #620)

Is a RuntimeException ok or a more specific exception would be better?