org.compiere.model.PO:
* BF [ 1874419 ] JDBC Statement not close in a finally block * minor - PO.get_xmlString - was exporting xml without indentation
This commit is contained in:
parent
ad34029418
commit
23c4031415
|
@ -1175,6 +1175,7 @@ public abstract class PO
|
||||||
if (CLogMgt.isLevelFinest())
|
if (CLogMgt.isLevelFinest())
|
||||||
log.finest(get_WhereClause(true));
|
log.finest(get_WhereClause(true));
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql.toString(), m_trxName); // local trx only
|
pstmt = DB.prepareStatement(sql.toString(), m_trxName); // local trx only
|
||||||
|
@ -1186,7 +1187,7 @@ public abstract class PO
|
||||||
else
|
else
|
||||||
pstmt.setString(i+1, m_IDs[i].toString());
|
pstmt.setString(i+1, m_IDs[i].toString());
|
||||||
}
|
}
|
||||||
ResultSet rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
{
|
{
|
||||||
success = load(rs);
|
success = load(rs);
|
||||||
|
@ -1198,9 +1199,6 @@ public abstract class PO
|
||||||
success = false;
|
success = false;
|
||||||
// throw new DBException("NO Data found for " + get_WhereClause(true));
|
// throw new DBException("NO Data found for " + get_WhereClause(true));
|
||||||
}
|
}
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
pstmt = null;
|
|
||||||
m_createNew = false;
|
m_createNew = false;
|
||||||
// reset new values
|
// reset new values
|
||||||
m_newValues = new Object[size];
|
m_newValues = new Object[size];
|
||||||
|
@ -1221,14 +1219,9 @@ public abstract class PO
|
||||||
// throw new DBException(e);
|
// throw new DBException(e);
|
||||||
}
|
}
|
||||||
// Finish
|
// Finish
|
||||||
try
|
finally {
|
||||||
{
|
DB.close(rs, pstmt);
|
||||||
if (pstmt != null)
|
rs = null; pstmt = null;
|
||||||
pstmt.close();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (SQLException e1)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
loadComplete(success);
|
loadComplete(success);
|
||||||
return success;
|
return success;
|
||||||
|
@ -1746,31 +1739,23 @@ public abstract class PO
|
||||||
.append(m_KeyColumns[0]).append("=?")
|
.append(m_KeyColumns[0]).append("=?")
|
||||||
.append(" AND AD_Language=?");
|
.append(" AND AD_Language=?");
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
|
pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
|
||||||
pstmt.setInt (1, ID);
|
pstmt.setInt (1, ID);
|
||||||
pstmt.setString (2, AD_Language);
|
pstmt.setString (2, AD_Language);
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
if (rs.next ())
|
if (rs.next ())
|
||||||
retValue = rs.getString(1);
|
retValue = rs.getString(1);
|
||||||
rs.close ();
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql.toString(), e);
|
log.log(Level.SEVERE, sql.toString(), e);
|
||||||
}
|
}
|
||||||
try
|
finally {
|
||||||
{
|
DB.close(rs, pstmt);
|
||||||
if (pstmt != null)
|
rs = null; pstmt = null;
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
return retValue;
|
return retValue;
|
||||||
} // get_Translation
|
} // get_Translation
|
||||||
|
@ -2898,30 +2883,22 @@ public abstract class PO
|
||||||
+ "FROM AD_Column c INNER JOIN AD_Table t ON (c.AD_Table_ID=t.AD_Table_ID) "
|
+ "FROM AD_Column c INNER JOIN AD_Table t ON (c.AD_Table_ID=t.AD_Table_ID) "
|
||||||
+ "WHERE t.TableName=? AND c.IsActive='Y' AND c.AD_Reference_ID=25 ORDER BY 1";
|
+ "WHERE t.TableName=? AND c.IsActive='Y' AND c.AD_Reference_ID=25 ORDER BY 1";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, null);
|
pstmt = DB.prepareStatement (sql, null);
|
||||||
pstmt.setString (1, acctTable);
|
pstmt.setString (1, acctTable);
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
while (rs.next ())
|
while (rs.next ())
|
||||||
s_acctColumns.add (rs.getString(1));
|
s_acctColumns.add (rs.getString(1));
|
||||||
rs.close ();
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, acctTable, e);
|
log.log(Level.SEVERE, acctTable, e);
|
||||||
}
|
}
|
||||||
try
|
finally {
|
||||||
{
|
DB.close(rs, pstmt);
|
||||||
if (pstmt != null)
|
rs = null; pstmt = null;
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
if (s_acctColumns.size() == 0)
|
if (s_acctColumns.size() == 0)
|
||||||
{
|
{
|
||||||
|
@ -3270,20 +3247,24 @@ public abstract class PO
|
||||||
sql.append(TableName).append("_ID FROM ").append(TableName);
|
sql.append(TableName).append("_ID FROM ").append(TableName);
|
||||||
if (WhereClause != null && WhereClause.length() > 0)
|
if (WhereClause != null && WhereClause.length() > 0)
|
||||||
sql.append(" WHERE ").append(WhereClause);
|
sql.append(" WHERE ").append(WhereClause);
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), trxName);
|
pstmt = DB.prepareStatement(sql.toString(), trxName);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
list.add(new Integer(rs.getInt(1)));
|
list.add(new Integer(rs.getInt(1)));
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, sql.toString(), e);
|
s_log.log(Level.SEVERE, sql.toString(), e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
DB.close(rs, pstmt);
|
||||||
|
rs = null; pstmt = null;
|
||||||
|
}
|
||||||
// Convert to array
|
// Convert to array
|
||||||
int[] retValue = new int[list.size()];
|
int[] retValue = new int[list.size()];
|
||||||
for (int i = 0; i < retValue.length; i++)
|
for (int i = 0; i < retValue.length; i++)
|
||||||
|
@ -3424,6 +3405,7 @@ public abstract class PO
|
||||||
DOMSource source = new DOMSource(get_xmlDocument(xml.length()!=0));
|
DOMSource source = new DOMSource(get_xmlDocument(xml.length()!=0));
|
||||||
TransformerFactory tFactory = TransformerFactory.newInstance();
|
TransformerFactory tFactory = TransformerFactory.newInstance();
|
||||||
Transformer transformer = tFactory.newTransformer();
|
Transformer transformer = tFactory.newTransformer();
|
||||||
|
transformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT, "yes");
|
||||||
transformer.transform (source, result);
|
transformer.transform (source, result);
|
||||||
StringBuffer newXML = writer.getBuffer();
|
StringBuffer newXML = writer.getBuffer();
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue