From c4705c3b672e0e40774bba413ffd6d17f369fdfd Mon Sep 17 00:00:00 2001 From: Eirik Bakke Date: Mon, 24 Feb 2025 16:31:48 -0500 Subject: [PATCH] Have the New Connection wizard recognize the Google BigQuery JDBC driver and JDBC URLs. --- .../modules/db/util/DriverListUtil.java | 9 +++++++++ .../modules/db/util/DriverListUtilTest.java | 20 +++++++++++++++++++ 2 files changed, 29 insertions(+) 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 37bf20b05d29..a5ed734196b7 100644 --- a/ide/db/src/org/netbeans/modules/db/util/DriverListUtil.java +++ b/ide/db/src/org/netbeans/modules/db/util/DriverListUtil.java @@ -406,6 +406,15 @@ 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"); + + // See https://cloud.google.com/bigquery/docs/reference/odbc-jdbc-drivers#jdbc_release_1621003 + url = add("Google BigQuery", null, "com.simba.googlebigquery.jdbc.Driver", + "jdbc:bigquery://https:///bigquery/v2:;ProjectId=;", true); + /* None of the available authentication methods use a JDBC-level username/password prompt. + (Instead, an external browser may be opened to prompt for credentials when the user attempts + to connect.) */ + url.setUsernamePasswordDisplayed(false); + url.setSampleUrl("jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=ProjectIdGoesHere;OAuthType=1;"); } public static Set getDrivers() { 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 1b4fef71298c..26b79a4e66b8 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 @@ -348,6 +348,26 @@ public void testSnowflake() throws Exception { propValues = buildPropValues(requiredProps); testUrlString(url, propValues, "jdbc:snowflake://" + HOST + "/"); } + + public void testBigQuery() throws Exception { + ArrayList supportedProps = new ArrayList<>(); + supportedProps.add(JdbcUrl.TOKEN_HOST); + supportedProps.add(JdbcUrl.TOKEN_PORT); + supportedProps.add(JdbcUrl.TOKEN_INSTANCE); + supportedProps.add(JdbcUrl.TOKEN_ADDITIONAL); + ArrayList requiredProps = new ArrayList<>(); + requiredProps.add(JdbcUrl.TOKEN_HOST); + requiredProps.add(JdbcUrl.TOKEN_PORT); + requiredProps.add(JdbcUrl.TOKEN_INSTANCE); + requiredProps.add(JdbcUrl.TOKEN_ADDITIONAL); + JdbcUrl url = checkUrl("Google BigQuery", null, "com.simba.googlebigquery.jdbc.Driver", + "jdbc:bigquery://https:///bigquery/v2:;ProjectId=;", + supportedProps, requiredProps); + HashMap propValues = buildPropValues(supportedProps); + testUrlString(url, propValues, "jdbc:bigquery://https://" + HOST + "/bigquery/v2:" + PORT + ";ProjectId=" + INSTANCE + ";" + ADDITIONAL); + propValues = buildPropValues(requiredProps); + testUrlString(url, propValues, "jdbc:bigquery://https://" + HOST + "/bigquery/v2:" + PORT + ";ProjectId=" + INSTANCE + ";" + ADDITIONAL); + } enum DB2Types { DB2, IDS, CLOUDSCAPE };