解决Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException

时间:2024-03-16 21:48:54

今天写项目时遇到这个问题: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: NO))
发现是没修改密码,所以连接不上MySQL数据库。如图所示:
解决Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException
找到db.properties文件,将密码改为自己的MySQL数据库连接密码。
datasource.connection.driver_class=com.mysql.jdbc.Driver
datasource.connection.url=jdbc:mysql://localhost:3306/db?useUnicode=true&characterEncoding=utf-8
datasource.connection.username=root
datasource.connection.password=123456
我设的密码为:123456
修改后数据库连接成功!
解决Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException