You can't operate on a closed Statement!!!
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!!!