-
1. Re: sleeped connections return to pool after some time in jboss as 7.1
wdfink Jun 11, 2013 2:47 AM (in response to rameshchokkapu)To me it is not clear what 'sleeped' connections are. Maybe you have a connection leak where the connections not closed and therefor not marked to returned to pool.
You should read this wiki and use it to check whether you have such leak.
-
2. Re: sleeped connections return to pool after some time in jboss as 7.1
rameshchokkapu Jun 11, 2013 5:38 AM (in response to wdfink)Thank for Reply.
Yes, Connection Leak. these leaked connections need to be return to pool after some time.
DestroyCount should be always "DestroyedCount" => "0".
I have another Question which is :
--------------------------------------------------
i have hundreds of DAO methods like below.
some DAO methods, i forgot to session.close() at finally block.
so my connections are getting to leak (sleep).
these leaked connections are not return to pool and i need to find where is that leak.
i have two options for this: 1) i need to return these leaked connections to pool after some time. 2) Need to find leak in which DAO method.
but always DestroyCount should show as zero (its my own requirement).
i have checked with debug="true" and ccm="true" and track-statements set to true . but in my server.log is not showing these connection leak. its only shows statement.close() and resultset.close() suggestions but not about session.close() suggestions.
sample DAO method :
public Emp findById(Long id) throws DAOException {
Session session = null;
try {
session = HibernateConnector.getInstance().getSession();
Query query = session.createQuery("from Emp where id = :id");
query.setParameter("id", "" + id);
List queryList = query.list();
if(queryList.isEmpty()) {
return null;
}
return (Emp) queryList.get(0); // only one expected because of
// the unique id
} catch (HibernateException ex) {
ex.printStackTrace();
} finally {
if(session != null) {
try {
session.close(); // if not put this statement, connection get into leak.(i have forgot these statement in some DAO methods)
} catch (HibernateException ignore) {
}
}
}// try/catch/finally ..
}
please help me.
Thanks in advance.
-
3. Re: sleeped connections return to pool after some time in jboss as 7.1
wdfink Jun 11, 2013 7:34 AM (in response to rameshchokkapu)There is no option to return connections to the pool other than closing it.
I'm not sure why setting the cache-connection-manager to debug the connection is not showing the stacktrace where the connection is opened.
If the container finish the invocation you should see a message that you should close the connection and the stacktrace.
I'm not a hibernate expert, but if you see the pool statistic hibernate should use this pool.
Do you have an extended persistence context in some cases?
-
4. Re: sleeped connections return to pool after some time in jboss as 7.1
rameshchokkapu Jun 11, 2013 8:34 AM (in response to wdfink)Thank You for Reply.
i am not using extended persistence context. No transations are maintained and using only stateless session beans which are Bean Managed.