Wednesday 22 February 2012

A SIMPLE HIBERNATE DEMO IN ECLIPSE IDE ( INDIGO.)..(3.7)

   
   Today, I created a simple demo for hibernate in Eclipse.
It is very simple. First of all, we have to include all the required 
jar files which are needed for developing a hibernate program.


  They are  available in hibernate2\lib  folder and add hibernate2\hibernate2.jar. also
In the same way you can include mysqldriver.jar file also.And my project name  is hiberconsoletrial.


  Before beginning hibernate code,


we have to  create a simple database in MySql. I am using MySql which comes bundled with XAMPP.



 Now go to c:\xampp\mysql\bin

>mysql   -u  root
>create   database   mycontacts;
>use mycontacts;
>create table  mycontactstable (id   varchar(4) primary key,name   varchar(15), phone  varchar(15));
After making a few entries,

   I  created a new class in hiberconsoletrial. It is a bean(besthiherbean).
and wrote a console class (besthiberbeanuser) in the same folder(hiberconsoletrial\src). Then place properties file and mapping xml file  in the same directory where our besthiberbean and besthiberbeanuser classes are available.

  Then I went to run configuration and gave required arguments.
It ran successfully!









.