IntelliJ IDEA tip: How to connect to a Database using Database Navigator

IntelliJ IDEA is a powerful development environment. In today’s tip we will learn how to install the Database Navigator plugin that adds database capabilities to your development environment.

Let’s start from the plugin installation. In order to do that, select the Settings | Plugin Panel and search for the “database navigator” in the MarketPlace text search:

h2 database tutorial h2 database tutorial

Click on Install. Then restart your IDE. We will now show how to configure the Database Navigator to connect to a PostgreSQL Database,

In order to check database connectivity, we will start PostgreSQL using Docker as follows:

docker run --name quarkus_test -e POSTGRES_USER=demo -e POSTGRES_PASSWORD=demo -e POSTGRES_DB=sampledb -p 5432:5432 postgres:10.5

So, as the IP Address and Ports will be forwarded on localhost, you can add a new Connection by selecting the DB Navigator from the upper Menu and choosing the target Database. The list of supported Databases include:

  • Oracle
  • MySQL
  • SQLite
  • PostgreSQL
  • Any JDBC compliant database (EXPERIMENTAL)

Then, click on the “+” button to add a new Connection:

intellij idea Database Navigator

After you have entered the JDBC Connection details, you can Verify the connection and click on OK. The Connection and Schema will be displayed in the left panel of IntelliJ IDEA:

intellij idea Database Navigator

From there, you can select the Connection and enter SQL statements:

intellij idea Database Navigator

Two things I link most of Database Navigator

  1. First, it’s just plain and simple to get started with any of the default Databases provided. I didn’t have to add any JDBC Driver or search for the JDBC Connection String for the Driver. Just using the default worked fine and I was about to use it in less than a minute!
  2. Then, Database navigator is not just plain SQL and PL/SQL editing. I was glad to see it provides advanced database connection management, script execution support, database objects browsing, data and code editor, support for database compiler operations, method execution and debugging, database objects factory, as well as various navigation capabilities between all its components. In other words, it’s an awesome SQL Client tool!

By the way, I’ve just updated this tutorial with my experience in using Database navigator with H2 database: H2 database tutorial

Found the article helpful? if so please follow us on Socials