Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
2.0.2
-
None
Description
Using Java 8 and MariaDB Connector/J 2.0.2-SNAPSHOT to connect to a MySQL 5.1.73 database results in an "access denied" error. The connection is created like this:
try (Connection c = DriverManager.getConnection(url, user, new String(password))) { |
System.out.printf("Connection class:%n%s%n", c.getClass().getName()); |
}
|
where url is something like this:
"jdbc:mariadb://127.0.0.1:3306/MYDB" |
and the result is the following stack trace:
Exception in thread "main" java.sql.SQLInvalidAuthorizationSpecException: Could not connect: Access denied for user 'luke'@'127.0.0.1' (using password: YES)
|
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:151)
|
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:115)
|
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.throwException(ExceptionMapper.java:89)
|
at org.mariadb.jdbc.Driver.connect(Driver.java:108)
|
at java.sql.DriverManager.getConnection(DriverManager.java:664)
|
at java.sql.DriverManager.getConnection(DriverManager.java:247)
|
at Main.main(Main.java:16)
|
Caused by: java.sql.SQLException: Could not connect: Access denied for user 'luke'@'127.0.0.1' (using password: YES)
|
Current charset is UTF-8. If password has been set using other charset, consider using option 'passwordCharacterEncoding'
|
at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.authentication(AbstractConnectProtocol.java:759)
|
at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.handleConnectionPhases(AbstractConnectProtocol.java:688)
|
at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connect(AbstractConnectProtocol.java:400)
|
at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1016)
|
at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:480)
|
at org.mariadb.jdbc.Driver.connect(Driver.java:103)
|
... 3 more
|
I also tried appending &passwordCharacterEncoding=UTF-8 to url, and another time &passwordCharacterEncoding=ISO-8859-1, neither of which helped.
Trying the same using MySQL Connector/J 5.1.42 (with mysql instead of mariadb in url) works fine.
Connecting using the mysql command line program from MySQL 5.7.18 works too, and, even though I doubt it matters, the \s command shows the following character set information:
Server characterset: latin1
|
Db characterset: latin1
|
Client characterset: utf8
|
Conn. characterset: utf8
|