Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Sanjeev Kumaar
Greenhorn
Posts: 12
Java MySQL Database Tomcat Server
  • 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.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do you commit your transaction?
 
Sanjeev Kumaar
Greenhorn
Posts: 12
Java MySQL Database Tomcat Server
  • 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
Java MySQL Database Tomcat Server
  • 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
Eclipse IDE Hibernate 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic