clickhouse-java icon indicating copy to clipboard operation
clickhouse-java copied to clipboard

connect() should fail if specifying a non-existent database in the JDBC URL

Open rogerbj opened this issue 2 years ago • 1 comments

Describe the bug

Specifying a non-existent database in the JDBC URLs results in the connection being established but following server calls fails.

Steps to reproduce

  1. Specify a non-existent database in the URL, i.e. jdbc:clickhouse://<host>:<port>/database

Expected behaviour

The connect should fail if the specified database doesn't exist rather than following calls after connect fails.

ClickHouse versions

  • ClickHouse Server version: 22.10.1.1877
  • ClickHouse JDBC version: 0.4.0 (revision: 3a53cf1)

rogerbj avatar Mar 15 '23 09:03 rogerbj

Thanks @rogerbj. But you can still issue queries against other databases, right? Or create the database before any query as mentioned in #826.

However, I do agree it's a bit confusing. With option createDatabaseIfNotExist, connecting to a database that doesn't exist makes no real sense any longer.

zhicwu avatar Mar 16 '23 01:03 zhicwu

This is still technically true - the underlying java client doesn't validate the database that you set. I don't think that's an issue though - the end user should know which databases they have, otherwise we'd have to do a server call just to validate for every connection.

Thank you for suggesting this, though!

Paultagoras avatar May 14 '25 01:05 Paultagoras