From e45fcf7ccc188335244cf5d57e1b50ceecf836bf Mon Sep 17 00:00:00 2001 From: Eirik Bakke Date: Fri, 31 Jan 2025 11:24:24 -0500 Subject: [PATCH] Have the New Connection wizard recognize the Snowflake JDBC driver and JDBC URLs. --- .../netbeans/modules/db/util/DriverListUtil.java | 8 +++++++- .../modules/db/util/DriverListUtilTest.java | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ide/db/src/org/netbeans/modules/db/util/DriverListUtil.java b/ide/db/src/org/netbeans/modules/db/util/DriverListUtil.java index 1cfdc746508f..37bf20b05d29 100644 --- a/ide/db/src/org/netbeans/modules/db/util/DriverListUtil.java +++ b/ide/db/src/org/netbeans/modules/db/util/DriverListUtil.java @@ -400,8 +400,14 @@ following fully-qualified class names (FQCNs) that are independent of the JDBC v /* I think H2 can sometimes use a password with the database, even though it's a file-based database. So keep the username/password displayed in this case. */ // url.setUsernamePasswordDisplayed(false); + + /* There is also a driver class com.snowflake.client.jdbc.SnowflakeDriver, which is + deprecated. The one below (starting "net") is the currently recommended one. See + https://docs.snowflake.com/en/developer-guide/jdbc/jdbc-configure */ + url = add("Snowflake", null, "net.snowflake.client.jdbc.SnowflakeDriver", "jdbc:snowflake:///[?]", true); + url.setSampleUrl("jdbc:snowflake://my-account-id.snowflakecomputing.com/?warehouse=COMPUTE_WH"); } - + public static Set getDrivers() { TreeSet drivers = new TreeSet<>(); for (JdbcUrl url : templateUrls) { diff --git a/ide/db/test/unit/src/org/netbeans/modules/db/util/DriverListUtilTest.java b/ide/db/test/unit/src/org/netbeans/modules/db/util/DriverListUtilTest.java index 38774d0c8734..1b4fef71298c 100644 --- a/ide/db/test/unit/src/org/netbeans/modules/db/util/DriverListUtilTest.java +++ b/ide/db/test/unit/src/org/netbeans/modules/db/util/DriverListUtilTest.java @@ -333,6 +333,21 @@ public void testDuckDB() throws Exception { propValues.remove(JdbcUrl.TOKEN_FILE); testUrlString(url, propValues, "jdbc:duckdb:"); } + + public void testSnowflake() throws Exception { + ArrayList supportedProps = new ArrayList<>(); + supportedProps.add(JdbcUrl.TOKEN_HOST); + supportedProps.add(JdbcUrl.TOKEN_ADDITIONAL); + ArrayList requiredProps = new ArrayList<>(); + requiredProps.add(JdbcUrl.TOKEN_HOST); + JdbcUrl url = checkUrl("Snowflake", null, "net.snowflake.client.jdbc.SnowflakeDriver", + "jdbc:snowflake:///[?]", + supportedProps, requiredProps); + HashMap propValues = buildPropValues(supportedProps); + testUrlString(url, propValues, "jdbc:snowflake://" + HOST + "/?" + ADDITIONAL); + propValues = buildPropValues(requiredProps); + testUrlString(url, propValues, "jdbc:snowflake://" + HOST + "/"); + } enum DB2Types { DB2, IDS, CLOUDSCAPE };