How to SSH tunnel and connect to a database using IntelliJ and JDBC?

Here's my setup via intellij if anyone is looking for simple solution without external libraries.

  1. Open Database view (View -> Tool Windows -> Database).
  2. Add new DataSource (right-click, New -> Data Source -> Postgres/Mysql). In host, use 127.0.0.1 (not localhost, sometimes localhost is not properly resolved).
  3. Fill in rest of the fields as configured on your remote host.

enter image description here

Now click on SSH/SSL tab and configure ssl tunnel:

enter image description here


Do you connect to SSH server from a java client like SSHJ (https://github.com/hierynomus/sshj) ?

The URL on your DriverManager seems wrong: try port 11100 instead.