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

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 and 1, 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, do the following:

  1. Log in to your Databricks workspace.

  2. In the sidebar, click Compute.

  3. In the list of available clusters, click the target cluster’s name.

  4. On the Configuration tab, expand Advanced options.

  5. Click the JDBC/ODBC tab.

  6. 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:

  1. Log in to your Databricks workspace.

  2. In the sidebar, click SQL > SQL Warehouses.

  3. In the list of available warehouses, click the target warehouse’s name.

  4. 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.