使用集成身份验证的Databricks SQL Server连接

2024-07-03 06:01:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用python将我的Databricks集群连接到现有的SQL Server数据库。我想利用集成身份验证方法。获取错误com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication.

jdbcHostname = "sampledb-dev.database.windows.net"
jdbcPort= 1433
jdbcDatabase = "sampledb-dev"
jdbcUrl = "jdbc:sqlserver://{0}:{1}; database={2}".format(jdbcHostname, jdbcPort, jdbcDatabase)

connectionProperties={
  "integratedSecurity" : "true",
  "driver" : "com.microsoft.sqlserver.jdbc.SQLServerDriver"
}

print(jdbcUrl)
query ="(SELECT * FROM TABLE1.Domain)"

domains = spark.read.jdbc(url = jdbcUrl, table = query, properties = connectionProperties)
display(domains) 

Tags: devcomdriverquerydatabasemicrosoftdomainssqlserver
1条回答
网友
1楼 · 发布于 2024-07-03 06:01:52

您不能将integratedSecurity=true与Azure PaaS数据库一起使用IntegratedSecurity是一个内部构造

您需要使用authentication=ActiveDirectoryIntegratedauthentication=ActiveDirectoryPassword,请参见此处的JDBC文档: https://docs.microsoft.com/en-us/sql/connect/jdbc/connecting-using-azure-active-directory-authentication?view=sql-server-ver15

您还需要您的帐户是对同步到Azure AD的数据库具有适当权限的用户。如果您使用多因素身份验证,则JDBC不支持这种身份验证,并且您的管理员需要为您提供一个未启用MFA的帐户。您将知道是否是这种情况,因为在尝试连接时会出现WSTrust错误

相关问题 更多 >