init datasource error, url: jdbc:mysql://localhost:3306/test?characterEncoding=utf8&allowPublicKeyRetrieval=true&serverTimezone=UTC
java.sql.SQLException: Access denied for user ''@'localhost' (using password: YES)
給小弟講數據庫連接池的時候,出現了這錯誤
查了半天也沒查出來
這塊代碼就幾條不會出現錯誤,應該是配置文件出現了錯誤
查看他的配置如下
user=root password=12345678 #driver=com.mysql.cj.jdbc.Driver driver=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/test?characterEncoding=utf8&allowPublicKeyRetrieval=true&serverTimezone=UTC
原來是第一條就出現了錯誤,username簡寫為user。無語😓
做個筆記給新人,剛學時不要圖省事寫簡寫,將username寫為user,將password寫為pw。
不要粘貼上面的代碼哦😯