[CONJ-166] SQLException for "Access denied for user" does not contain the vendor code Created: 2015-07-09  Updated: 2016-01-19  Resolved: 2015-07-17

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 1.1.9
Fix Version/s: 1.2.0

Type: Bug Priority: Major
Reporter: Paolo Bazzi Assignee: Diego Dupin
Resolution: Fixed Votes: 1
Labels: None

Attachments: Java Source File BugConnectionErrorCode.java    

 Description   

Trying to connect with a wrong username or password returns an SQLException which does not contain the correct expected error code (1045).

Trying with command line:
>mysql -u bar -pfoo testdb
ERROR 1045 (28000): Access denied for user 'bar'@'localhost' (using password: YES)

Using the attached test program reproduces the error:

Output MariaDB connector
MariaDB Exception: java.sql.SQLException: Could not connect: Access denied for user 'foo'@'localhost' (using password: YES)
MariaDB ErrorCode: -1
MariaDB SQLState: HY0000

Output MySQL connector
MySQL Exception: java.sql.SQLException: Access denied for user 'foo'@'localhost' (using password: YES)
MySQL ErrorCode: 1045
MySQL SQLState: 28000

-> We need this error code in order to be able to detect if a connection is setup using a wrong username or password.



 Comments   
Comment by Diego Dupin [ 2015-07-17 ]

done in next version 1.2.0

Comment by Paolo Bazzi [ 2016-01-19 ]

Verified with driver mariadb-java-client-1.3.3.jar and works as expected!

Generated at Thu Feb 08 03:13:39 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.