Hibernate connections are not closed even with C3P0 + explicit session.close()

后端 未结 2 566
猫巷女王i
猫巷女王i 2021-01-05 21:58

Hibernate connections to MySQL my db are not closing. After clicking 10 times in like 10 second, I get this connection statistics from MySQL Workbench (in my development mac

2条回答
  •  清酒与你
    2021-01-05 22:18

    private static final ThreadLocal session = new ThreadLocal();
    
    public static void closeSession() throws HibernateException {
        Session s = session.get();
        if (s != null) {
            s.close();
            session.remove();
        }
    }
    

    actually I am doing like this and it works

提交回复
热议问题