housepower / ClickHouse-Native-JDBC

ClickHouse Native Protocol JDBC implementation
https://housepower.github.io/ClickHouse-Native-JDBC/
Apache License 2.0
527 stars 145 forks source link

Why can't I return error information such as incorrect passwords? #450

Closed beijishiqidu closed 1 year ago

beijishiqidu commented 1 year ago

Environment

Error logs (ClickHouse-Native-jdbc Response interface source code)

public interface Response {

    ProtoType type();

    static Response readFrom(BinaryDeserializer deserializer, NativeContext.ServerContext info) throws IOException, SQLException {
        switch ((int) deserializer.readVarInt()) {
            case 0:
                return HelloResponse.readFrom(deserializer);
            case 1:
                return DataResponse.readFrom(deserializer, info);
            case 2:
                throw ExceptionResponse.readExceptionFrom(deserializer);
            case 3:
                return ProgressResponse.readFrom(deserializer);
            case 4:
                return PongResponse.readFrom(deserializer);
            case 5:
                return EOFStreamResponse.readFrom(deserializer);
            case 6:
                return ProfileInfoResponse.readFrom(deserializer);
            case 7:
                return TotalsResponse.readFrom(deserializer, info);
            case 8:
                return ExtremesResponse.readFrom(deserializer, info);
            case 9:
                throw new NotImplementedException("RESPONSE_TABLES_STATUS_RESPONSE");
            default:
                throw new IllegalStateException("Accept the id of response that is not recognized by Server.");
        }
    }

Steps to reproduce

When I use an incorrect ClickHouse password to link to ClickHouse, the system displays Accept the id of response that is not recognized by Server. The client driver returns this error message. Why is it not an error message such as incorrect user name or password?

#

demetribu commented 1 year ago

Hello,

Could you provide more detailed information regarding your issue? I've tried reproducing the problem you described, and the error I received is as follows:

com.github.housepower.exception.ClickHouseSQLException: DB::ExceptionDB::Exception: default: Authentication failed: password is incorrect or there is no user with such name. Stack trace:
0. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0x93b195a in /usr/bin/clickhouse
1. DB::IAccessStorage::throwCannotAuthenticate(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) @ 0x102f585f in /usr/bin/clickhouse
2. DB::IAccessStorage::login(DB::Credentials const&, Poco::Net::IPAddress const&, DB::ExternalAuthenticators const&, bool) const @ 0x102f5572 in /usr/bin/clickhouse
3. DB::Session::authenticate(DB::Credentials const&, Poco::Net::SocketAddress const&) @ 0x10e2791c in /usr/bin/clickhouse
4. DB::TCPHandler::receiveHello() @ 0x1184649a in /usr/bin/clickhouse
5. DB::TCPHandler::runImpl() @ 0x1183fe20 in /usr/bin/clickhouse
6. DB::TCPHandler::run() @ 0x11853a99 in /usr/bin/clickhouse
7. Poco::Net::TCPServerConnection::start() @ 0x1441490f in /usr/bin/clickhouse
8. Poco::Net::TCPServerDispatcher::run() @ 0x1441639a in /usr/bin/clickhouse
9. Poco::PooledThread::run() @ 0x14548619 in /usr/bin/clickhouse
10. Poco::ThreadImpl::runnableEntry(void*) @ 0x145448aa in /usr/bin/clickhouse
11. start_thread @ 0x9609 in /usr/lib/x86_64-linux-gnu/libpthread-2.31.so
12. __clone @ 0x122293 in /usr/lib/x86_64-linux-gnu/libc-2.31.so