Setting up Liquibase with MS-SQL Server

孤街醉人 提交于 2019-12-04 09:24:22

问题


I am utilising Liquibase (www.liquibase.org) into our MVC3 SQL Server 2008 project to manage database migration/changes. However I'm stumbling on the first hurdle: Connecting to Microsoft SQL Server instance.

I am looking at the quick start tutorial on the liquibase site, but exchanging the mysql for sql server DB

I run this command:

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

And receive this error:

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

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

How can I create or update an MS-SQL Server database with liquibase?


回答1:


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 when located in the same directory. Useful to simplify the command-line.

Database is updated as follows:

liquibase update

Notes:

  • I'm not a SQL server user, I picked up the JDBC driver and URL details from Microsoft doco
  • The "migrate" command has been deprecated.


来源:https://stackoverflow.com/questions/8990467/setting-up-liquibase-with-ms-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!