title: SocketException: Broken pipe with a mysql database accessed through JDBC
body: <p>I have a web application with a MySQL backend accessed through JDBC. Every morning I see this exception:</p>
  
  <p>** BEGIN NESTED EXCEPTION ** </p>
  
  <pre><code>java.net.SocketException
  MESSAGE: Broken pipe
  </code></pre>
  
  <p>STACKTRACE:</p>
  
  <pre><code>java.net.SocketException: Broken pipe
  at java.net.SocketOutputStream.socketWrite0(Native Method)
  at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
  at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
  at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
  at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
  at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2744)
  at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1612)
  at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
  at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
  at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
  at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1467)
  at com.model.dbchecks.DatabaseConnectHandler.db_execute_prepared_query(DatabaseConnectHandler.java:117)
  at com.model.dbchecks.UserHandler.does_user_exist(UserHandler.java:154)
  at com.model.dbchecks.UserHandler.authenticate_user(UserHandler.java:66)
  at com.web.security.LoginServlet.doPost(LoginServlet.java:68)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
  </code></pre>
  
  <p>How do I prevent this ? </p>