title: connection gone out while scheduled operation in Spring with BoneCP: "Database access prob lem. Killing off this connection..."
body: <p>I use injected EntityManagerFactory for scheduled operation:</p>
  
  <pre><code>@PersistenceUnit
  private EntityManagerFactory entityManagerFactory;
  
  @Scheduled(cron="0 0/10 * * * *")
  private void scheduledOperation() {
      int rows = 0;
      try {
          EntityManager em = entityManagerFactory.createEntityManager();
          em.getTransaction().begin();
          rows = em.createNativeQuery("UPDATE table SET ...").executeUpdate();
          em.getTransaction().commit();
      } catch (Exception ex) {
          logger.error("Exception while scheduledOperation. Details: " + ex.getMessage());
      }
      DateTime now = new DateTime(DateTimeZone.UTC);
      logger.info("Scheduled operation completed. Rows affected: {}. UTC time: {}", rows, now);
  }
  </code></pre>
  
  <p>When the application is started, scheduled operation runs every 10 minutes. So first several times operation works as well, but after some time this gone with error: </p>
  
  <pre><code>ERROR - ConnectionHandle           - Database access problem. Killing off this 
  connection and all remaining connections in the connection pool. SQL State = 08S01
  </code></pre>
  
  <p>Whats happens? How I can keep connection, or take working connection for each scheduled operation?</p>