postgresql - Database connection closed automatically -
i using postgres database.sometimes connection closed automatically while interacting application.sometimes not interacting application sitting ideal @ time connection closed.it shows follwing excepion.my server log
severe [org.activiti.engine.impl.jobexecutor.acquirejobsrunnable] (thread-101) exception during job acquisition: error querying database. cause: org.postgresql.util.psqlexception: connection has been closed. error may exist in org/activiti/db/mapping/entity/job.xml error may involve org.activiti.engine.impl.persistence.entity.jobentity.selectnextjobstoexecute error occurred while executing query sql: select res.* act_ru_job res left outer join act_ru_execution pi on pi.id_ = res.process_instance_id_ (res.retr ies_ > 0) , (res.duedate_ null or res.duedate_ < ?) , (res.lock_owner_ null or res.lock_exp_time_ < ?) , ( (res.execution_id_ null) or (pi.suspension_state_ = 1) ) limit ? offset ? cause: org.postgresql.util.psqlexception: connection has been closed.: org.apache.ibatis.exceptions.persistenceexception: error querying database. cause: org.postgresql.util.psqlexception: connection has been closed. error may exist in org/activiti/db/mapping/entity/job.xml error may involve org.activiti.engine.impl.persistence.entity.jobentity.selectnextjobstoexecute
the error occurred while executing query
sql: select res.* act_ru_job res left outer join act_ru_execution pi on pi.id_ = res.process_instance_id_ (res.retr ies_ > 0) , (res.duedate_ null or res.duedate_ < ?) , (res.lock_owner_ null or res.lock_exp_time_ < ?) , ( (res.execution_id_ null) or (pi.suspension_state_ = 1) ) limit ? offset ? cause: org.postgresql.util.psqlexception: connection has been closed. @ org.apache.ibatis.exceptions.exceptionfactory.wrapexception(exceptionfactory.java:23) [mybatis-3.1.1.jar:3.1.1] @ org.apache.ibatis.session.defaults.defaultsqlsession.selectlist(defaultsqlsession.java:104) [mybatis-3.1.1.jar:3.1.1] @ org.apache.ibatis.session.defaults.defaultsqlsession.selectlist(defaultsqlsession.java:95) [mybatis-3.1.1.jar:3.1.1] @ org.activiti.engine.impl.db.dbsqlsession.selectlistwithrawparameter(dbsqlsession.java:301) [activiti-engine-5.11.jar:5.11] @ org.activiti.engine.impl.db.dbsqlsession.selectlist(dbsqlsession.java:292) [activiti-engine-5.11.jar:5.11] @ org.activiti.engine.impl.db.dbsqlsession.selectlist(dbsqlsession.java:287) [activiti-engine-5.11.jar:5.11] @ org.activiti.engine.impl.db.dbsqlsession.selectlist(dbsqlsession.java:274) [activiti-engine-5.11.jar:5.11] @ org.activiti.engine.impl.persistence.entity.jobmanager.findnextjobstoexecute(jobmanager.java:105) [activiti-engine-5.11.jar:5.11] @ org.activiti.engine.impl.cmd.acquirejobscmd.execute(acquirejobscmd.java:50) [activiti-engine-5.11.jar:5.11] @ org.activiti.engine.impl.cmd.acquirejobscmd.execute(acquirejobscmd.java:33) [activiti-engine-5.11.jar:5.11] @ org.activiti.engine.impl.interceptor.commandexecutorimpl.execute(commandexecutorimpl.java:24) [activiti-engine-5.11.jar:5.11] @ org.activiti.engine.impl.interceptor.commandcontextinterceptor.execute(commandcontextinterceptor.java:60) [activiti-engine-5.11.jar:5.11] @ org.activiti.engine.impl.interceptor.loginterceptor.execute(loginterceptor.java:32) [activiti-engine-5.11.jar:5.11] @ org.activiti.engine.impl.jobexecutor.acquirejobsrunnable.run(acquirejobsrunnable.java:61) [activiti-engine-5.11.jar:5.11] @ java.lang.thread.run(thread.java:662) [rt.jar:1.6.0_32] caused by: org.postgresql.util.psqlexception: connection has been closed. @ org.postgresql.jdbc2.abstractjdbc2connection.checkclosed(abstractjdbc2connection.java:714) @ org.postgresql.jdbc3.abstractjdbc3connection.preparestatement(abstractjdbc3connection.java:274) @ org.jboss.jca.adapters.jdbc.basewrappermanagedconnection.dopreparestatement(basewrappermanagedconnection.java:677) @ org.jboss.jca.adapters.jdbc.basewrappermanagedconnection.preparestatement(basewrappermanagedconnection.java:663) @ org.jboss.jca.adapters.jdbc.wrappedconnection.preparestatement(wrappedconnection.java:404) @ org.apache.ibatis.executor.statement.preparedstatementhandler.instantiatestatement(preparedstatementhandler.java:72) [mybatis-3.1.1.jar:3.1.1] @ org.apache.ibatis.executor.statement.basestatementhandler.prepare(basestatementhandler.java:82) [mybatis-3.1.1.jar:3.1.1] @ org.apache.ibatis.executor.statement.routingstatementhandler.prepare(routingstatementhandler.java:54) [mybatis-3.1.1.jar:3.1.1] @ org.apache.ibatis.executor.simpleexecutor.preparestatement(simpleexecutor.java:70) [mybatis-3.1.1.jar:3.1.1] @ org.apache.ibatis.executor.simpleexecutor.doquery(simpleexecutor.java:56) [mybatis-3.1.1.jar:3.1.1] @ org.apache.ibatis.executor.baseexecutor.queryfromdatabase(baseexecutor.java:267) [mybatis-3.1.1.jar:3.1.1] @ org.apache.ibatis.executor.baseexecutor.query(baseexecutor.java:141) [mybatis-3.1.1.jar:3.1.1] @ org.apache.ibatis.executor.cachingexecutor.query(cachingexecutor.java:105) [mybatis-3.1.1.jar:3.1.1] @ org.apache.ibatis.executor.cachingexecutor.query(cachingexecutor.java:81) [mybatis-3.1.1.jar:3.1.1] @ org.apache.ibatis.session.defaults.defaultsqlsession.selectlist(defaultsqlsession.java:101) [mybatis-3.1.1.jar:3.1.1] ... 13 more
i have had similar problem using php. cause of problem was nesting connections. outer connection returned being closed after inner connection had returned data. solution simple: process both connection serially, meant in case first executed inner connection , afterwards original outer connection.
symbolically:
try{ firstconnection = createconnection(); results = firstconnection.query(...); if results == true secondconnection = createconnection(); resultstoo = secondconnection.query(); if resultstoo == true processresults(resultstoo); closeconnection(); end if; processresults(results); closeconnection(); end if; exceptionhandling();
processing second connection before first connection solved issue.
Comments
Post a Comment