0

I'm trying to connect to my database through JDBC. I set all of the parameters correctly, I checked it ten times but when I try to run my programs, it gives me that error: Access denied for user root@localhost using password yes.

I did everything that I could find on the Internet, let me show you two screenshots:

enter image description here

enter image description here The error I get:

 [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)

What I don't understand is that when I run the program, it creates the database without any problem but once I run the the class to make some update in the table, it doesn't work.

Duncan Jones
  • 67,400
  • 29
  • 193
  • 254
user3884432
  • 291
  • 3
  • 6
  • 1
    you use the wrong password – Marco Acierno Aug 15 '14 at 14:03
  • 2
    Instead of posting screenshots, could you copy and paste the actual text. – Mark Rotteveel Aug 15 '14 at 14:03
  • 3
    When you set the password it said "0 rows affected" which is probably causing unexpected behavior – mjr Aug 15 '14 at 14:06
  • 3
    possible duplicate of [Access denied for user 'root'@'localhost' (using password: YES) (Mysql::Error)](http://stackoverflow.com/questions/6081339/access-denied-for-user-rootlocalhost-using-password-yes-mysqlerror) – pherris Aug 15 '14 at 14:07
  • @MarcoAcierno: When I try through the terminal, it works perfectly. My password is set on ant so I don't think it's the wrong one. – user3884432 Aug 15 '14 at 14:08
  • 1
    @user3884432 well do a test without ANT. Just create a dumb Java program with hardcoded connection properties and try to connect to the database that way; if that doesn't work either then I agree with you that there is likely no configuration error in your ANT stuff. – Gimby Aug 15 '14 at 14:20

0 Answers0