0

When the application starts, it works fine, but after many update operations, it throws an exception:

[Request processing failed; nested exception is org.hibernate.exception.GenericJDBCException: Could not open connection] with root cause java.util.NoSuchElementException: Timeout waiting for idle object

Image

private SessionFactory sessionFactory;
public SessionFactory getSessionFactory() {
    return sessionFactory;
}

public void setSessionFactory(SessionFactory sessionFactory) {
    this.sessionFactory = sessionFactory;

}

protected  Session openSession() {
    return getSessionFactory().openSession();
}

 public void deleteAnyType(T t){
    Session session =super.openSession();
    session.delete(t);
    session.beginTransaction().commit();
    session.close();
}
Pang
  • 9,564
  • 146
  • 81
  • 122
黄伟杰
  • 27
  • 1
  • 12
  • this question might help you http://stackoverflow.com/questions/11734808/i-am-getting-cannot-get-a-connection-pool-error-timeout-waiting-for-idle-object – Mohamed Nabli Jul 27 '16 at 10:20
  • 2
    Don't use `openSession` use `getCurrentSession` and let spring manage the resources for you. – M. Deinum Jul 27 '16 at 10:23
  • Please post the actual stack trace as text instead of screenshots. Others can't copy and paste from your images. [See here](http://meta.stackoverflow.com/a/285557/1402846) for details. Thank you. – Pang Jul 27 '16 at 10:26
  • thank you for your help,it's my first time to use StackOverFlow,and forgive my pool English – 黄伟杰 Jul 27 '16 at 13:51

0 Answers0