title: SQLException: Access denied for user 'whatever'@'localhost'
body: <p>Credentials are correct, database name is correct, MySQL users are set correctly and have all the privileges, I have entries for 'username'@'%' as well as 'username'@'localhost', I can connect to this user via commandline correctly, as well as through mysql workbench. In other words, everything works as it should and is set as it should be, except my java app is unable to connect.</p>
  
  <p>I did about 3 clean uninstalls and installs of MySQL, with restarts, without restarts, tried to login through app as root (with pass) which didn't work, tried to login through app as user with no password (same error), etc.</p>
  
  <p>Also, a PHP website running on localhost using precisely the same login works perfectly.</p>
  
  <p>I've been checking and re-checking and trying all of this for the past 3 days, I went through all the related SO questions, all the blogs and docs I could find, all of it.</p>
  
  <pre><code>try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    conn = DriverManager.getConnection("jdbc:mysql://localhost/correctDBname", "correctUsername", "correctPassword");
  } catch(ClassNotFoundException | SQLException ex) {
    Logger.getLogger(SqlConnection.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
  }
  </code></pre>
  
  <p>MySQL driver name precisely as it appears in NetBeans' "Libraries" section in project: <strong>MySQL JDBC Driver - mysql-connector-java-5.1.23-bin.jar</strong></p>
  
  <p>Full text of the exception:</p>
  
  <pre><code>java.sql.SQLException: Access denied for user 'strada'@'localhost' (using password: YES)
  at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4120)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052)
  at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:925)
  at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1704)
  at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1250)
  at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2465)
  at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2498)
  at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2283)
  at com.mysql.jdbc.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:822)
  at com.mysql.jdbc.JDBC4Connection.&lt;init&gt;(JDBC4Connection.java:47)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
  at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:404)
  at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:317)
  at java.sql.DriverManager.getConnection(DriverManager.java:664)
  at java.sql.DriverManager.getConnection(DriverManager.java:247)
  at eu.storemedia.stradaserver.engine.SqlConnection.&lt;init&gt;(SqlConnection.java:23)
  at eu.storemedia.stradaserver.engine.StradaServer.&lt;init&gt;(StradaServer.java:51)
  at eu.storemedia.stradaserver.Home.&lt;clinit&gt;(Home.java:31)
  </code></pre>