BF [ 2444851 ] MLanguage should throw an exception if there is an error

https://sourceforge.net/tracker/index.php?func=detail&aid=2444851&group_id=176962&atid=879332

* improved DB access code
This commit is contained in:
teo_sarca 2008-12-18 10:27:44 +00:00
parent 16c31408a7
commit 891d7e071d
1 changed files with 13 additions and 12 deletions

View File

@ -39,9 +39,13 @@ import org.compiere.util.Msg;
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MLanguage.java,v 1.4 2006/07/30 00:58:36 jjanke Exp $ * @version $Id: MLanguage.java,v 1.4 2006/07/30 00:58:36 jjanke Exp $
*
* @author Teo Sarca, www.arhipac.ro
* <li>BF [ 2444851 ] MLanguage should throw an exception if there is an error
*/ */
public class MLanguage extends X_AD_Language public class MLanguage extends X_AD_Language
{ {
private static final long serialVersionUID = 1L;
/** /**
* Get Language Model from Language * Get Language Model from Language
@ -87,7 +91,9 @@ public class MLanguage extends X_AD_Language
*/ */
public static void maintain (Properties ctx) public static void maintain (Properties ctx)
{ {
List<MLanguage> list = new Query(ctx, Table_Name, "IsSystemLanguage='Y' AND IsBaseLanguage='N' AND IsActive='Y'", null) List<MLanguage> list = new Query(ctx, Table_Name, "IsSystemLanguage=? AND IsBaseLanguage=?", null)
.setParameters(new Object[]{true, false})
.setOnlyActiveRecords(true)
.list(); .list();
for (MLanguage language : list) { for (MLanguage language : list) {
language.maintain(true); language.maintain(true);
@ -336,9 +342,6 @@ public class MLanguage extends X_AD_Language
else else
retNo += deleteTable (rs.getString(1)); retNo += deleteTable (rs.getString(1));
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (SQLException e) catch (SQLException e)
{ {
@ -359,9 +362,8 @@ public class MLanguage extends X_AD_Language
*/ */
private int deleteTable (String tableName) private int deleteTable (String tableName)
{ {
String sql = "DELETE FROM " + tableName String sql = "DELETE FROM "+tableName+" WHERE AD_Language=?";
+ " WHERE AD_Language='" + getAD_Language() + "'"; int no = DB.executeUpdateEx(sql, new Object[]{getAD_Language()}, get_TrxName());
int no = DB.executeUpdate(sql, get_TrxName());
log.fine(tableName + " #" + no); log.fine(tableName + " #" + no);
return no; return no;
} // deleteTable } // deleteTable
@ -389,10 +391,9 @@ public class MLanguage extends X_AD_Language
pstmt.setString(1, baseTable); pstmt.setString(1, baseTable);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{
columns.add(rs.getString(1)); columns.add(rs.getString(1));
rs.close(); }
pstmt.close();
pstmt = null;
} }
catch (SQLException e) catch (SQLException e)
{ {
@ -429,7 +430,7 @@ public class MLanguage extends X_AD_Language
+ " WHERE AD_Language='" + getAD_Language() + "')"; + " WHERE AD_Language='" + getAD_Language() + "')";
// + " WHERE (" + keyColumn + ",'" + getAD_Language()+ "') NOT IN (SELECT " // + " WHERE (" + keyColumn + ",'" + getAD_Language()+ "') NOT IN (SELECT "
// + keyColumn + ",AD_Language FROM " + tableName + ")"; // + keyColumn + ",AD_Language FROM " + tableName + ")";
int no = DB.executeUpdate(insert, get_TrxName()); int no = DB.executeUpdateEx(insert, null, get_TrxName());
log.fine(tableName + " #" + no); log.fine(tableName + " #" + no);
return no; return no;
} // addTable } // addTable