2

Attempt to connect jdbc to SQL Server.

The following error occurs when using the mssql jdbc driver:

sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Is it a compatibility issue between SQL Server and JDBC driver version? Or what's the problem?

However, the option trustServerCertificate=true resolves the issue using the mssql jdbc driver.

https://learn.microsoft.com/ko-kr/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server-support-matrix?view=sql-server-ver16

According to , my jdbc driver is 10.2, jre is 1.8 and sqlserver is 2018.

I want to know what the difference is between the two drivers.

  • There is no SQL Server 2018 - perhaps you're confusing SQL Server versions with those for SSMS (SQL Server Management Studio)? – AlwaysLearning Jun 02 '22 at 08:17
  • What is it exactly that you're calling "sql-jdbc4"? The Microsoft JDBC Driver 10.2 for SQL Server is a JDBC Type 4 driver itself, ref: [Download Microsoft JDBC Driver for SQL Server](https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server). – AlwaysLearning Jun 02 '22 at 08:17
  • In case you were unaware there was a breaking change in the Microsoft JDBC Driver 10.2 for SQL Server... previously `Encrypt=False/No` was the default connection string option, going forward the default will change to `Encrypt=True/Yes`, ref: [JDBC Driver 10.2 for SQL Server Released](https://techcommunity.microsoft.com/t5/sql-server-blog/jdbc-driver-10-2-for-sql-server-released/ba-p/3100754) – AlwaysLearning Jun 02 '22 at 08:19
  • @AlwaysLearning It is SQL Server 2017, but I wrote it incorrectly as 2018. I'm sorry. There is a file called sqljdbc42.jar, not sql-jdbc4. I checked the contents of this jar in the link below. https://learn.microsoft.com/en-us/sql/connect/jdbc/system-requirements-for-the-jdbc-driver?redirectedfrom=MSDN&view=sql-server-ver16 –  Jun 03 '22 at 00:14
  • "PKIX path building failed" means that Java cannot verify the SSL connection, because it doesn't know about the server certificate or the CA certificate that signed it. If that is your actual problem, you should ask about that, not what the difference is between driver versions, because that seems to be an X-Y problem. – Mark Rotteveel Jun 04 '22 at 07:58

0 Answers0