what is java.io.EOFException, Message: Can not read response from server. Expected to read 4 bytes, read 0 bytes

前端 未结 8 2162
隐瞒了意图╮
隐瞒了意图╮ 2020-12-14 00:18

This question has been asked a couple of times in SO and many times in other sites. But I didn\'t get any satisfiable answer.

My problem:
I have a java web app

相关标签:
8条回答
  • 2020-12-14 00:40

    It might be Firewall related problem.

    0 讨论(0)
  • 2020-12-14 00:41

    This is EndOfFileException in java, happens when your cursor start point is on the end point or when database connection closed because of some unexpected exception.

    0 讨论(0)
  • 2020-12-14 00:41

    Got this error in PHPStorm while trying to connect and/or get some data from mysql server. Checkbox "single connection mode" fixed things for me. I'll just leave it here. Perhaps this will help some martyr in the future.

    https://www.jetbrains.com/help/phpstorm/configuring-database-connections.html

    0 讨论(0)
  • 2020-12-14 00:46

    I had this problem but I it wasn't possible for me to make changes in MySQL database configuration. Therefore I ensured that in my sql connector class the connection is always closed before it's initiated again. Something like:

    public static Connection getConnection() {
    
        if (DatabaseConnnector.conn == null) {
            initConn();
        } else {
            try {
                DatabaseConnnector.conn.close();          
            } catch (SQLException e) {
                e.printStackTrace();
            }
              initConn();
        }
        return DatabaseConnnector.conn;
    }
    

    And this solved the problem.

    0 讨论(0)
  • 2020-12-14 00:46

    i meet the same problem, it caused by lock for too much time.

    we have a long transcation A, if execute it, the other trascation will be locked util transcation A finished, so the others always be killed by our mysql tool(pt-kill)

    0 讨论(0)
  • 2020-12-14 00:49

    The connection has failed, possibly due to a firewall idle-timeout, etc. If you don't have your JDBC driver configured to reconnect on failure, then this error will not go away unless you open a new connection.

    If you are using a database connection pool (you are using one, right?), then you probably want to enable it's connection-checking features like issuing a query to check to see if the connection is working before handing it back to the application. In Apache commons-dbcp, this is called the validationQuery and is often set to something simple like SELECT 1.

    Since you are using MySQL, you ought to use a Connector/J-specific "ping" query that is lighter-weight than actually issuing a true SQL query and set your validation query to /* ping */ SELECT 1 (the ping part needs to be exact).

    0 讨论(0)
提交回复
热议问题