I'm trying to run a Liquibase update through bash and am running into issues connecting to the database ("The TCP/IP connection to the host MYCOMPUTERNAME/SQL, port 1433 has failed."). The command I'm using is this -
java -jar liquibase.jar --username="USERNAME" --password="PASSWORD" --url=$'jdbc:sqlserver://MYCOMPUTERNAME\SQL;databaseName=DBNAME' update
Note: the values in all caps aren't the real values, but show what I'm trying to do.
I've narrowed the issue down to the connection string - specifically the instance. I'm using sqljdbc4.jar to connect to the database. I have a database with the same name on the default instance and it works when I run this -
java -jar liquibase.jar --username="USERNAME" --password="PASSWORD" --url=$'jdbc:sqlserver://MYCOMPUTERNAME;databaseName=DBNAME' update
I've also ran the first one above from the Windows command line rather than bash and it works (though only with double quotes or no quotes, not single quotes). All this seems to point to a problem with my syntax in bash rather than an actual connection problem. I've tried single quotes, double quotes and escaping the backslash
EDIT: I've debugged the jar and the issue is that the value of the connection string is being read in as -
jdbc:sqlserver://MYCOMPUTERNAME/SQL;databaseName=DBNAME
Somehow the backslash is being switched when this is passed into the main method.
EDIT: I found the issue. I'm using Windows Bash, which is what was trying to alter the path. It looks like it was switching subsequent backslashes any time it found two consecutive forward slashes. I was able to move forward with this command -
MSYS_NO_PATHCONV=1 java -jar liquibase.jar --username="USERNAME" --password="PASSWORD" --url=$'jdbc:sqlserver://MYCOMPUTERNAME\SQL;databaseName=DBNAME' update
I found this solution here -
How to stop mingw and msys from mangling path names given at the command line?
The root cause is all documented here -