-->
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: Connection leak
PostPosted: Tue Dec 02, 2008 4:40 am 
Newbie

Joined: Tue Oct 21, 2008 7:39 am
Posts: 2
Hi

Im suspecting one of our applications is leaking connections. ( See log at bottom)
We are using hibernate 3.2.5 and c3p0 connection pooling.

But I am in doubt on how to determine where the connections leak.

Under what circumstances is the application responsible for returning the connections and when is this done automtically by hibernate?

Is there fex any difference between how to handle a:
getSession().createSQLQuery().executeUpdate()
and a:
getHibernateTemplate().find()
in the same method under the same circumstances?

Appreciate any pointers on how to solve this problem.

Claes

--------- Log --------------------
[DEBUG ] [connector.http.0.receiver.7] org.hibernate.jdbc.ConnectionManager - opening JDBC connection
[DEBUG ] [connector.http.0.receiver.7] org.hibernate.SQL - select productlin0_.productLineId as productL1_12_, productlin0_.CHAN
GEDBY as CHANGEDBY12_, productlin0_.LASTCHANGED as LASTCHAN3_12_, productlin0_.active as active12_, productlin0_.crmCode as crmCode12_, productlin0_.distrib
utionNumber as distribu6_12_, productlin0_.GENERALLEDGERID as GENERAL11_12_, productlin0_.name as name12_, productlin0_.price as price12_, productlin0_.vali
dFromDate as validFro9_12_, productlin0_.VATCODEID as VATCODEID12_ from PRODUCT_LINES productlin0_
[TRACE ] [connector.http.0.receiver.7] org.hibernate.jdbc.AbstractBatcher - preparing statement
[DEBUG ] [connector.http.0.receiver.7] org.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataS
ource

After this it does nothing more.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2008 10:55 am 
Beginner
Beginner

Joined: Thu Oct 02, 2008 10:15 am
Posts: 21
I would assume that if you are getting the Session explicitly using getSession(), you are also calling releaseSession().
Whereas when using HibernateTemplate it takes care of opening and closing a session.
Here are the Javadocs for HibernateTemplate from official documentation:
"
It provides Hibernate Session
handling such that neither the HibernateCallback implementation nor the calling
code needs to explicitly care about retrieving/closing Hibernate Sessions,
or handling Session lifecycle exceptions. "
Let me know if it helps.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 04, 2008 5:54 am 
Newbie

Joined: Tue Oct 21, 2008 7:39 am
Posts: 2
Thank you for pointing me to releaseSession(), I was trying all sorts of combinations with session.close() which just caused more trouble.

releaseSession was the key.


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.