java.sql.SQLException: Access denied for user '"root"'@'localhost' (using password: YES)

偶遇问题描述如下:

java.sql.SQLException: Access denied for user '"root"'@'localhost' (using password: YES)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3515)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:911)
	at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3953)
	at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1276)
	.
	.
	.

原因分析:

在properties文件中写入了:

driverClass=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/test
user="root"
password="123456"

解决方法:

将properties中的user与password的双引号去掉即可。

你可能感兴趣的:(MySQL)