FR [ 1841834 ] PrintFormatUtil: work in transaction
BF [ 1874419 ] JDBC Statement not close in a finally block - only for PrintFormatUtil.java
This commit is contained in:
parent
2c4be7b8bc
commit
002c1948c3
|
@ -41,7 +41,7 @@ public class MigrateData
|
||||||
|
|
||||||
// Update existing Print Format
|
// Update existing Print Format
|
||||||
PrintFormatUtil pfu = new PrintFormatUtil (Env.getCtx());
|
PrintFormatUtil pfu = new PrintFormatUtil (Env.getCtx());
|
||||||
pfu.addMissingColumns();
|
pfu.addMissingColumns((String)null);
|
||||||
} // MigrateData
|
} // MigrateData
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
|
|
|
@ -27,6 +27,9 @@ import org.compiere.util.*;
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: PrintFormatUtil.java,v 1.2 2006/07/30 00:53:02 jjanke Exp $
|
* @version $Id: PrintFormatUtil.java,v 1.2 2006/07/30 00:53:02 jjanke Exp $
|
||||||
|
*
|
||||||
|
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||||
|
* <li>FR [ 1841834 ] PrintFormatUtil: work in transaction
|
||||||
*/
|
*/
|
||||||
public class PrintFormatUtil
|
public class PrintFormatUtil
|
||||||
{
|
{
|
||||||
|
@ -47,37 +50,37 @@ public class PrintFormatUtil
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add Missing Columns for all Print Format
|
* @deprecated use {@link #addMissingColumns(String)}
|
||||||
*/
|
*/
|
||||||
public void addMissingColumns ()
|
public void addMissingColumns ()
|
||||||
|
{
|
||||||
|
addMissingColumns((String)null);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Add Missing Columns for all Print Format
|
||||||
|
*/
|
||||||
|
public void addMissingColumns (String trxName)
|
||||||
{
|
{
|
||||||
int total = 0;
|
int total = 0;
|
||||||
String sql = "SELECT * FROM AD_PrintFormat pf "
|
String sql = "SELECT * FROM AD_PrintFormat pf "
|
||||||
+ "ORDER BY Name";
|
+ "ORDER BY Name";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql, trxName);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
total += addMissingColumns(new MPrintFormat (m_ctx, rs, null));
|
total += addMissingColumns(new MPrintFormat (m_ctx, rs, 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;
|
|
||||||
}
|
}
|
||||||
log.info ("Total = " + total);
|
log.info ("Total = " + total);
|
||||||
} // addMissingColumns
|
} // addMissingColumns
|
||||||
|
@ -103,13 +106,14 @@ public class PrintFormatUtil
|
||||||
+ " AND c.AD_Table_ID=? " // 2
|
+ " AND c.AD_Table_ID=? " // 2
|
||||||
+ "ORDER BY 1";
|
+ "ORDER BY 1";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql, pf.get_TrxName());
|
||||||
pstmt.setInt(1, pf.getAD_PrintFormat_ID());
|
pstmt.setInt(1, pf.getAD_PrintFormat_ID());
|
||||||
pstmt.setInt(2, pf.getAD_Table_ID());
|
pstmt.setInt(2, pf.getAD_Table_ID());
|
||||||
ResultSet rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
int AD_Column_ID = rs.getInt(1);
|
int AD_Column_ID = rs.getInt(1);
|
||||||
|
@ -128,15 +132,10 @@ public class PrintFormatUtil
|
||||||
{
|
{
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
if (counter == 0)
|
if (counter == 0)
|
||||||
log.fine("None"
|
log.fine("None"
|
||||||
|
@ -161,7 +160,7 @@ public class PrintFormatUtil
|
||||||
org.compiere.Adempiere.startupEnvironment(true);
|
org.compiere.Adempiere.startupEnvironment(true);
|
||||||
//
|
//
|
||||||
PrintFormatUtil pfu = new PrintFormatUtil (Env.getCtx());
|
PrintFormatUtil pfu = new PrintFormatUtil (Env.getCtx());
|
||||||
pfu.addMissingColumns();
|
pfu.addMissingColumns((String)null);
|
||||||
} // main
|
} // main
|
||||||
|
|
||||||
} // PrintFormatUtils
|
} // PrintFormatUtils
|
||||||
|
|
Loading…
Reference in New Issue