You can't operate on a closed Statement!!!

果果_123 2013-02-25 05:02:42
private static final String QUERY_PROCESS ="select * from t_wf_process where uuid =?";
@Override
public ProcessEntity getProcessEntity(String processUUID)throws SQLException {
ProcessEntity processEntity = null;
try {
connection = this.commonJDBC.getConnection();
ps = connection.prepareStatement(QUERY_PROCESS);
ps.setString(1, processUUID);
rs = ps.executeQuery();
if (rs.next()) {
processEntity = WFEngineConstant.fillProcessEntity(rs);
} else {
processEntity = null;
}
} catch (SQLException e) {
logger.info("getProcessEntity出现异常", e);
} finally {
this.commonJDBC.cleanUp(connection, ps, rs); // 释放资源
}
// 返回流程实例对象
return processEntity;
}
//获取连接*************
/**
* 获取Connection
*/
public Connection getConnection(){
Connection connection = this.template.getConnection();
try {
if (connection.isClosed()) {
connection = SqlSessionUtils.getSqlSession(
this.template.getSqlSessionFactory(),
this.template.getExecutorType(),
this.template.getPersistenceExceptionTranslator())
.getConnection();
}
} catch (Exception e) {
e.printStackTrace();
}
return connection;
}

//关闭********

/**
* 关闭Connection,PreparedStatement,ResultSet
*/
public void cleanUp(Connection c,PreparedStatement ps,ResultSet rs){
this.closeResultSet(rs);
this.closePreparedStatement(ps);
this.closeConnection(c);

}
/**
* 关闭Connection
*/
public void closeConnection(Connection c){
try {
if (c != null) {
c.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* 关闭PreparedStatement
*/
public void closePreparedStatement(PreparedStatement ps){
try {
if (ps != null) {
ps.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* 关闭ResultSet
*/
public void closeResultSet(ResultSet rs){
try {
if (rs != null) {
rs.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
使用的是c3p0 注入template 模板得到连接的
有时候抛出如下的错。。。但是有时候又没有这样的错。。。是什么原因。。

抛出getProcessEntity出现异常!
You can't operate on a closed Statement!!!
...全文
1255 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
haiking5253 2014-11-12
  • 打赏
  • 举报
回复
同样遇到这个问题,请问有谁解决了这个问题了吗?
果果_123 2014-09-11
  • 打赏
  • 举报
回复
引用 1 楼 ycdx2001 的回复:
我之前也是和你一样 你现在解决了吗 ?
sulanyan29 2014-06-23
  • 打赏
  • 举报
回复
楼主也是用的MYSQL数据库与C3P0吧? 这问题有点莫名其秒的感觉,明明程序中处理有有条有理的,连接也是在finally中关闭的,就是偶尔会报这错。
sulanyan29 2014-06-23
  • 打赏
  • 举报
回复
顶一个
SiriBen 2013-12-04
  • 打赏
  • 举报
回复
我也遇到这样的问题,我更狗血的是,我这个问题只出现在后台管理页,用户前台页一直刷新都没问题,只有后台才会报这异常,随机性的。我也找了好久这个解决办法,也没解决
Lakers8888 2013-02-26
  • 打赏
  • 举报
回复

10,606

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 其他
社区管理员
  • 其他
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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