The most probable cause of connection failure is explained in the 3rd comment (by Jura Gorohovsky) on the question and is actually covered in the OP. To repeat, the details are here.
My problem was different and caused by confusion about (localdb). But before that, as this is the first actual answer, I will summarise the steps in the Jetbrains post, referred to by Jura and address the most common issue.
SQL Server (SQLEXPRESS) requires TCP/IP to be enabled for access by Rider (and presumably other Jetbrains products such as Intellij and, in fact any process using JDBC). The following steps are required:
Configuring SQL Server for Rider connections:
- Open SQL Server Configuration Manager for the approrpiate version -
cmd.exe /c start C:\Windows\SysWOW64\SQLServerManager14.msc
- SS2017, SQLServerManager13.msc - SS2016, SQLServerManager12.msc - SS2014. The snap-ins are also found in System32.
- The detail panel for SQL Server Services should show SQL Server (SQLEXPRESS).
- for SQL Server Network Configuration->Protocols for SQLEXPrESS ensure that the detail panel shows the line TCP/IP as Enabled.
- In TCP/IP->Properties->IP Addresses (right click TCP/IP). Set IPAll->TCP Dynamic Ports to blank and IPAll->TCP Port to 1433 (or other if you have changed the SS config).
- Confirm all and restart SQL Server (SQLEXPRESS) (right click on SQL Server Services->SQL Server (SQLEXPrESS)) and you should be able to connect with the url
jdbc:jtds:sqlserver://localhost;instance=SQLEXPRESS
. You can also use the Tds driver.
I assme there is nothing special about SQLEXPRESS and any SS instance you have created can be opened up in the same way.
Note that you may encounter problems if you use a port other than the default of 1433. (I can't currently find the docs.) If you specify the port number in the Rider connection page then the instance will be ignored and connection will be made to the default instance. The instance that you connect to from Rider must be either set as the default or have a port number of 1433.
My problem:
I enabled TCP/IP early on but ran into the problem that I could only connect to some sort of default instance which I know nothing about. This was caused by my failing to distinguish sufficiently between (localdb) and SQL Server proper, not being sure whether SQLEXPRESS was a separate product or an instance of SS and being unfamiliar with the SS Configuration snap-in. This will also present itself to the unwary as simply being unable to connect - if you don't happen to have SQLEXPRESS or other SS installed.
This InfoQ article summarises the role of (localdb). It's a kind of light weight version of SQL server but with none of its process admin and not using the same discoverability or transport. It will not show up in the SS Configuration snap-in.
Once you have taken on board the distinction between (localdb)/SQLLocalDB.exe and the other flavours of SS such as SQLEXPRESS the connection from Rider is quite simple and covered here.
Connectiong Rider to (localdb) - summary of post referred to above:
- Run
SQLLocalDB -s MSSQLLocalDB
- In Rider right hand panel do Database->+->Data Source->SQL Server.
- Select Driver as SQL Server (Tds)
- Select LocalDB from the dropdown to the right of the URL.
- Select MSSQLLocalDB (or other available instance) from the Instance drop down.
- Optionally specify a database in the text box.
- Provide credentials if not using pass through authentication
- Do Test Connection etc.
The transport is a named pipe. The other end is provided by the SQLLocalDB.exe process. If Rider remains unconnected for more than a few minutes then SQLLocalDB.exe will exit and you will need to rerun it next time you use Rider. This can be addressed with this solution.
Tested with Rider 2018.2.3.