Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

I'm not able to insert record in Derby using Hibernate

 
Greenhorn
Posts: 12
MySQL Database Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All!

This is my first example of Hibernate. I'm trying to insert a record in Derby using Hibernate. I've created a web application where a servlet is doing the main stuff.

I've used
IDE : Netbeans 6.8
Database : Derby
Server : Glassfish



here is my hibernate.cfg.xml



my hibernate.reveng.xml



my pack1.Student.hbm.xml




my pack1.Student.java




my pack1.NewHibernateUtil.java




n my pack1.NewServlet.java




I'm having STUDENT table inside "sample" db on my local Derby server.




while calling servlet it shows success but doesn't inserting record .

Please guide me.

Thanks in advance.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do you commit your transaction?
 
Sanjeev Kumaar
Greenhorn
Posts: 12
MySQL Database Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks Paul for showing interest ,

as per tutorial saving the session was enough and I if committing the transaction is necessary then how I'll do this ? I mean which method I'll use?

 
Sanjeev Kumaar
Greenhorn
Posts: 12
MySQL Database Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Problem resolved ....

I modified my servlet code a bit like following.





Tell me if I can improve this ...


Thanks Paul ! you were really helpful .
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sanjeev Kumaar wrote:
Thanks Paul for showing interest ,

as per tutorial saving the session was enough and I if committing the transaction is necessary then how I'll do this ? I mean which method I'll use?



You are welcome.

The tutorial you are using is wrong.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic