Configuring Liquibase with MS-SQL Server

I use Liquibase (www.liquibase.org) in our MVC3 SQL Server 2008 project to manage database migration / changes. However, I come across the first hurdle: connecting to an instance of Microsoft SQL Server.

I am learning a quick start tutorial on the Liquibase site, but am exchanging mysql for SQL Server SQL

I ran this command:

liquibase --driver=sqljdbc.jar --changeLogFile="C:\Temp\ChangeLog.xml" --url="jdbc:sqlserver://localhost;databaseName=test" --username=user --password=pass migrate 

And get this error:

 Liquibase Update Failed: Cannot find database driver: sqljdbc.jar 

I tried adding --classpath pointing to the sqljdbc driver, with no luck.

How to create or update an MS-SQL Server database using Liquibase?

+7
source share
1 answer

Create a properties file called Liquibase.properties containing the following:

 classpath=C:\\Program Files\\Microsoft SQL Server 2005 JDBC Driver\\sqljdbc_1.2\\enu\\sqljdbc.jar driver=com.microsoft.sqlserver.jdbc.SQLServerDriver url=jdbc:sqlserver://localhost:1433;databaseName=test username=myuser password=mypass changeLogFile=C:\\Temp\\ChangeLog.xml 

Liquibase will use this file if it is in the same directory. Useful for simplifying the command line.

The database is updated as follows:

 liquibase update 

Notes:

  • I am not a SQL server user, I took the JDBC driver and URL details from Microsoft doco
  • The migrate command is deprecated.
+16
source

All Articles