java2db

Jdbc with PostgreSQL using MyEclipse and NetBeans



JDBC application programming interface is one of the best and easiest ways to interact with the database. Below explained , Jdbc with PostgreSQL using MyEclipse and NetBeans in a simple and detailed way.

 

Basic requirements to run this application
Softwares MyEclipse or NetBeans IDE (Download MyEclipse , Download NetBeans )
PostgreSQL (Download PostgreSQL)
java (Download java )
Note :Better to use latest versions
Jar Files postgresql_8_2_504_jdbc3.jar
Files .java or .class

 

JDBC is a specification from Sun Microsystems and provides a standard abstraction in the form APIs of protocols for java applications to communicate with different relational databases . Below example , used type-4 driver to connect with the database.

 

JDBC With PostgreSQL Using MyEclipse :

Create New Project :

Go to File , New and select Java Project .

Jdbc with PostgreSQL

 

Enter valid name of the project in the popup window , click Finish button.

Jdbc with PostgreSQL

The new project created in the top-left corner of the MyEclipse IDE .

 

Add Jar Files :

Right click on the project and select Build Path  ,  Configure Build Path sub menu .

Jdbc with PostgreSQL

Click Add External JARs and select the postgresql_8_2_504_jdbc3.jar from the existing location. Click OK

 

Project Directory Structure :

This diagram represents the project directory structure .

 

Jdbc with PostgreSQL Example  :

Copy and save the below code in jdbcTestApp.java file

To run the application , right click on the project and select Run As -> Java Application.

 

Jdbc with PostgreSQL Using NetBeans :

Create New Project :

Go to File and select New Project sub menu

From Java select Java Application

Enter appropriate project name in the Project Name box. click Finish

Add Jar Files :

Expand project , Right click on Libraries and select Add JAR/Folder

Select postgresql_8_2_504_jdbc3.jar  for the location where it reside and finally click open .

Project Directory Structure :

See the project directory structure in the top-left side of the NetBeans IDE. It should be like below.

Jdbc with PostgreSQL Example  :

Copy and save the below code in jdbcTestApp.java file

Right click on the project and select Run .




Related Posts :
How to Connect Liferay 7 to PostgreSQL ( Java Liferay portlet and PostgreSQL integration )
Jsp , Servlet and JDBC login application example in NetBeans
Jsp,Servlet and JDBC integration example in Eclipse
Connect DB2 with Hibernate 4 in MyEclipse,NetBeans,RAD
Connect PostgreSQL with Hibernate 4 in Myeclipse,NetBeans,RAD
Connect MySQL with Hibernate 4 in NetBeans,MyEclipse,RAD
Connect oracle with hibernate in MyEclipse, NetBeans, RAD
Jdbc with Mysql in NetBeans and MyEclipse
   [will not be published]



^ <