Issue in connecting to SQL Server via liquibase

I am trying to connect to Liquibase to MSSQL Server On-prem. I have all the dependencies installed, facing below error. Please help:

liquibase --driver=com.microsoft.sqlserver.jdbc.SQLServerDriver --classpath=“D:\Renuka\Microsoft JDBC Driver 6.0 for SQL Server\sqljdbc_6.0\enu\jre8\sqljdbc42.jar” --url=“jdbc:sqlserver://localhost:1433;databaseName=test;integratedSecurity=false;” --changeLogFile=“D:\Renuka\test.sql” --username=liquibase --password=xxxxxx update

What error are you getting?

Unexpected error running Liquibase: Connection could not be created to jdbc:sqlserver://localhost:1433;databaseName=test;integratedSecurity=false; with driver com.microsoft.sqlserver.jdbc.SQLServerDriver. The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: “PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target”. ClientConnectionId:6c1ec0cc-b5ff-4e56-b1fb-ce77390d4fe6

I’m not really familiar withsql-server, but that doesn’t look like a Liquibase specific error, just a sql-server connection issue, missing a cert for connecting. You should make sure you can connect to the sql-server outside of Liquibase before trying to use Liquibase.

Try removing integratedSecurity=false and adding encrypt=false to test connectivity.

1 Like

Hi @Renuka - Welcome to the Liquibase Community!

I did some searching and was able to find an article on the Atlassian website that referenced a similar error. This is the fix they suggested:

If -Djavax.net.ssl.trustStore is present in your JVM arguments, Java will use the truststore configured instead of the default (cacerts). You can verify whether the -Djavax.net.ssl.trustStore parameter is causing problems by running the SSLPoke test using the same JVM argument which will execute SSLPoke using your custom truststore. For example:

$JAVA_HOME/bin/java -Djavax.net.ssl.trustStore=/my/custom/truststore -Djavax.net.debug=ssl SSLPoke jira.example.com 443

Here’s the reference link: Unable to connect to SSL services due to "PKIX Path Building Failed" error | Atlassian Support | Atlassian Documentation

Hey Daryl,

Thanks much. It worked after adding changelog file path to the search path.

Thank you. It worked by adding encrypt=false

1 Like