proxool连接池报错问题You can't perform any operations on this connection

夏天之大 2014-10-27 03:05:06
连接池配置:
    <test-before-use>true</test-before-use>
<test-after-use>true</test-after-use>
<house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql>
<house-keeping-sleep-time>500</house-keeping-sleep-time>
<simultaneous-build-throttle>2</simultaneous-build-throttle>
<maximum-connection-count>20</maximum-connection-count>
<minimum-connection-count>5</minimum-connection-count>
<prototype-count>5</prototype-count>
<maximum-connection-lifetime>180000000</maximum-connection-lifetime>
<maximum-active-time>172800000</maximum-active-time>


数据库操作类:

private static File datafile = new File(ConfigPath.Hiberconfig);
private static Configuration config = new Configuration().configure(datafile);
private static SessionFactory factory = config.buildSessionFactory();
public autoOperate(){}
//插入数据
public void insert(Comments2 user) {
this.session = factory.getCurrentSession();
session.getTransaction().begin();
this.session.save(user);
session.getTransaction().commit();

}
//删除记录
public void delete(String DEAL_ID){
//try{
this.session = factory.getCurrentSession();
String hql="delete Comments2 where DEAL_ID=?";
session.getTransaction().begin();
Query q=this.session.createQuery(hql);
q.setString(0, DEAL_ID);
q.executeUpdate();
session.getTransaction().commit();
// }
//finally{
// session.close();
//}
}
//更新纪录,先删除再插入
public void deleteinsert(Comments2 user){
this.session = factory.getCurrentSession();
String DEAL_ID=user.getDeal_id();
String hql="delete Comments2 where DEAL_ID=?";//delete
session.getTransaction().begin();
Query q=this.session.createQuery(hql);
q.setString(0, DEAL_ID);
q.executeUpdate();
session.getTransaction().commit();
insert(user);

}

//按数据是否存在
public boolean queryByAll(String DEAL_ID){
this.session = factory.getCurrentSession();
session.getTransaction().begin();
String hql = "from Comments2 b where b.deal_id=?";
Query query = this.session.createQuery(hql);
query.setString(0, DEAL_ID);
//Long count = (Long)query.uniqueResult();
List list=query.list();
//session.getTransaction().commit();
return list.size()>0?true:false;
}


主要功能:每天定时去执行一些增删改的操作,第一天运行正常,第二天就大面积的报错如下
2014-10-26 04:00:00 [ org.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:78):org.hibernate.util.JDBCExceptionReporter:DefaultQuartzScheduler_Worker-8:997827015 ] - [ ERROR ] Couldn't perform the operation prepareStatement: You can't perform any operations on this connection. It has been automatically closed by Proxool for some reason (see logs).
2014-10-26 04:00:00 [ service.autoSourceHandle.clearfile(autoSourceHandle.java:38):service.autoXMLHandle:DefaultQuartzScheduler_Worker-8:997827016 ] - [ ERROR ] 每天实体文件夹清理失败!
org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2214)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
at org.hibernate.loader.Loader.list(Loader.java:2090)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:388)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at Dao.autoOperate.queryByAll(autoOperate.java:106)
at service.autoSourceHandle.clearfile(autoSourceHandle.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:273)
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:272)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)
Caused by: java.sql.SQLException: Couldn't perform the operation prepareStatement: You can't perform any operations on this connection. It has been automatically closed by Proxool for some reason (see logs).
at org.logicalcobwebs.proxool.WrappedConnection.invoke(WrappedConnection.java:207)
at org.logicalcobwebs.proxool.WrappedConnection.intercept(WrappedConnection.java:87)
at $java.sql.Connection$$EnhancerByProxool$$e80c2491.prepareStatement(<generated>)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:497)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:415)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1538)
at org.hibernate.loader.Loader.doQuery(Loader.java:661)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2211)

求高手帮忙解答
...全文
765 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

50,549

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧