How can I find the jdbc connection timeout of a hibernate session
Posted
by
StevenWilkins
on Stack Overflow
See other posts from Stack Overflow
or by StevenWilkins
Published on 2010-12-22T15:46:20Z
Indexed on
2010/12/26
8:54 UTC
Read the original article
Hit count: 233
I currently have a long running thread which uses a hibernate session to perform many updates. We currently have our c3p0 connection timeout set to 20 minutes and it's timing out sometimes because of the number of updates we're performing.
The solution I have is to periodically return the connection to the pool via closing the session (we have hibernate configured this way) and get a new one. Upping the timeout is not desirable because the same pool is used for the entire application.
The problem is I don't know when to return the connection to the pool because I don't know what the timeout of the connection is. I know what the current setting is in our property file, but that can be changed without my knowledge at any time so it's fragile. Having a counter and returning the connection based on the number of updates I've performed is not ideal but could be my option of last resort.
I have a hibernate session, how can I retrieve the connection timeout of the jdbc connection which backs the session? Using the SessionFactory and SessionFactoryImpl classes are perfectly acceptable.
© Stack Overflow or respective owner