IntelliJ IDEA 2019.1 Help

Managing data sources

Data source is a location of data for your application.

In IntelliJ IDEA, you can define the following data sources:

Create a data source

Create a DB data source from database files

  1. If database files are in your project folder, open the Project tool window. Otherwise, open your file manager.

  2. Open the Database tool window (View | Tool Windows | Database).

  3. Select the files that you want to use as data sources and drag them to the Database tool window. A separate data source is created for each file.

    Drag a database file

  4. If you do not have the necessary database driver files, download them. Click The Data Source Properties icon on the toolbar of the Database tool window. Alternatively, select Properties from the context menu.

  5. In the Data Sources and Drivers window, click the Download link.

  6. To ensure that the connection to the data source is successful, click Test Connection, and click OK.

Configure data sources from project files

You can use XML files that contain database connection settings (for example, context.xml for Spring, Hibernate, JPA and Tomcat) to create DB data sources.

  1. Open the Database tool window (View | Tool Windows | Database).

  2. Click the Add button on the toolbar and select Import from sources. Alternatively, right-click the area under the toolbar or under existing data sources, select New, and click Import from sources.

    In the Data Sources and Drivers window, you can see names of candidate data sources in the green color.

  3. Download the driver files if they are missing.

    To specify a driver, perform one of the following steps:

    • To download the necessary driver, click the Download link.

    • To specify the driver files that you already have available on your computer, click the <DriverName> link to the right of Driver.

      On the page where the driver settings are shown, under JDBC drivers / Additional, click icons welcome createNewProject svg and select necessary files.

      Return to the page with the data source settings.

  4. To ensure that the connection to the data source is successful, click Test Connection.

  5. Click OK.

Create a DDL data source

  1. Open the Database tool window (View | Tool Windows| Database).

  2. Click the Data Source Properties icon (the Data Source Properties icon) on the toolbar, and select DDL Data Source.

  3. Specify the data source name.

  4. In the DDL Files form, click the Add icon (the Add icon) and select necessary SQL files.

Customizing data sources

Configure data source settings

  1. In the Database tool window (View | Tool Windows | Database), select a data source that you want to change.

  2. Click the Data Source Properties icon (the Data Source Properties) on the toolbar (or press Shift+Enter).

  3. In the Data Sources and Drivers window, edit the data source properties. For more information about data source properties, see Data source settings and DDL data source settings.

Group data sources

If you have a number of different databases, you can group their data sources in the Database tool window (View | Tool Windows | Database). To group data sources, select the necessary data source, press F6, or select Move to Group from the context menu.

The following options are available for data source groups in the Move to Group menu:

  • Create a new group for the data source.

  • Move the data source to the root list. This option removes the data source from a group.

  • Move the data source to an existing group.

Group data sources

Remove data sources

To remove a data source, in the Database tool window (View | Tool Windows | Database), press Delete. Alternatively, you can select Remove from the context menu, or click Edit | Delete.

Also, to remove a data source, you can use the Data Sources and Drivers window (File | Data Sources). In the Data Sources and Drivers window, select the data source and press Delete. Alternatively, you can click the Remove icon on the toolbar, or select Remove from the context menu.

Last modified: 20 June 2019