0
votes

I'm trying to connect to Microsoft SQL Server 2008 SP3 using Liquibase and Microsoft JDBC Driver 4.1. I get various exceptions and not a single successful way to authenticate into the server via commandline. With the same username and password I was able to login to the database via MS SQL Client. So it is not an issue with login issues with this user. I believe the issue is with the JDBC Driver.

Versions:

1) SQL Server 2008 - SP3

2) Liquibase v3.3.2

3) JDBC Driver - "Microsoft JDBC Driver 4.1 for SQL Server" - http://www.microsoft.com/en-us/download/details.aspx?id=11774

4) JDK Version - 1.7.0_71" [ Java(TM) SE Runtime Environment (build 1.7.0_71-b14), Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode) ]

What i have checked:

1) TCP/ IP is allowed, marked "YES", port 1433

2) MS SQL 2008 SP3 installed to resolve "2976923 2994310 FIX: Distribution Agent for Oracle subscription fails when you use SQL Server 2008 R2 or SQL Server 2008" - http://support.microsoft.com/kb/2653857

3) SQL Serverauthentication and Windows Authentication enabled for the user

Errors and Commandline Inputs:

1 "com.microsoft.sqlserver.jdbc.sqlserverexception login failed for user"

Commandline Input -

a. liquibase --driver=com.microsoft.sqlserver.jdbc.SQLServerDriver --classpath=C:\MicrosoftJDBC\sqljdbc_4.1\enu\sqljdbc4.jar --url="jdbc:sqlserver://DBServer" --username=abcd --password=abcd123 --changeLogFile=db-changelog.xml update

b. liquibase --driver=com.microsoft.sqlserver.jdbc.SQLServerDriver --classpath=C:\MicrosoftJDBC\sqljdbc_4.1\enu\sqljdbc4.jar --url="jdbc:sqlserver://DBServer;databaseName=DBName;" --username=abcd --password=abcd123 --changeLogFile=db-changelog.xml update

c. liquibase --driver=com.microsoft.sqlserver.jdbc.SQLServerDriver --classpath=C:\MicrosoftJDBC\sqljdbc_4.1\enu\sqljdbc4.jar --url="jdbc:sqlserver://DBServer;databaseName=DBName;"; --username=abcd --password=abcd123 --changeLogFile=db-changelog.xml update

2 - Unexpected error running Liquibase: com.microsoft.sqlserver.jdbc.SQLServerException: The port number 1433\DBName is not valid.

Commandline Inputs -

a. liquibase --driver=com.microsoft.sqlserver.jdbc.SQLServerDriver --classpath=sC:\MicrosoftJDBC\sqljdbc_4.1\enu\qljdbc4.jar --url="jdbc:sqlserver://DBServer:1433/DBName" --username=abcd --password=abcd123 --changeLogFile=db-changelog.xml update

b. liquibase --driver=com.microsoft.sqlserver.jdbc.SQLServerDriver --classpath=C:\MicrosoftJDBC\sqljdbc_4.1\enu\sqljdbc4.jar --url="jdbc:sqlserver://DBServer:1433\DBName" --username=abcd --password=abcd123 --changeLogFile=db-changelog.xml update

c.liquibase --driver=com.microsoft.sqlserver.jdbc.SQLServerDriver --classpath=C:\MicrosoftJDBC\sqljdbc_4.1\enu\sqljdbc4.jar --url="jdbc:sqlserver://DBServer\DBName" --username=abcd --password=abcd123 --changeLogFile=db-changelog.xml update

3 Unexpected error running Liquibase: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host DBServer/DBName, port 1433 has failed. Error: "null. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".

Commandline Input -

a. liquibase --driver=com.microsoft.sqlserver.jdbc.SQLServerDriver --classpath=C:\MicrosoftJDBC\sqljdbc_4.1\enu\sqljdbc4.jar --url=jdbc:sqlserver://DBServer/DBName" --username=abcd --password=abcd123 --changeLogFile=db-changelog.xml update

I require resolution via liquibase commandline arguments and not through Java or Maven. I was able to sucessfully authenticate with same user via Java and Maven, but it does not solve my purpose to automate deployments. Please help to resolve this issue. Thanks!

1
The issue is because liquibase.bat file deletes the '!' [an exclamation mark symbol] in the end when it is parsed in the batch file before it is passed to the liquibase.integration.commandline.Main method in the liquibase.jar file. I've raised an issue liquibase.jira.com/browse/CORE-2250Amreth Chandrasehar

1 Answers

3
votes

The issue is because liquibase.bat file deletes the '!' [an exclamation mark symbol] in the end when it is parsed in the batch file before it is passed to the liquibase.integration.commandline.Main method in the liquibase.jar file. I've raised an issue liquibase.jira.com/browse/CORE-2250