My webapp is running on Tomcat 5.5, I declared the datasource in web.xml:
jdbc/OrdiniWebDS
MySQL drops unused connections after a while because it assumes that the other side forgot to close it.
What you need to do is to configure a check that Tomcat should apply before it reuses a pooled connection. To do this, add ?autoReconnect=true&useUnicode=true&characterEncoding=utf8 to the end of the URL and add validationQuery="Select 1" to the Resource element:
[EDIT] This page gives more details: Configuring a MySQL Datasource in Apache Tomcat