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

Running SQL Server 2012 Express on a remote computer, trying to start Flyway. 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 configuration file looks like this:

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

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

Here are some connection strings I tried, all of which failed:

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

    IOException network error: connection rejected: 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 

    IOException network error: connection rejected: connect

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

    IOException network error: connection rejected: connect

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

Before anyone asks, yes, we have TCP access to the database and it uses port 1433.

+6
source share
3 answers

This bothered me, and there weren't many answers on how to format the connection string with the instance name.

Here is what worked for me:

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

In case of any problems, the correct connection string is as follows:

 flyway.url=jdbc:jtds:sqlserver://SERVER_INSTANCE_NAME:1433/DB_NAME 

It took me a while to figure this out, but maybe it will be useful for someone :)

+2
source

It helped me a bit.

The connection string I used was (passed as parameters for the span on the command line).

Note also that the name mydatabasename must already exist.

 ./flyway migrate -url=jdbc:jtds:sqlserver://localhost:1433/mydatabasename -user=myuser -password=mypassword -baselineVersion=269 -baselineDescription="Base version" -outOfOrder=true -baselineOnMigrate= 

Some part was missing, because I did not start the SQL Server browser and may not have configured TCP correctly:

See the SQL Server section here . After installation is complete, enable TCP / IP:

Launch Sql Server Configuration Manager Go to SQL Server Network Configuration → Protocols for SQLEXPRESS Enable TCP / IP TCP / IP Properties → IP Addresses → IPAll Dynamic TCP Ports: Empty TCP Port: 1433 Then enable remote access:

Launch Sql Server Configuration Manager SQL Server Services → SQL Server Browser → Properties → Service Tab Startup Mode: Automatic OK SQL Server Browser → SQL Server Start → Reboot

0
source

Source: https://habr.com/ru/post/989830/


All Articles