org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection;

来源:互联网 发布:js 创建key value数组 编辑:程序博客网 时间:2024/05/16 19:39

今天在自建一个maven web项目,在进行测试的时候,报错,详细信息如下:

### 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 file [E:\work_pratise\happyrunning\happyrunning\target\classes\com\zxc\happy\mapping\UserMapper.xml]### The error may involve com.zxc.happy.dao.UserMapper.selectByPrimaryKey### 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))

网上遇到此问题的好多帖子,更多的是表示配置出问题,参考链接如下:

http://blog.csdn.net/liwuyang2013/article/details/25986597

http://blog.csdn.net/cool_easy/article/details/42913811

检查jdbc.properties的配置,路径以及用户密码都没有问题,驱动类jar包也有,后来仔细检查,发现在配置文件:

jdbc.driver=com.mysql.jdbc.Driverjdbc.url=jdbc:mysql://localhost:3306/running_man?useUnicode=true&characterEncoding=utf8jdbc.username=rootjdbc.password=root 
jdbc.password=root后面有空格,这样就会报上述错误,而且在这四条配置中,若后面有空格,都会报上述错误

阅读全文
1 0