com.microsoft.sqlserver.jdbc.SQLServerException

Waqas Jamil 6 Reputation points
2021-02-10T19:51:01.793+00:00

66691-e111.pnghi developers,

I got stuck into an issue and this problem has already wasted my three days.

I am trying to connect PySpark with MSSQL but failed. I have tried almost all possible solutions available on internet but nothing worked for me.
MSSQL is setup on google compute engine vm with Centos OS.

df = spark.read.format("jdbc") \
.option("url", "jdbc:sqlserver://x.x.x.x;encrypt=false;databaseName=x.x.x") \
.option("dbtable", "x.x.x") \
.option("user", "x.x.x.x") \
.option("password", "x.x.x.x") \
.option("driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver").load()

You can find the error snapshot in attachment. Please suggest me the solution, its really important for me.

thanks.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,127 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,665 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sean Gallardy - MSFT 1,886 Reputation points Microsoft Employee
    2021-02-10T22:51:56.88+00:00

    From the error message in the tiny screenshot:

    The driver could not establish a secure connection to SQL Server by using SSL [...] "SQL Server returned an incomplete response"

    From your connection string:

    encrypt=false;

    The first thing would be to allow encryption. The second thing is look at the SQL Server errorlog and configuration to see if it's forcing encryption (though a different error message should have appeared). The third is get a packet capture to make sure the SSL 3-way handshake it happening and that it is indeed responding to requests.

    1 person found this answer helpful.

  2. CathyJi-MSFT 22,321 Reputation points Microsoft Vendor
    2021-02-11T05:54:13.85+00:00

    Hi @Waqas Jamil ,

    Could you install Network Monitor 3.4 on SQL server and SQL client to capture network package to check if you get any error message when SSL 3-way handshake happening? Did the version of SSL are same on SQL Server and client?


    If the response is helpful, please click "Accept Answer" and upvote it, thank you.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.