java.sql.SQLException: Communication failure

奇怪的问题,求教达人!我在IntelliJIDEA里边运行单个的java类,就可以连接到mysql数据库,但是我编译后放在to

奇怪的问题,求教达人!
我在IntelliJ   IDEA   里边运行单个的java类,就可以连接到mysql数据库,但是我编译后放在tomcat下就会出现这个错误,
java.sql.SQLException:   Communication   failure   during   handshake.   Is   there   a   server
  running   on   localhost:3306?
                at   org.gjt.mm.mysql.MysqlIO.init(Unknown   Source)
                at   org.gjt.mm.mysql.Connection.connectionInit(Unknown   Source)
....
怎么会有这个错误的?
我的mysql明明运行的好好的

[解决办法]
Is there a server
running on localhost:3306?
没看到吗?端口问题!建议把端口改了@