Hello Friends, Here is the article to give simple code to connecting PostgreSQL Database with Java Application.Here i am using eclipse IDE. i am connecting java with PostgreSQL database using JDBC driver. Let’s see all important steps.
1.First Download jdbc driver. write in google search box “jdbc driver for PostgreSQL”. Download suitable driver and extract.
2.Open your favorite IDE, i am using eclipse.right click on project.scroll down to Properties.click “Add External JARs”.select the jar file that you downloaded.
3.Write below codes.

4.the above code explanation. server name “localhost”,port number “5432”,Database “postgres” user name “postgres” password “sam1234”. countries “Table Name”. country_id and
country_name are columns. In the codes i am using try and catch. if any exception occurs then it catch by catch block.
Happy Coding…Thanks.