Legacy Databricks JDBC Driver
Note
The following information applies to legacy Databricks JDBC Driver 2.6.22 and below.
For information about Databricks JDBC Driver 2.6.25 and above, see Databricks JDBC Driver.
To use a JDBC connection URL to authenticate using a Databricks personal access token, set the following properties collection, replacing <personal-access-token>
with your Databricks personal access token:
jdbc:spark://<server-hostname>:443;httpPath=<http-path>;transportMode=http;SSL=1;UID=token;PWD=<personal-access-token
Databricks recommends that you use the most secure authentication flow available. The authentication flow described in this article carries risks that are not present in other flows. You should only use this flow when other more secure flows, such as managed identities, aren’t viable.
To use Java code to authenticate using a Databricks personal access token, set the following properties collection, replacing <personal-access-token>
with your Databricks personal access token:
// ...
String url = "jdbc:spark://<server-hostname>:443;httpPath=<http-path>;transportMode=http;SSL=1";
Properties p = new java.util.Properties();
p.put("UID", "token");
p.put("PWD", "<personal-access-token>");
// ...
DriverManager.getConnection(url, p);
// ...
The legacy Databricks JDBC Driver requires setting the transportMode and SSL properties. Databricks recommends that you set these values to
http
and1
, respectively.For a complete Java code example that you can adapt as needed, see the beginning of Authentication settings for the Databricks JDBC Driver.
To get the values for
<server-hostname>
and<http-path>
, see the following procedures.
To get the connection details for a Databricks cluster:
Log in to your Databricks workspace.
In the sidebar, click Compute.
In the list of available clusters, click the target cluster’s name.
On the Configuration tab, expand Advanced options.
Click the JDBC/ODBC tab.
Copy the connection details that you need, such as Server Hostname, Port, and HTTP Path.
To get the connection details for a Databricks SQL warehouse, do the following:
Log in to your Databricks workspace.
In the sidebar, click SQL > SQL Warehouses.
In the list of available warehouses, click the target warehouse’s name.
On the Connection Details tab, copy the connection details that you need, such as Server hostname, Port, and HTTP path.
To use the driver with a Databricks cluster, there are two permissions that the calling user or service principal needs when connecting to or restarting the cluster:
CAN ATTACH TO permission to connect to the running cluster.
CAN RESTART permission to automatically trigger the cluster to start if its state is terminated when connecting.
To use the driver with a Databricks SQL warehouse, the calling user or service principal needs CAN USE permission. The Databricks SQL warehouse automatically starts if it was stopped.
Note
Databricks SQL warehouses are recommended when using Microsoft Power BI in DirectQuery mode.