How to connect to MS SQL Server Express in JetBrains DataGrip?

Yuriy picture Yuriy · Mar 19, 2016 · Viewed 14.2k times · Source

I'm trying to set up new tool from JetBrains: DataGrip to work with my local install of MS SQL Server 2014 Express. I spent some time trying to "convert" ms connection string to jdbc, but no luck. I can connect using MS SQL Server 2014 management Studio.

So here is my connection string:

"Data Source=MyPCName\MySQLInstanceName;Initial Catalog=MyDataBaseNameA3D;Integrated Security=True;"

My best guess was based on msdn example:

jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]

MSDN: Connecting to SQL Server with the JDBC Driver. Building the Connection URL

jdbc:sqlserver://MyPCName\MySQLInstanceName:1433;databaseName=MyDataBaseNameA3D;integratedSecurity=true;

Has anyone resolved such issue and maybe can walk me through setup steps?

Otherwise I'm just going to drop this tool. I've wasted enough time on something that should be very simplistic.

Answer

Andrey picture Andrey · Mar 28, 2016

DataGrip has pre-defined jdbc url templates for each jdbc driver. For MS SQL Server it has two drivers:

  • SQL Server (Microsoft driver) with the template url connection string: jdbc:sqlserver://host:port;databaseName=<your db name>

  • SQL Server (jTDS driver) with the template url connection string: jdbc:jtds:sqlserver://host:port/<your db name>

The name of the database is optional in both cases. These url template are also filled automatically if you set corresponding connection parameters. Since DataGrip 2016 completion is also possible when filling the connection settings: DB connection setting

Could be that your url is correct but you are getting tcp connection errors. In such case please make sure that if you are connecting via TCP port, SQL Server is configured to accept remote connections on the specified ip address and listens for tcp connections on the specified port number (or see SQL Server documentation).

If you are connecting via named instance, please make sure to specify instance name in the connection settings and omit specifying the port (if it is an "express" version of Sql Server, the instance name could be SQLEXPRESS).

UPD: see also Connecting DataGrip to MS SQL Server tutorial on DataGrip blog.