Waiting for table level lock Mysql Java application error

Asked

Viewed 253 times

0

I have a Java swing application that uses the Mysql database, in its operation after spending some time in operation I realized that the application hangs in a few moments, It is necessary to restart the computer to be able to carry out the process again because even closing the application and opening again the same problem persisted. I was able to identify that the problem occurred at the time of recording or updating information. Consulting the Workbench I checked the connections and saw that there was a user stopped with the command related to the process. The state of that connection was as Waiting for table level lock now I am not sure that it is she who is causing the problem or something of my application that is not treating 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();
        }
    }
}
  • You’re committing and closing the transaction correctly?

  • I will update the issue by adding the code you requested.

1 answer

0


Along with the application also works a backup application that designed by the team, and with the database of a larger size, the time to carry out the backup increases, causing the waiting of the backup to finish to carry out the recording of the data in the database. At first I did the removal of the backup application and am analyzing a more effective and independent way to backup without causing problems in application performance.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.