Look at the error message:
Unable to connect to any of the specified MySQL hosts.
It couldn't be a lot clearer - you are trying to connect to a MySql server which doesn't exist.
At a guess, you haven't alters the example code to address your actual installation - and you can't expect the example (which has to be for everyone who reads the book) to know in advance what your specific connection and login details are!