This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Kubernetes in Action and have Marko Luksa on-line!
See this thread for details.
Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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.
 
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!