Global and Local Data Sources
IntelliJ IDEA distinguishes between Global and Local data sources.
- Global data sources are available in all projects in your workspace.
- Local data sources are available in one specific project only.
Types of Data Sources
IntelliJ IDEA supports data sources of the following types:
- DB data sources, which correspond to the existing databases the application you are developing will interact with.
- DDL data sources, which represent the necessary data structures and act as stub databases, the databases without any data. For this data source type you should have one or more DDL files (SQL file type) representing the required data structures available in your project directory (or one of its subdirectories). Also note that a particular SQL dialect should be set for all those files (or the directories containing those files).
DB data sources can be both global and local; DDL data sources can be configured only at the project level.
IntelliJ IDEA establishes a database connection between a data source and the corresponding database automatically, the first time it needs to execute a query. A database connection is displayed in the Database tool window as a node below the data source via which it is established, and is marked with the icon.
IntelliJ IDEA closes a connection automatically upon the session termination; alternatively, you can close a database connection manually ( Close Connection in the context menu of a connection (DeleteDelete)).
Access to Data Sources
Access to data sources is supported through a variety of IntelliJ IDEA features and components:
- Support for SQL, which includes syntax and error highlighting, code completion, selection of words and statements, parameter lookup, and refactoring (Introduce constant, for instance).
- The ability to use source files with injected SQL code, with different SQL dialects, configurable at the project, directory, or file level.
- Dedicated Database tool window, where you can configure data sources.
- Dedicated Database, Hibernate, and JPA consoles.
- Configuring DDL data sources based on data structure definition (DDL) files, integration between the data source structure and the corresponding DDL statements in the definition file.
- Generating DDL statements based on the structures of a data source.
- Configuring database management scripts as external tools and running them from within IntelliJ IDEA.
- The ability to download archives and libraries with driver classes right from IntelliJ IDEA.
- Object-relational mapping by means of EJB, Hibernate and JPA.
- Persistence tool window that enables mappings between relational databases and object models.
- Table Editor that provides a graphical interface for viewing and editing database tables.
- Structure view for DDL SQL files available in the Structure tool window ( or Alt+7Command 7) or in the Structure pop-up ( or Ctrl+F12Ctrl+F12).