RubyMine 2023.2 Help

Connect to MS SQL server

Prerequisites

This topic gives you an example of how you can configure Microsoft SQL Server and create a connection to it from RubyMine. If you already have Microsoft SQL Server installed and configured, consider jumping to the section that describes a creation of a database connection in RubyMine.

Step 1. Configure the SQL Server Configuration Manager

To open SQL Server Configuration Manager, open the Search dialog on Windows and type SQLServerManager15.msc (for Microsoft SQL Server 2019). Double-click the found result.

If you use other versions of Microsoft SQL Server, change the second digit before .msc or check the following locations:

  • SQL Server 2019: C:\Windows\SysWOW64\SQLServerManager15.msc

  • SQL Server 2017: C:\Windows\SysWOW64\SQLServerManager14.msc

  • SQL Server 2016: C:\Windows\SysWOW64\SQLServerManager13.msc

  • SQL Server 2014 (12.x): C:\Windows\SysWOW64\SQLServerManager12.msc

  • SQL Server 2012 (11.x): C:\Windows\SysWOW64\SQLServerManager11.msc

Open the SQL Server Configuration Manager

Run the SQL Server Browser

SQL Server Browser listens for incoming requests and provides information about Microsoft SQL Server instances on the computer. For more information about SQL Server Browser, see SQL Server Browser in the Microsoft documentation.

If the SQL Server Browser menu items are disabled, try to enable the SQL Server Agent service.

  1. In the SQL Server Configuration Manager, click SQL Server Services.

  2. In the right pane that lists server services, right-click SQL Server Browser and select Start.

    Run the SQL Server Browser

Enable SQL Server Agent

SQL Server Agent is a Microsoft Windows service that executes scheduled administrative tasks. For more information about the service, see SQL Server Agent in the official Microsoft documentation. Ensure that SQL Server Agent is running and starts automatically. After the change, a restart might be required.

  1. Navigate to Control Panel | Administrative Tools | Services.

  2. In the Services window, right-click SQL Server Agent(<server_name>) and select Properties. For this tutorial, <server_name> is MSSQLSERVER.

  3. From the Startup type list, select Automatic and click Start.

    Enable SQL Server Agent

Enable the TCP/IP connection

  1. In the SQL Server Configuration Manager, expand SQL Server Network Configuration and click Protocols for MSSQLSERVER, where MSSQLSERVER is a name of the Microsoft SQL Server instance.

  2. In the list of protocol names, right-click TCP/IP and select Properties.

  3. On the Protocol tab, from the Enabled list, select Yes.

  4. On the IP Addresses tab, find the interface that your workstation uses and see the connection port. By default, the port is 1433. Verify that other running applications do not use the same port.

    Enable the TCP/IP connection

Step 2. Configure SQL Server Management Studio (SSMS)

Create a user

  1. In the SQL Server Management Studio (SSMS), navigate to Security | Logins.

  2. Right-click the Logins root folder and select New Login.

  3. On the General page, specify a login name in the Login name field.

  4. Select authentication mode. You can select between the following authentication modes:

    • Windows authentication: to use your domain login and password.

    • SQL Server authentication: to use a custom login and password. If you select Enforce password security policy checkbox, the user must change the assigned password before connecting to Microsoft SQL Server with RubyMine. Otherwise, clear the Enforce password security policy checkbox.

  5. Click OK.

    Create a user

Configure user roles

  1. Right-click the created user profile and select Properties.

  2. On the Server Roles page, select the appropriate user role (for example, sysadmin).

    Configure user roles

Step 3. Connect to Microsoft SQL Server with RubyMine

The following section describes configuration of RubyMine on Windows, macOS, and Linux. Note that the Use Windows domain authentication checkbox is available only on Windows. To configure Windows domain authentication on macOS and Linux, see Connect by using Windows domain authentication.

Windows

Connect by using SQL Server authentication

  1. In the Database tool window ( View | Tool Windows | Database), click the Data Source Properties icon The Data Source Properties icon. Alternatively, press Command I.

  2. In the Data Sources and Drivers dialog, click the Add icon (The Add icon) and select Microsoft SQL Server.

  3. Click the Driver link and select Microsoft SQL Server (jTds).

  4. Check if there is a Download missing driver files link at the bottom of the connection settings area. Click this link to download drivers that are required to interact with a database. For a direct download link, refer to the JetBrains JDBC drivers page.

    You can find the downloaded JDBC drivers in the RubyMine configuration directory.

    The IDE does not include bundled drivers in order to have a smaller size of the installation package and to keep driver versions up-to-date for each IDE version.

    The Download missing driver files link

    You can also use your drivers for the database instead of the provided ones. For more information about connecting to a database with your driver, see Add a user driver to an existing connection.

    If there is no Download missing driver files link, then you already have the required drivers.

  5. In Host, Instance, and Port fields, specify your connection details. If the server name (in our case, DESKTOP) does not work, replace it with the server IP address.

  6. From the Authentication list, select User & Password.

  7. In User and Password fields, specify your credentials.

  8. Ensure that the connection to the database can be established using the provided details. To do that, click the Test Connection link at the bottom of the connection details area.

    Test Connection link

    In case of any connection issues, refer to the Cannot connect to a database page.

  9. (Optional) By default, only the default database and schema are introspected and available to work with. If you also want to work with other databases and schemas, in the Schemas tab, select them for the introspection.

    Schemas tab of the Data Sources and Drivers dialog
  10. Click OK to create the data source.

  11. Find your new data source in the Database tool window (Alt+1) .

    • To learn more about the Database tool window, see the corresponding reference topic.

    • To learn how to work with database objects in RubyMine, see Database objects.

    • To write and run queries, open the default query console by clicking the data source and pressing F4.

    • To view and edit data of a database object, open Data Editor and Viewer by double-clicking the object.

Connect by using SQL Server authentication

Connect by using single sign-on for Microsoft SQL Server

If you run RubyMine on Windows in the same domain as the Microsoft SQL Server database, you can use the Single-Sign On (SSO).

  1. In the Database tool window ( View | Tool Windows | Database), click the Data Source Properties icon The Data Source Properties icon. Alternatively, press Command I.

  2. In the Data Sources and Drivers dialog, click the Add icon (The Add icon) and select Microsoft SQL Server.

  3. Click the Driver link and select Microsoft SQL Server (jTds).

  4. Check if there is a Download missing driver files link at the bottom of the connection settings area. Click this link to download drivers that are required to interact with a database. For a direct download link, refer to the JetBrains JDBC drivers page.

    You can find the downloaded JDBC drivers in the RubyMine configuration directory.

    The IDE does not include bundled drivers in order to have a smaller size of the installation package and to keep driver versions up-to-date for each IDE version.

    The Download missing driver files link

    You can also use your drivers for the database instead of the provided ones. For more information about connecting to a database with your driver, see Add a user driver to an existing connection.

    If there is no Download missing driver files link, then you already have the required drivers.

  5. In Host, Instance, and Port fields, specify your connection details. If the server name (in our case, DESKTOP) does not work, replace it with the server IP address.

  6. From the Authentication list, select Windows credentials.

  7. Ensure that the connection to the database can be established using the provided details. To do that, click the Test Connection link at the bottom of the connection details area.

    Test Connection link

    In case of any connection issues, refer to the Cannot connect to a database page.

  8. (Optional) By default, only the default database and schema are introspected and available to work with. If you also want to work with other databases and schemas, in the Schemas tab, select them for the introspection.

    Schemas tab of the Data Sources and Drivers dialog
  9. Click OK to create the data source.

  10. Find your new data source in the Database tool window (Alt+1) .

    • To learn more about the Database tool window, see the corresponding reference topic.

    • To learn how to work with database objects in RubyMine, see Database objects.

    • To write and run queries, open the default query console by clicking the data source and pressing F4.

    • To view and edit data of a database object, open Data Editor and Viewer by double-clicking the object.

Connect by using SQL Server authentication

Connect by using Windows domain authentication

  1. In the Database tool window ( View | Tool Windows | Database), click the Data Source Properties icon The Data Source Properties icon. Alternatively, press Command I.

  2. In the Data Sources and Drivers dialog, click the Add icon (The Add icon) and select Microsoft SQL Server.

  3. Click the Driver link and select Microsoft SQL Server (jTds).

  4. Check if there is a Download missing driver files link at the bottom of the connection settings area. Click this link to download drivers that are required to interact with a database. For a direct download link, refer to the JetBrains JDBC drivers page.

    You can find the downloaded JDBC drivers in the RubyMine configuration directory.

    The IDE does not include bundled drivers in order to have a smaller size of the installation package and to keep driver versions up-to-date for each IDE version.

    The Download missing driver files link

    You can also use your drivers for the database instead of the provided ones. For more information about connecting to a database with your driver, see Add a user driver to an existing connection.

    If there is no Download missing driver files link, then you already have the required drivers.

  5. In Host, Instance, and Port fields, specify your connection details. If the server name (in our case, DESKTOP) does not work, replace it with the server IP address.

  6. From the Authentication list, select Domain credentials.

  7. In the Domain field, specify the domain (for example, DEVELOPMENT).

  8. In User and Password fields, specify your domain credentials. In the User field, type your domain user without the domain prefix (for example, John.Smith instead of DOMAIN\John.Smith).

    Alternatively, on the General tab, specify the connection string. Consider the following example of a full connection string:

    jdbc:jtds:sqlserver://DESKTOP:1433;domain=DEVELOPMENT;instance=MSSQLSERVER;databaseName=guest;
  9. Ensure that the connection to the database can be established using the provided details. To do that, click the Test Connection link at the bottom of the connection details area.

    Test Connection link

    In case of any connection issues, refer to the Cannot connect to a database page.

  10. (Optional) By default, only the default database and schema are introspected and available to work with. If you also want to work with other databases and schemas, in the Schemas tab, select them for the introspection.

    Schemas tab of the Data Sources and Drivers dialog
  11. Click OK to create the data source.

  12. Find your new data source in the Database tool window (Alt+1) .

    • To learn more about the Database tool window, see the corresponding reference topic.

    • To learn how to work with database objects in RubyMine, see Database objects.

    • To write and run queries, open the default query console by clicking the data source and pressing F4.

    • To view and edit data of a database object, open Data Editor and Viewer by double-clicking the object.

Connect by using SQL Server authentication

macOS and Linux

Connect by using SQL Server authentication

  1. In the Database tool window ( View | Tool Windows | Database), click the Data Source Properties icon The Data Source Properties icon. Alternatively, press Command I.

  2. In the Data Sources and Drivers dialog, click the Add icon (The Add icon) and select Microsoft SQL Server.

  3. Click the Driver link and select Microsoft SQL Server (jTds).

  4. Check if there is a Download missing driver files link at the bottom of the connection settings area. Click this link to download drivers that are required to interact with a database. For a direct download link, refer to the JetBrains JDBC drivers page.

    You can find the downloaded JDBC drivers in the RubyMine configuration directory.

    The IDE does not include bundled drivers in order to have a smaller size of the installation package and to keep driver versions up-to-date for each IDE version.

    The Download missing driver files link

    You can also use your drivers for the database instead of the provided ones. For more information about connecting to a database with your driver, see Add a user driver to an existing connection.

    If there is no Download missing driver files link, then you already have the required drivers.

  5. In Host, Instance, and Port fields, specify your connection details. If the server name (in our case, DESKTOP) does not work, replace it with the server IP address.

  6. From the Authentication list, select User & Password.

  7. In User and Password fields, specify your credentials.

  8. Ensure that the connection to the database can be established using the provided details. To do that, click the Test Connection link at the bottom of the connection details area.

    Test Connection link

    In case of any connection issues, refer to the Cannot connect to a database page.

  9. (Optional) By default, only the default database and schema are project and dataset are database is schema is keyspace is namespace is introspected and available to work with. If you also want to work with other databases and schemas projects and datasets databases, schemas, and shared databases databases schemas keyspaces namespaces, in the Schemas tab, select them for the introspection.

    Schemas tab of the Data Sources and Drivers dialog
  10. Click OK to create the data source.

  11. Find your new data source in the Database tool window (Alt+1) .

    • To learn more about the Database tool window, see the corresponding reference topic.

    • To learn how to work with database objects in RubyMine, see Database objects.

    • To write and run queries, open the default query console by clicking the data source and pressing F4.

    • To view and edit data of a database object, open Data Editor and Viewer by double-clicking the object.

Connect by using SQL Server authentication

Connect by using Windows domain authentication

  1. In the Database tool window ( View | Tool Windows | Database), click the Data Source Properties icon The Data Source Properties icon. Alternatively, press Command I.

  2. In the Data Sources and Drivers dialog, click the Add icon (The Add icon) and select Microsoft SQL Server.

  3. Click the Driver link and select Microsoft SQL Server (jTds).

  4. Check if there is a Download missing driver files link at the bottom of the connection settings area. Click this link to download drivers that are required to interact with a database. For a direct download link, refer to the JetBrains JDBC drivers page.

    You can find the downloaded JDBC drivers in the RubyMine configuration directory.

    The IDE does not include bundled drivers in order to have a smaller size of the installation package and to keep driver versions up-to-date for each IDE version.

    The Download missing driver files link

    You can also use your drivers for the database instead of the provided ones. For more information about connecting to a database with your driver, see Add a user driver to an existing connection.

    If there is no Download missing driver files link, then you already have the required drivers.

  5. In Host, Instance, and Port fields, specify your connection details. If the server name (in our case, DESKTOP) does not work, replace it with the server IP address.

  6. From the Authentication list, select Domain credentials.

  7. In the Domain field, specify the domain (for example, DEVELOPMENT).

  8. In User and Password fields, specify your domain credentials. In the User field, type your domain user without the domain prefix (for example, John.Smith instead of DOMAIN\John.Smith).

    Alternatively, on the General tab, specify the connection string. Consider the following example of a full connection string:

    jdbc:jtds:sqlserver://DESKTOP:1433;domain=DEVELOPMENT;instance=MSSQLSERVER;databaseName=guest;
  9. Ensure that the connection to the database can be established using the provided details. To do that, click the Test Connection link at the bottom of the connection details area.

    Test Connection link

    In case of any connection issues, refer to the Cannot connect to a database page.

  10. (Optional) By default, only the default database and schema are project and dataset are database is schema is keyspace is namespace is introspected and available to work with. If you also want to work with other databases and schemas projects and datasets databases, schemas, and shared databases databases schemas keyspaces namespaces, in the Schemas tab, select them for the introspection.

    Schemas tab of the Data Sources and Drivers dialog
  11. Click OK to create the data source.

  12. Find your new data source in the Database tool window (Alt+1) .

    • To learn more about the Database tool window, see the corresponding reference topic.

    • To learn how to work with database objects in RubyMine, see Database objects.

    • To write and run queries, open the default query console by clicking the data source and pressing F4.

    • To view and edit data of a database object, open Data Editor and Viewer by double-clicking the object.

Connect by using SQL Server authentication
Last modified: 31 July 2023