Check if the database exists before connection