Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"Connection reset" messages after opening new Hibernate session

 
Cameron Dalton
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a long running stand-alone application which listens on a JMS queue for messages telling it to run. When a message comes in, a Hibernate session is opened, queries are performed, and then the session is closed using Session.close(). There is no transaction management because no writes are being performed.

Now I was under the impression that Session.close() closes the underlying JDBC connection with the database. However, something seems to remain open or aware of the database server because if the database is restarted before the next JMS message comes in, there is a SocketException thrown (with messages like "connection reset by peer", "socket write error", etc). The open session does not throw the exception; it is thrown by the first query.

What do I need to do to completely close the connection so that when a JMS message is received a brand new connection is made from scratch?

Thanks for your help with this problem.
 
Javid Jamae
Author
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AFAIK, the session does not control the lifecycle of the connection, the datasource does. What datasource do you have configured? Are you using connection pooling? Show us your hibernate.cfg.xml file.
 
Cameron Dalton
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response, Javid. Here's the interesting parts of my hibernate.cfg.xml:



This is not running in a J2EE container as it's a standalone Java app, so I didn't think I could use a datasource. Maybe I'm wrong though...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic