BF [ 1874419 ] JDBC Statement not close in a finally block - fixed for org.compiere.model.MGoal
This commit is contained in:
parent
65bb91b9e5
commit
2cd9802c0f
|
|
@ -52,35 +52,28 @@ public class MGoal extends X_PA_Goal
|
||||||
+ "WHERE g.AD_User_ID=ur.AD_User_ID AND g.AD_Role_ID=ur.AD_Role_ID AND ur.IsActive='Y')) "
|
+ "WHERE g.AD_User_ID=ur.AD_User_ID AND g.AD_Role_ID=ur.AD_Role_ID AND ur.IsActive='Y')) "
|
||||||
+ "ORDER BY SeqNo";
|
+ "ORDER BY SeqNo";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, null);
|
pstmt = DB.prepareStatement (sql, null);
|
||||||
pstmt.setInt (1, Env.getAD_Client_ID(ctx));
|
pstmt.setInt (1, Env.getAD_Client_ID(ctx));
|
||||||
pstmt.setInt (2, AD_User_ID);
|
pstmt.setInt (2, AD_User_ID);
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
while (rs.next ())
|
while (rs.next ())
|
||||||
{
|
{
|
||||||
MGoal goal = new MGoal (ctx, rs, null);
|
MGoal goal = new MGoal (ctx, rs, null);
|
||||||
goal.updateGoal(false);
|
goal.updateGoal(false);
|
||||||
list.add (goal);
|
list.add (goal);
|
||||||
}
|
}
|
||||||
rs.close ();
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
s_log.log (Level.SEVERE, sql, e);
|
s_log.log (Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
try
|
finally
|
||||||
{
|
{
|
||||||
if (pstmt != null)
|
DB.close(rs, pstmt);
|
||||||
pstmt.close ();
|
rs = null; pstmt = null;
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
MGoal[] retValue = new MGoal[list.size ()];
|
MGoal[] retValue = new MGoal[list.size ()];
|
||||||
list.toArray (retValue);
|
list.toArray (retValue);
|
||||||
|
|
@ -100,33 +93,26 @@ public class MGoal extends X_PA_Goal
|
||||||
sql = MRole.getDefault(ctx, false).addAccessSQL(sql, "PA_Goal",
|
sql = MRole.getDefault(ctx, false).addAccessSQL(sql, "PA_Goal",
|
||||||
false, true); // RW to restrict Access
|
false, true); // RW to restrict Access
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, null);
|
pstmt = DB.prepareStatement (sql, null);
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
while (rs.next ())
|
while (rs.next ())
|
||||||
{
|
{
|
||||||
MGoal goal = new MGoal (ctx, rs, null);
|
MGoal goal = new MGoal (ctx, rs, null);
|
||||||
goal.updateGoal(false);
|
goal.updateGoal(false);
|
||||||
list.add (goal);
|
list.add (goal);
|
||||||
}
|
}
|
||||||
rs.close ();
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
s_log.log (Level.SEVERE, sql, e);
|
s_log.log (Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
try
|
finally
|
||||||
{
|
{
|
||||||
if (pstmt != null)
|
DB.close(rs, pstmt);
|
||||||
pstmt.close ();
|
rs = null; pstmt = null;
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
MGoal[] retValue = new MGoal[list.size ()];
|
MGoal[] retValue = new MGoal[list.size ()];
|
||||||
list.toArray (retValue);
|
list.toArray (retValue);
|
||||||
|
|
@ -165,30 +151,23 @@ public class MGoal extends X_PA_Goal
|
||||||
String sql = "SELECT * FROM PA_Goal WHERE IsActive='Y' AND PA_Measure_ID=? "
|
String sql = "SELECT * FROM PA_Goal WHERE IsActive='Y' AND PA_Measure_ID=? "
|
||||||
+ "ORDER BY SeqNo";
|
+ "ORDER BY SeqNo";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, null);
|
pstmt = DB.prepareStatement (sql, null);
|
||||||
pstmt.setInt (1, PA_Measure_ID);
|
pstmt.setInt (1, PA_Measure_ID);
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
while (rs.next ())
|
while (rs.next ())
|
||||||
list.add (new MGoal (ctx, rs, null));
|
list.add (new MGoal (ctx, rs, null));
|
||||||
rs.close ();
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
s_log.log (Level.SEVERE, sql, e);
|
s_log.log (Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
try
|
finally
|
||||||
{
|
{
|
||||||
if (pstmt != null)
|
DB.close(rs, pstmt);
|
||||||
pstmt.close ();
|
rs = null; pstmt = null;
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
MGoal[] retValue = new MGoal[list.size ()];
|
MGoal[] retValue = new MGoal[list.size ()];
|
||||||
list.toArray (retValue);
|
list.toArray (retValue);
|
||||||
|
|
@ -347,30 +326,23 @@ public class MGoal extends X_PA_Goal
|
||||||
+ "WHERE PA_Goal_ID=? AND IsActive='Y' "
|
+ "WHERE PA_Goal_ID=? AND IsActive='Y' "
|
||||||
+ "ORDER BY Org_ID, C_BPartner_ID, M_Product_ID";
|
+ "ORDER BY Org_ID, C_BPartner_ID, M_Product_ID";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, get_TrxName());
|
pstmt = DB.prepareStatement (sql, get_TrxName());
|
||||||
pstmt.setInt (1, getPA_Goal_ID());
|
pstmt.setInt (1, getPA_Goal_ID());
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
while (rs.next ())
|
while (rs.next ())
|
||||||
list.add (new MGoalRestriction (getCtx(), rs, get_TrxName()));
|
list.add (new MGoalRestriction (getCtx(), rs, get_TrxName()));
|
||||||
rs.close ();
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log (Level.SEVERE, sql, e);
|
log.log (Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
try
|
finally
|
||||||
{
|
{
|
||||||
if (pstmt != null)
|
DB.close(rs, pstmt);
|
||||||
pstmt.close ();
|
rs = null; pstmt = null;
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
m_restrictions = new MGoalRestriction[list.size ()];
|
m_restrictions = new MGoalRestriction[list.size ()];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue