I find it hard to establish a link between jdbc and mysql. I think one of the reasons is the mysql port. I checked the port with the statement: \"show variables like \'port\';\"
I had this problem because I had forgotten that I started mysqld with the --skip-networking
flag in order to reset the MySQL root password, like so:
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
Run ps aux | grep mysql
and you may see the process (or a pair of them) hanging around still. If so, kill it/them and then restart mysql.