Network Design

This is me… trying to access PostgreSQL Database Server, but it doesn’t have public IP

Maybe it’s sound common, but actually my goal is to create Java Program to access PostgreSQL Server that located behind some Site server. This PostgreSQL Server, doesn’t have public IP.. so it can’t accessed from the internet. Just take a look at the network design above.

I’ve heard about JSch ( few years ago, and we can simply read the example and demonstration of its functionality here: And if we only want to access the Database via SSH, we can simply use this example on stackoverflow:

But, my network design a little bit different. I was thinking about this problem several hours… until someone gave me some advised in Java Group discussion on Facebook: create a tunnel then connect to the db through that tunnel. Eureka!

This is my code snippet.

View full article »