Error Waiting for table level lock MySQL Java application

0

I have a Java swing application that uses the MySQL database, in its operation after some time spent in operation I noticed that the application crashed in some moments, it is necessary to restart the computer to be able to perform the process again because even closing the application and again opening the same problem persisted. I was able to identify what the problem caused when recording or updating information. Querying the Workbench I checked the connections and saw that there was a stopped user with the command related to the process. The state of that connection was like Waiting for table level lock now I'm not sure that it's causing the problem or something in my application that is not handling correctly.

DAO.java

 public int create(Produto produto) {
    EntityManager em = null;
    try {
        em = getEntityManager();
        em.getTransaction().begin();
        em.persist(produto);
        em.getTransaction().commit();
    } finally {
        if (em != null) {
            em.close();
        }
    }

    return produto.getCodproduto();
}

public void edit(Produto produto) throws NonexistentEntityException, Exception {
    EntityManager em = null;
    try {
        em = getEntityManager();
        em.getTransaction().begin();
        produto = em.merge(produto);
        em.getTransaction().commit();
    } catch (Exception ex) {
        String msg = ex.getLocalizedMessage();
        if (msg == null || msg.length() == 0) {
            Integer id = produto.getCodproduto();
            if (findProduto(id) == null) {
                throw new NonexistentEntityException("The produto with id " + id + " no longer exists.");
            }
        }
        throw ex;
    } finally {
        if (em != null) {
            em.close();
        }
    }
}
    
asked by anonymous 15.09.2016 / 12:55

1 answer

0

The application also runs a backup application that is designed by the team, and with the database of a larger size, the time to perform the backup increases, waiting for the end of the backup to perform the recording of the data in the Bank. At first I did the removal of the backup application and I am analyzing a more efficient and independent way of doing the backup without causing problems in the performance of the application.

    
30.09.2016 / 18:49