You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by giocarmine <gi...@gmail.com> on 2009/11/18 15:52:19 UTC

Tomcat and MySQL

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 :)
-- 
View this message in context: http://old.nabble.com/Tomcat-and-MySQL-tp26408387p26408387.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat and MySQL

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: giocarmine [mailto:giocarmine@gmail.com]
> Subject: Tomcat and MySQL
> 
> i've developed a web application, it runs on Tomcat 5.5.4

Step 1: upgrade.  5.5.4 is over five years old and innumerable bugs and security issues have been fixed since then.

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

Not by the driver, but by the MySQL server.  Besides the autoReconnect setting, read the commons-dbcp doc and try the testOnBorrow and validationQuery settings:
http://commons.apache.org/dbcp/configuration.html

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat and MySQL

Posted by Pid <pi...@pidster.com>.
On 18/11/2009 14:57, Neil Aggarwal wrote:
> Giocarmine:
>
>> It seems that the connection with MySQL it's closed by the
>> driver due to a
>> timeout.
>
> Have you set autoReconnect=true in your JDBC url?
>
> jdbc:mysql://localhost:3306/dbName?autoReconnect=true

Opening a single connection, and keeping it open, is not usually a good 
strategy.  A better solution would be to configure a connection pool.

 
http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html#Database%20Connection%20Pool%20%28DBCP%29%20Configurations


p



> 	Neil
>
> --
> Neil Aggarwal, (281)846-8957, http://UnmeteredVPS.net
> Host your tomcat app on a CentOS VPS for only $25/month!
> Unmetered bandwidth, 7 day no risk trial, Google Checkout
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat and MySQL

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Giocarmine:

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

Have you set autoReconnect=true in your JDBC url?

jdbc:mysql://localhost:3306/dbName?autoReconnect=true

	Neil

--
Neil Aggarwal, (281)846-8957, http://UnmeteredVPS.net
Host your tomcat app on a CentOS VPS for only $25/month!
Unmetered bandwidth, 7 day no risk trial, Google Checkout


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org