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

This commit is contained in:
teo_sarca 2008-01-24 10:28:23 +00:00
parent 920c5f51ea
commit 51f916f51c
1 changed files with 11 additions and 23 deletions

View File

@ -148,23 +148,27 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem
m_translationLabel = new HashMap<String,String>(); m_translationLabel = new HashMap<String,String>();
m_translationSuffix = new HashMap<String,String>(); m_translationSuffix = new HashMap<String,String>();
String sql = "SELECT AD_Language, PrintName, PrintNameSuffix FROM AD_PrintFormatItem_Trl WHERE AD_PrintFormatItem_ID=?"; String sql = "SELECT AD_Language, PrintName, PrintNameSuffix FROM AD_PrintFormatItem_Trl WHERE AD_PrintFormatItem_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, get_ID()); pstmt.setInt(1, get_ID());
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
m_translationLabel.put (rs.getString (1), rs.getString (2)); m_translationLabel.put (rs.getString (1), rs.getString (2));
m_translationSuffix.put (rs.getString (1), rs.getString (3)); m_translationSuffix.put (rs.getString (1), rs.getString (3));
} }
rs.close();
pstmt.close();
} }
catch (SQLException e) catch (SQLException e)
{ {
log.log(Level.SEVERE, "loadTrl", e); log.log(Level.SEVERE, "loadTrl", e);
} }
finally {
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
} }
} // loadTranslations } // loadTranslations
@ -391,25 +395,9 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem
if (retValue == null) if (retValue == null)
{ {
String sql = "SELECT ColumnName FROM AD_Column WHERE AD_Column_ID=?"; String sql = "SELECT ColumnName FROM AD_Column WHERE AD_Column_ID=?";
try retValue = DB.getSQLValueString(null, sql, AD_Column_ID.intValue());
{ if (retValue != null)
PreparedStatement pstmt = DB.prepareStatement(sql, null); s_columns.put(AD_Column_ID, retValue);
pstmt.setInt(1, AD_Column_ID.intValue());
ResultSet rs = pstmt.executeQuery();
if (rs.next())
{
retValue = rs.getString(1);
s_columns.put(AD_Column_ID, retValue);
}
else
s_log.log(Level.SEVERE, "Not found AD_Column_ID=" + AD_Column_ID);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
s_log.log(Level.SEVERE, "AD_Column_ID=" + AD_Column_ID, e);
}
} }
return retValue; return retValue;
} // getColumnName } // getColumnName