Skip to content

Result of connection.isValid() returned true even incorrect credentials provided #2472

@CharlieCaiHZ

Description

@CharlieCaiHZ

Description

Result of connection.isValid() returned true even incorrect credentials provided

Steps to reproduce

  1. using provided code example, give correct host
  2. give incorrect username and password
  3. run the code, it will return "Connection to ClickHouse is valid.".

Error Log or Exception StackTrace

Expected Behaviour

Return false if credential incorrect

Code Example

import java.sql.Connection;
import java.sql.DriverManager;

public class ClickHouseConnectionTest {
    public static void main(String[] args) {
        String url = "jdbc:clickhouse://<host>:<port>/<database>";
        String user = "incorrectuser";      // optional
        String password = "incorrectpwd";  // optional

        try (Connection connection = DriverManager.getConnection(url, user, password)) {
            if (connection.isValid(5)) {
                System.out.println("Connection to ClickHouse is valid.");
				
				
            } else {
                System.out.println("Connection established, but not valid.");
            }
        } catch (Exception e) {
            System.err.println("Failed to connect to ClickHouse:");
            e.printStackTrace();
        }
    }
}

Configuration

Client Configuration

Environment

  • Cloud
  • Client version: clickhouse-jdbc-0.8.6-shaded-all.jar
  • Language version:
  • OS:

ClickHouse Server

  • ClickHouse Server version:
  • ClickHouse Server non-default settings, if any:
  • CREATE TABLE statements for tables involved:
  • Sample data for all these tables, use clickhouse-obfuscator if necessary

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:jdbc-metadataissue handling metadata things like getting type of columnbugjdbc-v2jdbc-v2 issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions