Other
Enable the Database Tools and SQL plugin
This functionality relies on the Database Tools and SQL plugin, which is bundled and enabled in RubyMine by default. If the relevant features aren't available, make sure that you didn't disable the plugin.
Press Ctrl+Alt+S to open the IDE settings and then select
.Open the Installed tab, find the Database Tools and SQL plugin, and select the checkbox next to the plugin name.
To create a data source, you need a JDBC driver. There are two types of drivers in RubyMine: with Complete Support and with Basic Support. You can see a list of database vendors with complete and basic support on the Drivers tab in the Data Sources and Drivers dialog. Also, note that user-created drivers are considered as drivers with basic support.
Complete Support includes such features as enhanced code completion and better retrieval of database objects (introspection). For example, with complete support, you will see the following objects in the corresponding databases: user-defined types in Apache Cassandra, macros in Apache Hive, extensions in PostgreSQL. Also, all inspections, quick-fixes, and other coding assistance features are available for databases with the complete support.
Basic Support has code highlighting and displays objects that were retrieved by the JDBC driver. RubyMine uses JDBC metadata for database introspection and the SQL 2016 dialect for code highlighting. No errors are detected and highlighted.
The introspection with JDBC metadata means that some specific database objects will not appear in the database tree view. Code completion will not include objects that were not retrieved during introspection.
Creating data sources from drivers with basic support
There are two ways to create data sources from drivers with basic support.
Using the Other submenu
Using user driver files
Using the Other submenu
Open data source properties. You can open data source properties by using one of the following options:
In the Database tool window ( ) , click the Data Source Properties icon .
Press Shift+Enter.
In the Data Sources and Drivers dialog, you can use Data Sources and Drivers tabs to create a data source.
Data Sources: click the Add icon () and navigate to Other. In this submenu, select the driver that you want to use for the data source creation.
Drivers: click the Drivers tab and select the necessary driver. In the settings of this driver, click Create Data Source.
Specify the database connection details. Alternatively, paste the JDBC URL in the URL field.
To delete a password, right-click the Password field and select Set Empty.
For the reference information about connection settings (for example, Host, Port, and so on) on the General and other tabs of Data Sources and Drivers dialog (Shift+Enter) , see Data source settings.
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.
Location for the downloaded JDBC drivers is the RubyMine configuration directory.
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, refer to Add a user driver to an existing connection.
If there is no Download missing driver files link, then you already have the required drivers.
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.
In case of any connection issues, refer to the Cannot connect to a database page.
Click OK to create the data source.
Using user driver files
Open data source properties. You can open data source properties by using one of the following options:
In the Database tool window ( ) , click the Data Source Properties icon .
Press Shift+Enter.
In the Data Sources and Drivers dialog, ensure that you are on the Drivers tab.
In the Data Sources and Drivers dialog, click the Add icon ().
In the Name field, type the name of the driver.
In the Driver Files pane, click the Add icon () and select Custom JARs.
Navigate to the JAR file of the JDBC driver, select it, and click OK.
In the Class field, specify the value that you want to use for the driver.
Click Apply.
To create a data source from the driver's dialog, click Create Data Source.
Library paths for user drivers
To work properly, some JDBC drivers require a path to library files along with the driver.
For example, to determine if the application should operate in the Instant Client mode, Oracle Instant Client (OCI) applications look for library files in the runtime library search path (LD_LIBRARY_PATH
on Linux or PATH
on Windows). You can set these paths in the Data Sources and Drivers dialog.
Adding library paths
Open data source properties. You can open data source properties by using one of the following options:
In the Database tool window ( ) , click the Data Source Properties icon .
Press Shift+Enter.
In the Data Sources and Drivers dialog, click the driver entry to which you want to add a path to library files.
(Optional) Add a driver for which you want to add library files. If the existing driver does not meet the requirements, replace the existing driver. To delete the existing driver entry, select the driver and click Remove. For more information about adding a driver, refer to create a connection to a database with a JDBC driver.
In the Driver files pane, click the Add icon () and select Native Library Path.
Navigate to the folder with library files. Ensure that the driver version corresponds to the version of these library files. For example, if you use the driver version 19.6, the attached library files must also have the 19.6 version.
Productivity tips
Create a data source from the JDBC URL
To connect to the database, create a data source that will store your connection details. You can do this using one of the following ways:
In the main menu, go to
.In the Database tool window ( ) , click the New icon () in the toolbar. Navigate to Data Source from URL.
In the URL field, paste the JDBC URL.
From the Driver list, select the necessary driver for the data source.
In the Data Sources and Drivers dialog, enter credentials.
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.
In case of any connection issues, refer to the Cannot connect to a database page.
Click OK to create the data source.
Find your new data source in the Database tool window (⌘ 1) .
For more information about the Database tool window, see the corresponding reference topic.
For more information about working with database objects in RubyMine, refer to 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.