消息:用户'root'@'localhost'拒绝访问(使用密码:YES)

时间:2014-08-15 14:00:53

标签: java mysql jdbc

我正在尝试通过JDBC连接到我的数据库。我正确设置了所有参数,我检查了十次但是当我尝试运行程序时,它给了我错误:Access denied for user root@localhost using password yes

我做了我能在网上找到的所有内容,让我给你看两个截图:

enter image description here

enter image description here 我得到的错误:

 [java] Set the following properties:
 [java] dbms: mysql
 [java] driver: com.mysql.jdbc.Driver
 [java] dbName: testdb
 [java] userName: root
 [java] serverName: localhost
 [java] portNumber: 3306
 [java] Releasing all open resources ...
 [java] java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
 [java]     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1094)
 [java]     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4208)
 [java]     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4140)
 [java]     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:925)
 [java]     at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1747)
 [java]     at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1287)
 [java]     at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2494)
 [java]     at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2527)
 [java]     at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2309)
 [java]     at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
 [java]     at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
 [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
 [java]     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 [java]     at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
 [java]     at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
 [java]     at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:419)
 [java]     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:344)
 [java]     at java.sql.DriverManager.getConnection(DriverManager.java:571)
 [java]     at java.sql.DriverManager.getConnection(DriverManager.java:187)
 [java]     at com.oracle.tutorial.jdbc.JDBCTutorialUtilities.getConnection(JDBCTutorialUtilities.java:289)
 [java]     at com.oracle.tutorial.jdbc.CoffeesTable.main(CoffeesTable.java:376)
 [java] SQLState: 28000
 [java] Error Code: 1045
 [java] Message: Access denied for user 'root'@'localhost' (using password: YES)

我不明白的是,当我运行程序时,它创建数据库没有任何问题但是一旦我运行该类在表中进行一些更新,它就不起作用。

0 个答案:

没有答案