Unable to connect to Mysql via JDBC but works fine with Mysql
Which MySQL Version you are using ? 

You won't be able to use root user I guess.

Create new application user and use that user for application.

CREATE USER appuser@'%' identified by 'PASSWORD';
Grant SELECT on *.* to appuser@'%';
flush privileges;