我正在尝试使用pyspark从hadoop群集使用Windows身份验证连接到sql服务器数据库,但一直遇到问题。有人可以帮忙吗?
我尝试指定域名和密码,但是没有用。
代码:
DF = spark.read.format("jdbc") \
.option("url", "jdbc:sqlserver://SERVERNAME;database=DBNAME") \
.option("dbtable", "TABLENAME") \
.option("user", "DOMAIN\USERID") \
.option("password", "PWD") \
.option("driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver").load()
错误:
Py4JJavaError: An error occurred while calling o611.load.
: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user
'domain\userid'. ClientConnectionId:d1532bb7-8b63-4dc0-920f-87205fb0289a
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:259)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:256)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:108)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:4545)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3406)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:85)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3370)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7347)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2713)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2261)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1921)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1762)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1077)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:618)
at org.apache.spark.sql.execution.datasources.jdbc.DriverWrapper.connect(DriverWrapper.scala:45)
我也尝试过Integratedsecurity = true,但是由于我们的hadoop集群与sql server db不在同一个域中,因此也没有用。域名后,我也尝试用“ /”代替“ \”。