Tomcat and MySQL
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Pytone_P
Posted On:   Wednesday, November 18, 2009 10:11 AM

Hello, i've developed a web application, it runs on Tomcat 5.5.4 and it uses MySQL. I have a problem when after i use the application, and then it remains idle for some hours. It seems that the connection with MySQL it's closed by the driver due to a timeout. The stacktrace is the follow: javax.servlet.ServletException: No operations allowed after connection closed.Connection was implicitly closed by the driver. org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:845) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:778) org.apache.jsp.aziende_jsp._jspService(org.a   More>>

Hello,



i've developed a web application, it runs on Tomcat 5.5.4 and it uses MySQL.

I have a problem when after i use the application, and then it remains idle for
some hours.

It seems that the connection with MySQL it's closed by the driver due to a timeout.

The stacktrace is the follow:




javax.servlet.ServletException: No operations allowed after connection closed.Connection was implicitly closed by the driver.

org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:845)

org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:778)

org.apache.jsp.aziende_jsp._jspService(org.apache.jsp.aziende_jsp:482)

org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed by the driver.
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:980)

com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)

com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)

com.mysql.jdbc.ConnectionImpl.throwConnectionClosedException(ConnectionImpl.java:1160)

com.mysql.jdbc.ConnectionImpl.checkClosed(ConnectionImpl.java:1147)

com.mysql.jdbc.ConnectionImpl.createStatement(ConnectionImpl.java:2486)

com.mysql.jdbc.ConnectionImpl.createStatement(ConnectionImpl.java:2468)

businessLogic.CommonInterface.getSpecializzazioni(CommonInterface.java:1538)

businessLogic.CommonInterface.getSpecializzazione(CommonInterface.java:930)

org.apache.jsp.aziende_jsp._jspService(org.apache.jsp.aziende_jsp:128)

org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)




Can i configure Tomcat so that the connection with MySQL will be persistent?



thank you in advice :)

   <<Less

Re: Tomcat and MySQL

Posted By:   Stephen_McConnell  
Posted On:   Wednesday, November 18, 2009 09:58 PM

The best way to handle this would not be in the configuration of Tomcat. Not a good idea to keep a DB connection persistent and un-used for hours. Very bad programming practice.

What one CAN do is find where this exception is generated, CATCH the exception (mmmm that is what exception handling is for) and re-open the connection and try again.
About | Sitemap | Contact