MyBatis connection Error Cannot create poolableconnectionfactory (Access denied for user ' root ' @ ' local

Source: Internet
Author: User

Org.mybatis.spring.MyBatisSystemException:nested exception is org.apache.ibatis.exceptions.PersistenceException:
# # # Error querying database. Cause:org.springframework.jdbc.CannotGetJdbcConnectionException:
Could not get JDBC Connection; Nested exception is org.apache.commons.dbcp.SQLNestedException:
Cannot create poolableconnectionfactory (Access denied for user ' root ' @ ' localhost ' (using Password:yes)
# # # The error may exist in Com/sample/mappers/employeemapper.xml
# # # The error may involve Com.sample.dao.EmployeeDao.listall
# # # The error occurred while executing a query
# # # Cause:org.springframework.jdbc.CannotGetJdbcConnectionException:
Could not get JDBC Connection; Nested exception is org.apache.commons.dbcp.SQLNestedException:
Cannot create poolableconnectionfactory (Access denied for user ' root ' @ ' localhost ' (using Password:yes)

Notice:the user is ' root ' not ' root '

The problem is roughly the need to check your data source configuration as in resource: Url,username,password

URL This is generally "jdbc:mysql://localhost:3306/test", must pay attention to 3306, this is your database connection with the port, you can change it to another, but if you use the Tomcat container, do not write it 8080, This will produce cannot create poolableconnectionfactory (Communications link failure problem, and there is url=jdbc:mysql://localhost:3306/ The localhost in test is not a random configuration, it depends on the from host in your database

I was really in MySQL Workbench5.2 ce in the Users and privileges, there is a server Access Management

User from host you see there is no localhost in host, if you can write url=jdbc:mysql://localhost:3306/test, if from Host has 127.0.0.1 words, can also be written url=jdbc:mysql://127.0.0.1:3306/test

There is username= this must be written correctly, I was writing is name=, the results of MySQL can not find username, and then he automatically set the username as "", so that the error hint: java.sql.SQLException:Access Denied for user ' @ ' localhost ' (using password:yes) do you see that the @ front is two single quotes, that is I did not input username and led to default default username, in fact, this error can also be changed with the set permissions, But that's MySQL content, don't say it.

Summed up is: the URL port to write to, can not write other programs are occupied, 127.0.01 or localhost to see which of the database, but also to put the driver into the project in the Web-inf/lib, here to mention do not put into Tomcat lib.

MyBatis connection Error Cannot create poolableconnectionfactory (Access denied for user ' root ' @ ' local

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.