How to connect to PostgreSQL using JAVA JDBC

In this video I have shown how you can connect to PostgreSQL using JAVA JDBC.
This example is shown in eclipse IDE.
You should download the jar file from official postgresql site.
The jar file shown in this video is postgresql-42.2.9.jar.
You can download it here. postgresql-42.2.9

1. Project Structure.

2. ConnectDB.java
Please update the host,port,dbname,username and password according to your db details.

3. Before running the code, Please the jar file in the build path.

4.After running the program in Eclipse IDE, The console will show the message the DB Connection is ok.