org.hibernate.exception.GenericJDBCException: Cannot open cconnection(执行几次查询之后就不能查询/页面动不了/分页查询只能点击几)

org.hibernate.exception.GenericJDBCException: Cannot open cconnection(执行几次查询之后就不能查询/页面动不了/分页查询只能点击几而已)


解决方案:

SSH中使用类似 this.hibernateTemplate.getSessionFactory().openSession().createSQLQuery(sqlString)的查询功能多次后,页面会卡死不动,主要是因为session的没有关闭内存不断攀升所致,解决方法可以将语句拆开,然后关闭session;

SSH中使用类似 this.hibernateTemplate.getSessionFactory().openSession().createSQLQuery(sqlString)/分页查询只能点击几次而已,就报 Cannot open cconnection,主要是因为session的没有关闭连接所致,解决方法可以将语句拆开,然后关闭session;

如:

  Session session=this.getHibernateTemplate().getSessionFactory().openSession();
  List list = session.createSQLQuery(sqlString).list();


  session.clear();//关闭session
  session.close();//关闭连接con



你可能感兴趣的:(org.hibernate.exception.GenericJDBCException: Cannot open cconnection(执行几次查询之后就不能查询/页面动不了/分页查询只能点击几))