This directory contains the example of querying data via Databricks SQL Endpoint or Databricks Cluster using JDBC protocol. Since version 2.6.36 the JDBC driver supports OAuth authentication. Following examples demonstrate that:
SimbaJDBCAadTokenUser
- authentication to Databricks is performed using Azure Active Directory tokens issued for the current user.SimbaJDBCAadTokenServicePrincipal
- authentication to Databricks is performed using Azure Active Directory tokens issued for Azure Service Principal.
Right now many parameters are hard-coded, so you need to change them before running.
You need to update source code and adjust following parameters:
query
- what query should be executedclientId
- client ID of application in Azure Active DirectoryclientSecret
- secret for AAD application (ideally should be taken from KeyVault);host
- the host portion of the Databricks workspace (obtained from SQL Warehouse configuraiton)httpPath
- the HTTP Path of the SQL Warehouse (obtained from SQL Warehouse configuraiton)
query
- what query should be executedhost
- the host portion of the Databricks workspace (obtained from SQL Warehouse configuraiton)httpPath
- the HTTP Path of the SQL Warehouse (obtained from SQL Warehouse configuraiton)oauthClientId
- (optional) if you don't have Azure application with namedatabricks-sql-jdbc
, then set it to the Application ID of the Azure application that will be used for authentication.
Just execute mvn package
to build the code, and then you can execute resulting uber jar:
java -cp target/simba-jdbc-aad-token-0.0.2-jar-with-dependencies.jar \
net.alexott.demos.SimbaJDBCAadTokenServicePrincipal
Or the code could be executed from an IDE.