Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Losing connection to DB

Status
Not open for further replies.

momyyao

Programmer
Oct 26, 2005
3
US
I have a web site using Hibernate + Struts. It is on company's server with Tomcat + MySQL.
Once a day, the application disconnects to the database and throws 500 error to every page since the side bar needs to pull info. from the database. Log only says "Could not execute query". So, every morning, I have to restart Tomcat to fix the 500 error.
Anyone, any idea what's going on?

Thanks in advance!
 
What do you mean by 'Once a day, the application disconnects to the database' ? Are you saying that you always leave a connection open to the db ?

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
I mean every morning when I open the home page, it throws 500 error. And after I restart Tomcat, everything will be fine till the next morning.
All connections are managed by Hibernate. And I always close a Hibernate session after each access.
 
Are you sure you close all connections to the db (including result sets, statements etc) ?

What happens overnight ? Does the db get restarted at all ? Does the server get rebooted ?

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Correct me if I'm wrong.
For my understanding, each hibernate session attempts a connection to the database. When the session is closed, the connection terminates as well. So I only need to make sure a Hibernate session is closed after process.
I use MyEclipse which generates sessionFactory file automatically when I add the Hibernate capabilities. And I'm pretty sure I closed every session as I followed MyEclipse's tutorial for my project.
Over night, the server does nothing but keeping online, no reboot. I'm not sure about the DB, but MySQL is running every morning for sure.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top