[CONJ-606] invalid or undocumented error code and state returned when MariaDB server is down Created: 2018-05-16  Updated: 2023-12-15  Resolved: 2023-12-15

Status: Closed
Project: MariaDB Connector/J
Component/s: JDBC 4.2 compatibility
Affects Version/s: 2.2.1
Fix Version/s: 3.0.0

Type: Bug Priority: Minor
Reporter: Vidyasagar Mundroy Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

JDBC driver 2.2.1, MariaDB 10.1.30, Ubuntu 16.04 LTS


Attachments: Java Source File MariaDbInvErrorCodeBug.java    

 Description   

If a database connection is tried when MariaDB server is down, the JDBC driver returns following error information:

Error code:-1
SQL State:08
Message:Could not connect to address=(host=localhost)(port=3306)(type=master) : Connection refused (Connection refused)

I believe error code -1 is not a valid error code and not documented at https://mariadb.com/kb/en/library/mariadb-error-codes/. Further, SQL State is expected to be 5 characters but not sure if it is right to return 2 character major class of errors.

Above mentioned error information can be reproduced by running attached program as following:

java MariaDbInvErrorCodeBug org.mariadb.jdbc.Driver jdbc:mariadb://localhost:3306/bladb blauser blapasswd

Output displayed by the program is as following:
Error code:-1
SQL State:08
Message:Could not connect to address=(host=localhost)(port=3306)(type=master) : Connection refused (Connection refused)



 Comments   
Comment by Diego Dupin [ 2023-12-15 ]

late answer, but SQLState now returns "08000" since 3.0

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