My Notepad

  • My Linux Notes
  • My Grid Notes
  • To do List
  • Wednesday, November 22, 2006

     

    MySQL: No operations allowed after connection closed.

    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.pid



    Use SHOW VARIABLES statement to check current running system variables. 604800 is in Sec, which is 1 week's time.

    Comments: Post a Comment



    << Home

    Archives

    December 2005   January 2006   February 2006   April 2006   May 2006   June 2006   July 2006   November 2006   February 2007   May 2007   June 2007   November 2007   February 2008   March 2008   April 2008   August 2008   December 2008   March 2009   April 2009   May 2009   June 2009   October 2009   November 2009   December 2009   May 2013  

    This page is powered by Blogger. Isn't yours?