0

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.
jarlh
  • 42,561
  • 8
  • 45
  • 63
Skeol
  • 37
  • 7
  • Would adding auto reconnect parameter to the connection string resolve this issue? See https://stackoverflow.com/questions/37707104/intermittent-jdbc-broken-pipe-and-link-failure – Shadow Oct 14 '20 at 00:58
  • Use a connection pool such as Apache DBCP. They already take care of all this stuff. – user207421 Oct 14 '20 at 06:44

0 Answers0