This is an automated email from the ASF dual-hosted git repository.

cwylie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/master by this push:
     new 79dffef  add explicit example for jdbc query context on connection 
properties (#10182)
79dffef is described below

commit 79dffefbf8d51e3f46e235ec6741a810adcbd8f2
Author: Clint Wylie <[email protected]>
AuthorDate: Fri Jul 24 13:43:04 2020 -0700

    add explicit example for jdbc query context on connection properties 
(#10182)
    
    * add explicit example for jdbc query context on connection properties
    
    * make comment clearer
    
    * Update sql.md
    
    * Update sql.md
---
 docs/querying/sql.md | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/docs/querying/sql.md b/docs/querying/sql.md
index 895972f..500b456 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:avatic [...]
 
 Example code:
 
@@ -849,7 +847,7 @@ try (Connection connection = 
DriverManager.getConnection(url, connectionProperti
       final ResultSet resultSet = statement.executeQuery(query)
   ) {
     while (resultSet.next()) {
-      // Do something
+      // process result set
     }
   }
 }
@@ -885,6 +883,19 @@ 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 query 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)) {
+  // 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.
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to