I am running into the following error: java.sql.SQLNonTransientConnectionException: (conn=59967) Broken pipe (Write failed)
when trying to execute a query to a database after the connection has been opened for over a day. Of course, testing this would be strenuous since leaving a process running for a day would take forever.
I was wondering the following:
- Is it possible to reproduce this error? (Possibly parameters to add onto the JDBC connection and/or variables to change on mysql?) I've tried lowering wait_timeout, however that didn't throw a Broken Pipe but something else.
- Would Connection.isValid() (https://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html) catch the broken pipe error? I was thinking of creating a method that checks if the connection isValid using that method before creating a new connection.