Well obviously an Exception is being thrown so it will display "Cannot connect to server".
presumably not "Cannot connect to database" as you specified.

As you do not seem to be printing out the...