IDEMPIERE-568 Review proper closing of JDBC statements and resultsets
This commit is contained in:
parent
3eb6bc9151
commit
c2941041fe
|
@ -129,30 +129,23 @@ public class MTab extends X_AD_Tab
|
|||
String sql = "SELECT * FROM AD_Field WHERE AD_Tab_ID=? ORDER BY SeqNo";
|
||||
ArrayList<MField> list = new ArrayList<MField>();
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, trxName);
|
||||
pstmt.setInt (1, getAD_Tab_ID());
|
||||
ResultSet rs = pstmt.executeQuery ();
|
||||
rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
list.add (new MField (getCtx(), rs, trxName));
|
||||
rs.close ();
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
try
|
||||
finally
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
pstmt = null;
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
//
|
||||
m_fields = new MField[list.size ()];
|
||||
|
@ -191,22 +184,27 @@ public class MTab extends X_AD_Tab
|
|||
public static int getTab_ID(int AD_Window_ID , String TabName) {
|
||||
int retValue = 0;
|
||||
String SQL = "SELECT AD_Tab_ID FROM AD_Tab WHERE AD_Window_ID= ? AND Name = ?";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
|
||||
pstmt = DB.prepareStatement(SQL, null);
|
||||
pstmt.setInt(1, AD_Window_ID);
|
||||
pstmt.setString(2, TabName);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
retValue = rs.getInt(1);
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
s_log.log(Level.SEVERE, SQL, e);
|
||||
retValue = -1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
return retValue;
|
||||
}
|
||||
//end vpj-cd e-evolution
|
||||
|
|
Loading…
Reference in New Issue