Step 1: Download and Reference the JDBC Driver
Download the Databricks JDBC Driver:
- Download the appropriate version for your operating system.
- Extract the DatabricksJDBC42.jar file from the downloaded zip file.
Step 2: Gather Configuration Settings
Gather Configuration Settings:
- Server Hostname: The hostname of your Azure Databricks cluster or SQL warehouse.
- Port: The port number (default is 443).
- HTTP Path: The HTTP path to your Databricks SQL endpoint.
- Authentication Token: A personal access token or Microsoft Entra ID (formerly Azure Active Directory) token.
Step 3: Create a Personal Access Token
Create a Personal Access Token:
- In your Azure Databricks workspace, click your username in the top bar and select Settings.
- Next to Access tokens, click Manage.
- Click Generate new token.
- Optionally, enter a comment and set the token's lifetime.
- Click Generate and copy the token to a secure location.
Step 4: Configure the JDBC Connection
Configure the JDBC Connection:
- Use the following JDBC URL format:
jdbc:spark://<Server Hostname>:<Port>/;transportMode=http;ssl=1;httpPath=<HTTP Path>;AuthMech=3;UID=token;PWD=<Personal Access Token>
- Replace <Server Hostname>, <Port>, <HTTP Path>, and <Personal Access Token> with your specific values.
Step 5: Connect Using JDBC
Connect Using JDBC:
- Depending on your programming language or tool, use the JDBC URL to establish a connection.
%python
import jaydebeapi
jdbc_url = "jdbc:spark://<Server Hostname>:<Port>/;transportMode=http;ssl=1;httpPath=<HTTP Path>;AuthMech=3;UID=token;PWD=<Personal Access Token>"
driver_class = "com.simba.spark.jdbc.Driver"
jar_file = "/path/to/DatabricksJDBC42.jar"
conn = jaydebeapi.connect(driver_class, jdbc_url, jars=jar_file)
cursor = conn.cursor()
cursor.execute("SELECT * FROM my_table")
result = cursor.fetchall()
cursor.close()
conn.close()
I have followed the above steps to connect to Azure Databricks using JDBC protocol. I am using Python to connect but getting below error:
raise JVMNotFoundException("No JVM shared library file ({0}) "
jpype._jvmfinder.JVMNotFoundException: No JVM shared library file (jvm.dll) found. Try setting up the JAVA_HOME environment variable properly.
Please help me with this and also let me know if there is another way without having JVM. Thanks