From da38fff2f585569e94be4fa7321b556396faec52 Mon Sep 17 00:00:00 2001 From: Clint Wylie Date: Mon, 13 Jul 2020 18:22:34 -0700 Subject: [PATCH 1/4] add explicit example for jdbc query context on connection properties --- docs/querying/sql.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/querying/sql.md b/docs/querying/sql.md index 895972fd8c4b..5b66b3344a36 100644 --- a/docs/querying/sql.md +++ b/docs/querying/sql.md @@ -885,6 +885,18 @@ Druid SQL supports setting connection parameters on the client. The parameters i All other context parameters you provide will be attached to Druid queries and can affect how they run. See [Query context](query-context.html) for details on the possible options. +```java +String url = "jdbc:avatica:remote:url=http://localhost:8082/druid/v2/sql/avatica/"; + +// Set any connection context parameters you need here. +Properties connectionProperties = new Properties(); +connectionProperties.setProperty("sqlTimeZone", "America/Los_Angeles"); +connectionProperties.setProperty("useCache", "false"); + +try (Connection connection = DriverManager.getConnection(url, connectionProperties)) { + // do some SQL stuff +} +``` Note that to specify an unique identifier for SQL query, use `sqlQueryId` instead of `queryId`. Setting `queryId` for a SQL request has no effect, all native queries underlying SQL will use auto-generated queryId. From fdb67bee7b3ddbf1388a8e1d47d0947097e972a3 Mon Sep 17 00:00:00 2001 From: Clint Wylie Date: Mon, 13 Jul 2020 18:26:55 -0700 Subject: [PATCH 2/4] make comment clearer --- docs/querying/sql.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/querying/sql.md b/docs/querying/sql.md index 5b66b3344a36..2a9b7c6b01aa 100644 --- a/docs/querying/sql.md +++ b/docs/querying/sql.md @@ -888,7 +888,7 @@ All other context parameters you provide will be attached to Druid queries and c ```java String url = "jdbc:avatica:remote:url=http://localhost:8082/druid/v2/sql/avatica/"; -// Set any connection context parameters you need here. +// Set any query context parameters you need here. Properties connectionProperties = new Properties(); connectionProperties.setProperty("sqlTimeZone", "America/Los_Angeles"); connectionProperties.setProperty("useCache", "false"); From 4bad16c502b32c90d6b5f2423e61e17323b3c643 Mon Sep 17 00:00:00 2001 From: Clint Wylie Date: Wed, 22 Jul 2020 17:14:26 -0700 Subject: [PATCH 3/4] Update sql.md --- docs/querying/sql.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/querying/sql.md b/docs/querying/sql.md index 2a9b7c6b01aa..4fcf70e1a345 100644 --- a/docs/querying/sql.md +++ b/docs/querying/sql.md @@ -849,7 +849,7 @@ try (Connection connection = DriverManager.getConnection(url, connectionProperti final ResultSet resultSet = statement.executeQuery(query) ) { while (resultSet.next()) { - // Do something + // process result set } } } @@ -894,9 +894,10 @@ connectionProperties.setProperty("sqlTimeZone", "America/Los_Angeles"); connectionProperties.setProperty("useCache", "false"); try (Connection connection = DriverManager.getConnection(url, connectionProperties)) { - // do some SQL stuff + // create and execute statements, process result sets, etc } ``` + Note that to specify an unique identifier for SQL query, use `sqlQueryId` instead of `queryId`. Setting `queryId` for a SQL request has no effect, all native queries underlying SQL will use auto-generated queryId. From 467f40145a6538b8f4f0bcd589321cbdf1f9b244 Mon Sep 17 00:00:00 2001 From: Clint Wylie Date: Wed, 22 Jul 2020 17:16:58 -0700 Subject: [PATCH 4/4] Update sql.md --- docs/querying/sql.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/querying/sql.md b/docs/querying/sql.md index 4fcf70e1a345..500b4566a107 100644 --- a/docs/querying/sql.md +++ b/docs/querying/sql.md @@ -829,9 +829,7 @@ delivered due to an error. ### JDBC -You can make Druid SQL queries using the [Avatica JDBC driver](https://calcite.apache.org/avatica/downloads/). Once -you've downloaded the Avatica client jar, add it to your classpath and use the connect string -`jdbc:avatica:remote:url=http://BROKER:8082/druid/v2/sql/avatica/`. +You can make Druid SQL queries using the [Avatica JDBC driver](https://calcite.apache.org/avatica/downloads/). We recommend using Avatica JDBC driver version 1.17.0 or later. Note that as of the time of this writing, Avatica 1.17.0, the latest version, does not support passing connection string parameters from the URL to Druid, so you must pass them using a `Properties` object. Once you've downloaded the Avatica client jar, add it to your classpath and use the connect string `jdbc:avatica:remote:url=http://BROKER:8082/druid/v2/sql/avatica/`. Example code: