trinodb / trino

Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
https://trino.io
Apache License 2.0
10.46k stars 3.01k forks source link

SQLException does not return the correct SQLState when making connection failed #16504

Open xsgao-github opened 1 year ago

xsgao-github commented 1 year ago

When making a connection failed, the SQLException does not return the correct SQLState:

try (Connection conn = DriverManager.getConnection("jdbc:trino://localhost:8080/tpch", user, pwd)) {
   // ...
} catch (SQLException ex) {
    ex.getSQLState(); // always return "0"
}

At a minimum, we should reveal these two values:

SQLSTATE Error Scenario
08001 Unable to Connect Client unable to connect to the server
28000 Invalid Authorization Specification User enters invalid credentials (Bad username\password, and so on)

A general list of SQLStates can also be found here.

jinli-dev commented 2 months ago

I see this issue as well. When an error occurs, the SQLState is null (0), which means "successful completion" according to the wiki.

And this issue was reported more than one year ago. Could someone help to fix this?