fidoandfido / blackswan

Blackswan Stock Game
Other
2 stars 0 forks source link

Broken connections when accessing database #14

Closed fidoandfido closed 13 years ago

fidoandfido commented 13 years ago

Occasionally, an exception is raised:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /Welcome.jsp at line 17

14: <%
15: HibernateUtil.beginTransaction(); 16: UserSessionDAO userSessionDAO = new UserSessionDAO(); 17: UserSession userSession = userSessionDAO.getUserSessionBySessionId(request.getSession().getId()); 18: 19: User user = null; 20: Trader trader = null;

Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:553) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:457) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

org.hibernate.exception.JDBCConnectionException: could not execute query org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74) org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) org.hibernate.loader.Loader.doList(Loader.java:2147)

And so on.

Further down are the lines:

root cause

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 195,570,528 milliseconds ago. The last packet sent successfully to the server was 195,570,529 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem. sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

This would indicate that the server is using a connection pool and recycling connections; occasionally a connection is returned that has timed out. Suggested remedy would be to add the autoconnect parameter to the hibernate.cfg.xml file appropriately.

fidoandfido commented 13 years ago

Updated hibernate config; as per link here : http://www.codefin.net/2007/05/hibernate-and-mysql-connection-timeouts.html

Also added auto reconnect to connection url.