cancel
Showing results for 
Search instead for 
Did you mean: 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to connect to SQL Warehouse from RStudio using U2M authentication

jmbabazi
New Contributor II

Hi Community,

Has anyone encountered the error below, and If yes, how did you solve it? My workspace is setup normally in UC. My workspace also has private endpoint setup. I am authentication over the browser when I run my R code, then right after the error is thrown

Error in dbConnect(drv, url = jdbc_url) :
Unable to connect JDBC to jdbc:databricks://adb-xxxxxx.xx.xxxxx.net:443;httpPath=/sql/1.0/warehouses/xxxxxxxxxx;AuthMech=11;Auth_Flow=2;EnableTokenCache=0;EnableArrow=0;
JDBC ERROR: [Databricks][JDBCDriver](500151) Error setting/closing session: Invalid local Address .

I'm getting this while using the R code below

library(RJDBC)
library(DBI)

setwd("/home")

# Set up JDBC connection parameters

jdbc_url <- "jdbc:databricks://adb-xxxxxx.2.xxxxx.net:443;httpPath=/sql/1.0/warehouses/xxxxxxx;AuthMech=11;Auth_Flow=2;EnableTokenCache=0;EnableArrow=0"

jdbc_driver <- "com.databricks.jdbc.Driver"

# Load the JDBC driver
drv <- RJDBC::JDBC(driverClass = "com.databricks.client.jdbc.Driver",
                   classPath = "DatabricksJDBC42.jar")

# Establish the connection  
conn <- dbConnect(drv, url = jdbc_url)

# Query table
result <- dbGetQuery(conn, "select count(*) from catalog.schema.table")
print(result)

 

1 ACCEPTED SOLUTION

Accepted Solutions

MehdiModarressi
New Contributor III

Hi 

You can use the below connection string for the JDBC driver. Make sure to NOT change the OAuth2ClientId

jdbc:databricks://<workspace url>:443/default;transportMode=http;ssl=1;httpPath=<sql path>;AuthMech=11;OAuth2ClientId=96eecda7-19ea-49cc-abb5-240097d554f5;Auth_Flow=2;EnableTokenCache=0;

 Hope this helps.

 

Regards,
Mehdi

View solution in original post

5 REPLIES 5

SLohse
New Contributor II

I am facing similar issue when connecting via DBeaver Client (JDBC driver version 2.6.40)

"[Databricks][JDBCDriver](500151) Error setting/closing session: Invalid local Address .
Invalid local Address"

MehdiModarressi
New Contributor III

Hi 

You can use the below connection string for the JDBC driver. Make sure to NOT change the OAuth2ClientId

jdbc:databricks://<workspace url>:443/default;transportMode=http;ssl=1;httpPath=<sql path>;AuthMech=11;OAuth2ClientId=96eecda7-19ea-49cc-abb5-240097d554f5;Auth_Flow=2;EnableTokenCache=0;

 Hope this helps.

 

Regards,
Mehdi

Hi. when I try this I get this new error message after successful browser OAuth authentification.

[Databricks][JDBCDriver](500593) Communication link failure. Failed to connect to server. Reason: HTTP Response code: 403, Error message: PERMISSION_DENIED: You do not have permission to autostart 0812-090825-9uy7yt4i.



MehdiModarressi
New Contributor III

This error indicates that the warehouse is not running, and your user may not have the privilege to start it. Try starting the SQL Warehouse from the UI.

jmbabazi
New Contributor II

Thanks everyone for the replies. It turned out that this is a known bug and they are working on a fix

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group