This problem has annoyed me for long. Every morning the first thing I did is to restart tomcat tomca once because otherwise this exception will be thrown:
[PortalLoginFilter] trying to authenticate user kangtang according to the database record...java.sql.SQLException: No operations allowed after connection closed.
Connection was closed due to the following exception:
** BEGIN NESTED EXCEPTION **
java.sql.SQLException
MESSAGE: Communication link failure: java.io.EOFException, underlying cause: null
** BEGIN NESTED EXCEPTION **
java.io.EOFException
STACKTRACE:
The reason is because mysql close an inactive connection after 8 hours idle. (Connector/J I am using is mysql-connector-java-3.0.17, mysql version 4.1.2)
This time can be changed by using SET statement in mysql, command-line parameters when starting mysql or configuring in my.cnf, a sample my.cnf is like this:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
wait_timeout=604800
interactive_timeout=604800
[mysql.server]
user=mysql
basedir=/var/lib
[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pidUse SHOW VARIABLES statement to check current running system variables. 604800 is in Sec, which is 1 week's time.