java.sql.SQLException: Access denied for user ‘somebody’@‘localhost’ (using password: YES)
整合SSM时出现了一个错误:
这个问题困惑了我快一天,网上搜了很多类似的错误处理方法,发现对我的情况没有用。
最后发现是database.properties配置文件中的配置名写的不对,由于之前经常使用的druid连接池,现在换到了c3p0,有些不习惯
原先是这样配置数据库连接信息的:
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/ssmbuild?useSSL=true&useUnicode=true&characterEncoding=utf-8
username=root
password=root
改成这样就可以了:
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ssmbuild?useSSL=true&useUnicode=true&characterEncoding=utf-8
jdbc.username=root
jdbc.password=root
新的发现,改成这样也可以:
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/ssmbuild?useSSL=true&useUnicode=true&characterEncoding=utf-8
user=root password=root
只要不写成username好像都可以,username这个变量好像被jvm环境占用了
————————————————
原文链接:https://blog.csdn.net/qq_45659339/article/details/110010197