w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
connection gone out while scheduled operation in Spring with BoneCP: "Database access prob lem. Killing off this connection..."

That's because you don't ever close the EntityManager and the associated connections might hang indefinitely.

Change your code to this instead:

EntityManager em = null;
try {        
    em = entityManagerFactory.createEntityManager();
    rows = em.createNativeQuery("UPDATE table SET ...").executeUpdate();
} catch (Exception ex) {
    logger.error("Exception while scheduledOperation. Details: " +
} finally {
    if(em != null) {

And always call rollback on failure. Don't assume transactions will rollback automatically because this is a database specific implementation.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.