Hibernate and Java hello example

Step 1:  Open netbeans
File> New Project >java web> web application .click next
Project name : hibernatehello .click next . again click nextnow select framework : hibernate . click finish
Step 2: Now hibernate.cfg.xml file opens edit this line change the database name if required in am using hibernate 

after edit:

make sure that this database should exists 
complete code of hibernate.cfg.xml

Step 3:
Make a java class named student and copy the below code.(Student.java)

Step 4:
Now right click on the folder and select hibernate mapping wizard
File Name: student.hbm .click next

class to map: one.Student .click finish
code in student.hbl

Step 5:
Again right click on package “one” select HibernateUtil.java
name this class as HibernateUtil and just click finish.
now last step:
copy this code in index.jsp

Leave a Reply

Contact Us
close slider
Contact Us

How can we help you with?