*BF [ 1874419 ] JDBC Statement not close in a finally block

*Organize imports
This commit is contained in:
Redhuan D. Oon 2008-02-08 19:25:19 +00:00
parent a35c729673
commit 4aa01e3459
1 changed files with 9 additions and 24 deletions

View File

@ -43,30 +43,23 @@ public class MAsset extends X_A_Asset
MAsset retValue = null; MAsset retValue = null;
String sql = "SELECT * FROM A_Asset WHERE M_InOutLine_ID=?"; String sql = "SELECT * FROM A_Asset WHERE M_InOutLine_ID=?";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement (sql, trxName); pstmt = DB.prepareStatement (sql, trxName);
pstmt.setInt (1, M_InOutLine_ID); pstmt.setInt (1, M_InOutLine_ID);
ResultSet rs = pstmt.executeQuery (); rs = pstmt.executeQuery ();
if (rs.next ()) if (rs.next ())
retValue = new MAsset (ctx, rs, trxName); retValue = new MAsset (ctx, rs, trxName);
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;
} }
return retValue; return retValue;
} // getFromShipment } // getFromShipment
@ -260,16 +253,14 @@ public class MAsset extends X_A_Asset
String sql = "SELECT * FROM A_Asset_Delivery WHERE A_Asset_ID=? ORDER BY Created DESC"; String sql = "SELECT * FROM A_Asset_Delivery WHERE A_Asset_ID=? ORDER BY Created DESC";
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, getA_Asset_ID()); pstmt.setInt(1, getA_Asset_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
list.add(new MAssetDelivery(getCtx(), rs, get_TrxName())); list.add(new MAssetDelivery(getCtx(), rs, get_TrxName()));
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
@ -277,14 +268,8 @@ public class MAsset extends X_A_Asset
} }
finally finally
{ {
try DB.close(rs, pstmt);
{ rs = null; pstmt = null;
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null;
} }
// //
MAssetDelivery[] retValue = new MAssetDelivery[list.size()]; MAssetDelivery[] retValue = new MAssetDelivery[list.size()];