What is the difference between the connection object and the command class in the context of database programming?