2

I am trying to get all the schema from a database which I passed in the connection url in snowflake jdbc driver.

Observation : I am getting all the schema from all the databases even though I pass wrong database. wrong database/schema/warehouse does not validate during the connection creation time.

URL : jdbc:snowflake://XXXXX.region.aws.snowflakecomputing.com?role=custome_role&warehouse=test_wh&db=test_db&schema=test_schema &CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX=true

Why Snowflake JDBC driver does not validate the wrong warehouse/database/schema during connection creation time or query execution time?

Debasish Halder
  • 173
  • 3
  • 12
  • Is it possible that they are returning all databases visible to the role BECAUSE you passed in an invalid DB name? That seems to be reasonable behavior. – Eric Hauenstein Jun 29 '21 at 19:28
  • @debasish - When you say "wrong warehouse/database/schema" , do you imply non-existent ones?Or combination of DB / warehouse / schema to which the role does not have access to? – Srinath Menon Jun 30 '21 at 02:36
  • @EricHauenstein Yes returning all visible databases to the role. But I passed invalid DB which does not exist in that account at all. – Debasish Halder Jun 30 '21 at 03:43
  • @SrinathMenon Yes, I implied non-existing DB, which does not present in that account or any role. – Debasish Halder Jun 30 '21 at 03:44

2 Answers2

1

Use

statement.executeQuery("show databases;");

And check if the list contains the requested database

Eliko
  • 61
  • 1
  • 2
0

What I see is that there is no check on the DB name parameter being passed in the connection url. The only check that is done is for Role and if the role is existent then all the db's for that will be listed.

Srinath Menon
  • 1,479
  • 8
  • 11
  • I also observe same. I think driver should be send some error message in connection creation time if db does not exist or db insufficient privileged to access that db to provided role. – Debasish Halder Jun 30 '21 at 04:24