* Ensure proper release of database cursor
This commit is contained in:
parent
58459b1de2
commit
e8b2863868
|
@ -93,6 +93,7 @@ public class CCachedRowSet extends CachedRowSetImpl implements CachedRowSet
|
||||||
ResultSet rs = stmt.executeQuery(sql);
|
ResultSet rs = stmt.executeQuery(sql);
|
||||||
OracleCachedRowSet crs = new OracleCachedRowSet();
|
OracleCachedRowSet crs = new OracleCachedRowSet();
|
||||||
crs.populate(rs);
|
crs.populate(rs);
|
||||||
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
return crs;
|
return crs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,9 +134,9 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
||||||
}
|
}
|
||||||
// Try locally
|
// Try locally
|
||||||
log.warning("Execute locally");
|
log.warning("Execute locally");
|
||||||
PreparedStatement pstmt = local_getPreparedStatement (false, null); // shared connection
|
p_stmt = local_getPreparedStatement (false, null); // shared connection
|
||||||
p_vo.clearParameters(); // re-use of result set
|
p_vo.clearParameters(); // re-use of result set
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = ((PreparedStatement)p_stmt).executeQuery();
|
||||||
return rs;
|
return rs;
|
||||||
} // executeQuery
|
} // executeQuery
|
||||||
|
|
||||||
|
@ -191,9 +191,9 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
||||||
}
|
}
|
||||||
// Try locally
|
// Try locally
|
||||||
log.warning("execute locally");
|
log.warning("execute locally");
|
||||||
PreparedStatement pstmt = local_getPreparedStatement (false, null); // shared connection
|
p_stmt = local_getPreparedStatement (false, null); // shared connection
|
||||||
p_vo.clearParameters(); // re-use of result set
|
p_vo.clearParameters(); // re-use of result set
|
||||||
return pstmt.executeUpdate();
|
return ((PreparedStatement)p_stmt).executeUpdate();
|
||||||
} // executeUpdate
|
} // executeUpdate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -908,6 +908,7 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
||||||
//
|
//
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
rowSet = CCachedRowSet.getRowSet(rs);
|
rowSet = CCachedRowSet.getRowSet(rs);
|
||||||
|
rs.close();
|
||||||
pstmt.close();
|
pstmt.close();
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
conn.close();
|
conn.close();
|
||||||
|
@ -1023,6 +1024,8 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
||||||
rowSet = CCachedRowSet.getRowSet(rs);
|
rowSet = CCachedRowSet.getRowSet(rs);
|
||||||
pstmt.close();
|
pstmt.close();
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
|
rs.close();
|
||||||
|
rs = null;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -1050,15 +1053,15 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
||||||
public int remote_executeUpdate()
|
public int remote_executeUpdate()
|
||||||
{
|
{
|
||||||
log.finest("Update");
|
log.finest("Update");
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AdempiereDatabase db = CConnection.get().getDatabase();
|
AdempiereDatabase db = CConnection.get().getDatabase();
|
||||||
if (db == null)
|
if (db == null)
|
||||||
throw new NullPointerException("Remote - No Database");
|
throw new NullPointerException("Remote - No Database");
|
||||||
//
|
//
|
||||||
PreparedStatement pstmt = local_getPreparedStatement (false, p_vo.getTrxName());
|
pstmt = local_getPreparedStatement (false, p_vo.getTrxName());
|
||||||
int result = pstmt.executeUpdate();
|
int result = pstmt.executeUpdate();
|
||||||
pstmt.close();
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1067,6 +1070,14 @@ public class CPreparedStatement extends CStatement implements PreparedStatement
|
||||||
log.log(Level.SEVERE, p_vo.toString(), ex);
|
log.log(Level.SEVERE, p_vo.toString(), ex);
|
||||||
throw new RuntimeException (ex);
|
throw new RuntimeException (ex);
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
if (pstmt != null) {
|
||||||
|
try {
|
||||||
|
pstmt.close();
|
||||||
|
} catch (SQLException e) {}
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
} // remote_executeUpdate
|
} // remote_executeUpdate
|
||||||
|
|
||||||
//remove this commnet if you want use JAVA 6
|
//remove this commnet if you want use JAVA 6
|
||||||
|
|
|
@ -145,8 +145,8 @@ public class CStatement implements Statement
|
||||||
}
|
}
|
||||||
// Try locally
|
// Try locally
|
||||||
log.warning("execute locally");
|
log.warning("execute locally");
|
||||||
Statement stmt = local_getStatement (false, null); // shared connection
|
p_stmt = local_getStatement (false, null); // shared connection
|
||||||
return stmt.executeQuery(p_vo.getSql());
|
return p_stmt.executeQuery(p_vo.getSql());
|
||||||
} // executeQuery
|
} // executeQuery
|
||||||
|
|
||||||
|
|
||||||
|
@ -191,8 +191,8 @@ public class CStatement implements Statement
|
||||||
}
|
}
|
||||||
// Try locally
|
// Try locally
|
||||||
log.warning("execute locally");
|
log.warning("execute locally");
|
||||||
Statement pstmt = local_getStatement (false, null); // shared connection
|
p_stmt = local_getStatement (false, null); // shared connection
|
||||||
return pstmt.executeUpdate(p_vo.getSql());
|
return p_stmt.executeUpdate(p_vo.getSql());
|
||||||
} // executeUpdate
|
} // executeUpdate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -717,15 +717,15 @@ public class CStatement implements Statement
|
||||||
public int remote_executeUpdate()
|
public int remote_executeUpdate()
|
||||||
{
|
{
|
||||||
log.finest("");
|
log.finest("");
|
||||||
|
Statement pstmt = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AdempiereDatabase db = CConnection.get().getDatabase();
|
AdempiereDatabase db = CConnection.get().getDatabase();
|
||||||
if (db == null)
|
if (db == null)
|
||||||
throw new NullPointerException("Remote - No Database");
|
throw new NullPointerException("Remote - No Database");
|
||||||
//
|
//
|
||||||
Statement pstmt = local_getStatement (false, p_vo.getTrxName());
|
pstmt = local_getStatement (false, p_vo.getTrxName());
|
||||||
int result = pstmt.executeUpdate(p_vo.getSql());
|
int result = pstmt.executeUpdate(p_vo.getSql());
|
||||||
pstmt.close();
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -733,6 +733,16 @@ public class CStatement implements Statement
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, p_vo.toString(), ex);
|
log.log(Level.SEVERE, p_vo.toString(), ex);
|
||||||
throw new RuntimeException (ex);
|
throw new RuntimeException (ex);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (pstmt != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pstmt.close();
|
||||||
|
} catch (SQLException e){}
|
||||||
|
pstmt = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // remote_executeUpdate
|
} // remote_executeUpdate
|
||||||
|
|
||||||
|
@ -884,6 +894,7 @@ public class CStatement implements Statement
|
||||||
//
|
//
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
rowSet = CCachedRowSet.getRowSet(rs);
|
rowSet = CCachedRowSet.getRowSet(rs);
|
||||||
|
rs.close();
|
||||||
pstmt.close();
|
pstmt.close();
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue