SQL Server: Unable to connect

Hello,

Total newbie here. I’m going through the Liquibase University and thought I’d try it with a SQL Server, which is what we’re going to be using. But I’m unable to connect to my mssql instance at all.
This is my liquibase.properties file

changeLogFile=myChangelog.xml
driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
url="jdbc:sqlserver://localhost:4293;DatabaseName=wmLiquibaseTutorial;"
username=testLogin 
password=testPassword 

I have confirmed that I can connect using sqlcmd from the same powershell terminal using the same information. I looked at the “Using Liquibase with MSSQL” topic in the Docs and tried this to help debug, and it gets the same error.

liquibase --username=testLogin --password=testPassword --changelog-file=changelog.xml status

Liquibase Version: 4.17.0
Liquibase Community 4.17.0 by Liquibase

Unexpected error running Liquibase: Connection could not be created to "jdbc:sqlserver://localhost:4293;databaseName=wmLiquibaseTutorial;" with driver com.microsoft.sqlserver.jdbc.SQLServerDriver.  Possibly the wrong driver for the given database URL

Platform is Windows
SQL Server is MSSQL 2019 Dev Edition
java -version
java version “1.8.0_261”
Java™ SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot™ 64-Bit Server VM (build 25.261-b12, mixed mode)

edited to add: I also tried downloading the newest JDBC driver from Microsoft and using that, but it didn’t help

Thanks in advance

Hi @wmenton , welcome to Liquibase!

Quick question: is 4293 really the SQL Server service port (number)?
The default one would usually be 1433.

Thanks,
Eduard

Thanks for the welcome. It is the port. We’re not allowed to use default port numbers

1 Like

As a test, I reset the port to the default 1433 and it still fails to connect

1 Like

It looks like this might be caused by the double quotes surrounding the driver URL. Try removing the quotes and see if it works. Please let us know!

Reference:

1 Like

Thanks - that was part of the problem.

1 Like

The remaining issues were resolved by adding
trustServerCertificate=true
to my connection string

1 Like