在使用JdbcTemplate执行sql语句时,出现错误如下
org.springframework.jdbc.CannotGetJdbcConnectionException:
Could not get JDBC Connection;
nested exception is java.sql.SQLException:
Access denied for user 'CMCST'@'localhost' (using password: YES)
此时采用的是在applicationContex.xml中引入jdbc.properties文件,该文件内容为:
driver = com.mysql.cj.jdbc.Driver
url = jdbc:mysql://127.0.0.1:3306/spring
userName = root
passWord = root
解决方法:
jdbc.driver = com.mysql.cj.jdbc.Driver
jdbc.url = jdbc:mysql://127.0.0.1:3306/spring
jdbc.userName = root
jdbc.passWord = root
如此便解决了