您的位置:首页 > 运维架构

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

2014-02-22 16:02 453 查看
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


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐