Search code examples
sql-server-2012connection-stringflyway

What is the correct syntax for a Flyway connection string to SQL Server?


Running SQL Server 2012 Express on a remote machine, trying to get Flyway up and running. I have a database on pcesqldev.pce.local called Hawk (dbo.Hawk, if that matters) that I want to connect to, and the template from the config file looks like this:

SQL Server        : jdbc:jtds:sqlserver://<host>:<port>/<database>

Note, this is different from other jdbc connection strings I have used with other products - most of them do not include the jtds portion and do include the instance name.

Here's a few connection strings that I have tried, all of which failed:

  • flyway.url=jdbc:jtds:sqlserver://pcesqldev.pce.local:1433/Hawk
    

    Network error IOException: Connection refused: connect

  • flyway.url=jdbc:jtds:sqlserver://pcesqldev.pce.local\SQLEXPRESS:1433/Hawk
    

    Unknown server host name 'pcesqldev.pce.local\SQLEXPRESS'

  • flyway.url=jdbc:jtds:sqlserver://pcesqldev.pce.local/SQLEXPRESS:1433/Hawk
    

    Network error IOException: Connection refused: connect

  • flyway.url=jdbc:jtds:sqlserver://pcesqldev.pce.local:1433/SQLEXPRESS\Hawk
    

    Network error IOException: Connection refused: connect

What am I missing? There must be something obvious, but I can't see it.

Before anybody asks, yes we do have TCP access to the database enabled and it is using port 1433.


Solution

  • This one got me, and there was not many answers out there on how to format a connection string with an instance name.

    Here's what worked for me:

    flyway.url=jdbc:jtds:sqlserver://<host>:<port>/<database>;instance=<instance_name>