-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: MySQL connections count
PostPosted: Sun Jan 04, 2009 9:54 pm 
Newbie

Joined: Tue Aug 12, 2008 7:42 pm
Posts: 3
Location: Mexico
Hi everyone:

I'm using Hibernate 3.2.5 with MySql 5.1. I'm building a Web app using J2EE and Tomcat. I put in a servlet the next test code


Session sesion = HibernateUtil.getSessionFactory().openSession();
sesion.beginTransaction();

Usuario usr = new Usuario();
UsuarioHome usrDal = new UsuarioHome();

usr = usrDal.findById("ff8081811dd7e638011dd7e76b910002", sesion);

sesion.getTransaction().commit();


This works prefectly, the problem is that, when I see the MySQL Administrator Client in the "Server Connections" tab, I see that after I execute my servlet, two more connections are generated, but they don't dissapear, instead they appear as "sleep". If I do a sesion.close() I get an exception because it says that commit() already closed the sesion.

So, the question is... is it normal that mySQL keep this connections??, do I have to configure something in my Hibernate mappings, MySql or Tomcat.

Any advice would be appreciated. Thank You in advance for your time.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 05, 2009 4:27 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
hibernate keeps some connection in DB for using connection pool support.
Use explicit transaction i.e., create transaction object and commit that object.

_________________
If u feel it will help you, don't forget to rate me....


Top
 Profile  
 
 Post subject: Solved
PostPosted: Mon Jan 05, 2009 6:07 pm 
Newbie

Joined: Tue Aug 12, 2008 7:42 pm
Posts: 3
Location: Mexico
I tried what you suggested Madan_Prabhu without success. But the problem was solved when I started using c3P0 Connection Pool. Thank you for your answer anyway.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.