seckill icon indicating copy to clipboard operation
seckill copied to clipboard

我jdbc.properties里的usename写的是root为啥debug queryById的时候报错Access denied for user 'JAY'@'localhost' (using password: YES)。。。我是小白。。

Open tmlvampire opened this issue 8 years ago • 11 comments

tmlvampire avatar Apr 15 '17 14:04 tmlvampire

这是因为你数据库没连接上,用户名或者密码错了。小白的话去网上看看如何配置mysql的

发自网易邮箱大师 在2017年04月15日 22:24,tmlvampire 写道:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

codingXiaxw avatar Apr 16 '17 04:04 codingXiaxw

数据库我确定是对的 因为不用配置文件的话就连上了。。。。。。用了jdbc,properties就报这个错。。好奇怪

tmlvampire avatar Apr 17 '17 06:04 tmlvampire

既然能连上那应该不是数据库没打开的缘故,估计是你的spring配置文件中没有将jdbc.properties正确的配置上,再检查下你的resources包下的spring-dao文件试试

codingXiaxw avatar Apr 19 '17 09:04 codingXiaxw

spring-dao.xml中,用了${username}之后它好像会取当前计算机用户名来连数据库,spring-dao.xml和jdbc.properties的中username改成user就好使了,希望能帮到你们。

delme-bat avatar Apr 25 '17 02:04 delme-bat

啊哈这种错误我不清楚,不过好像又长了新姿势哈!那使用${username}不能成功连接数据库的建议将参数username换成user试试,谢谢这位小兄弟!

codingXiaxw avatar Apr 25 '17 07:04 codingXiaxw

亲测有效,spring-dao.xml和jdbc.properties的中username改成user有用,谢谢各位帮忙解决的层主

oldbig-carry avatar Aug 03 '17 03:08 oldbig-carry

不能用username做key

leetomlee123 avatar Mar 25 '18 07:03 leetomlee123

mac中应该好的

ericzhanghz avatar Apr 04 '18 12:04 ericzhanghz

就是${username}被系统变量覆盖了,不要用username做key即可

chenchuxin avatar Apr 09 '18 09:04 chenchuxin

你们怎么运行的啊,数据库都没有啊

jiangjianpeng avatar May 26 '18 03:05 jiangjianpeng

楼上说的都对的,用户名被覆盖了,一般我写jdbc.properties的时候都会加上jdbc. 的前缀,个人认为比较规范。 jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/seckill?useUnicode=true&characterEncoding=utf-8 jdbc.username=root jdbc.password=root

ijiroterunao avatar Mar 21 '19 12:03 ijiroterunao