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:
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.