Added Error if database is not defined/ connected but is autoloader. Added appropriate test case.