Cannot create PoolableConnectionFactory (Access denied for user ''@'localhost'

坚强是说给别人听的谎言 提交于 2019-12-01 04:17:06

Your setup looks fine. This looks to purly be a permissions problem.

You need to grant that user access in mysql. While Java will connect to localhost, it will do so using tcp/ip - however in mysql localhost and 127.0.0.1 have different meaning. Issuing this SQL should do the trick.

grant all on twitter.* to 'root'@'127.0.0.1' identified by 'mypwd';

That assumes Java resolves 'localhost' to 127.0.0.1, if things still doesn't work, you could try changing your connection string to "jdbc:mysql://127.0.0.1:3306/twitter"

Should I have this in my context.xml or just the normal password?

As you have it now, the plaintext password.

In your configuration context.xml for the webapp you have to change user="root" by username="root"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!