当前页面: 开发资料首页 → JSP 专题 → 高兴散分,妈的,c3pO连接池,耽误了我两天时间,希望大家以后注意.
高兴散分,妈的,c3pO连接池,耽误了我两天时间,希望大家以后注意.
摘要: 高兴散分,妈的,c3pO连接池,耽误了我两天时间,希望大家以后注意.
Session s = HibernateSessionFactory.currentSession();
String hql=null;
Iterator it=null;
//第一段
hql="From BmStbi where sbeno='02200607040001'";
it = s.createQuery(hql).list().iterator();
BmStbi bs = (BmStbi)it.next();
out.print(bs.getSbeno());
out.print(bs.getSbeno());
//第二段
hql="From BmDictionary where code='0313012'";
it = s.createQuery(hql).list().iterator();
BmDictionary bd=(BmDictionary)it.next();
out.print(bd.getCode());
out.print(bd.getName());
HibernateSessionFactory.closeSession();
问题:
两段同时执行就报异常:
org.apache.jasper.JasperException: could not execute query
注释掉任何一段的话,执行正常,我实在不知道错在哪里了.
终于找到问题了,本来是用的hibernate自带的连接池,换了这个就出现问题,好想连接只能使用一次,如果只一个查询的话,连着刷新会一次正确一次错误,一个页面两个查询就会出现上述错误.
没看出问题,但分还是要接的
JF
jf
gxlz
恭喜楼主 功德圆满
我觉得问题是不是在这里:你有两个事务,但只建立了一个session,应该是一个session(会话)对应一个事务!
接分接分
up
支持