Re: MySQL connection problems on Tomcat



Hakan wrote:

My web start application connects to a MySQL database through a servlet. The servlet accesses the database through a MySQL connector instance and returns the results the client if necessary. Everything is done through a Tomcat Linux web server.

My problems seem to occur when I run the program through the servlet for the first time after a while, like the first time of the day or after not testing it on the server for some days. It can't fetch anything from the database, so the client just gets null objects back. Ultimately, a NullPointerException kills the application as it has nothing to work with.

The solution is very simple. I shut down Tomcat and restart it, after which it again reads results from the database as it should. This is just not a sustainable way to deal with it.

My employer wants to deploy it such that many different users will have an interest in accessing it from various places and not just people with system administrator privileges. Hence, crashes are liable to make them spurn the application. That would make quite a lot of work useless.

Do you know the source of the mentioned problem?

Regards.

The MySQL server has a system variable named wait_timeout:

http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#option_mysqld_wait_timeout

If there is no activity on a TCP/IP connection for more than wait_timeout seconds, then the server will close the connection.

The default value is 28800 seconds, or 8 hours.

You can either override the timeout globally in your server configuration file by adding a line such as

wait_timeout = 864000

to change the timeout to 10 days for all connections, or set it on a per-connection basis by sending the command

set wait_timeout = 864000;

to the server from each new connection.

David Harper
Cambridge, England
.



Relevant Pages

  • Re: ADO Connection Timeout
    ... to the central server, but you are willing to live with periods where it ... i.e. a local database or even a text file. ... to function until the connection can be restored to the server. ...
    (microsoft.public.data.ado)
  • Complicated Connection Problems bewteen ADP and SQL Server
    ... This database ... expertise for getting the user workstations talking to the SQL Server. ... connection would fail and the adp wouldn't be able to talk to the server. ... might be in my ADO connection string. ...
    (microsoft.public.access.adp.sqlserver)
  • Complicated Connection Problem between ADP and SQL Server
    ... This database ... expertise for getting the user workstations talking to the SQL Server. ... connection would fail and the adp wouldn't be able to talk to the server. ... might be in my ADO connection string. ...
    (microsoft.public.sqlserver.connect)
  • Re: ADO Connection Timeout
    ... so what happens when a connection failure forces one station to revert ... to a local database? ... Further, you *will* have contention issues, Jet does not support record ... to the central server, but you are willing to live with periods where it ...
    (microsoft.public.data.ado)
  • Re: ADO Connection Timeout
    ... When the first test is run, the results are stored in the central database. ... to the central server, but you are willing to live with periods where it ... i.e. a local database or even a text file. ... to function until the connection can be restored to the server. ...
    (microsoft.public.data.ado)