*BF [ 1874419 ] JDBC Statement not close in a finally block
*Organize imports *Parameterized <T>
This commit is contained in:
parent
918872fd8a
commit
0eb0840aaa
|
@ -17,21 +17,33 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.model;
|
package org.compiere.model;
|
||||||
|
|
||||||
import java.beans.*;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.io.*;
|
import java.beans.PropertyChangeSupport;
|
||||||
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.*;
|
import java.sql.PreparedStatement;
|
||||||
import java.text.*;
|
import java.sql.ResultSet;
|
||||||
import java.util.*;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Timestamp;
|
||||||
import java.util.logging.*;
|
import java.text.MessageFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import javax.swing.event.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import org.compiere.util.*;
|
import java.util.Properties;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import javax.script.ScriptEngine;
|
import javax.script.ScriptEngine;
|
||||||
import javax.script.ScriptException;
|
import javax.swing.event.EventListenerList;
|
||||||
|
|
||||||
|
import org.compiere.util.CLogMgt;
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.Evaluatee;
|
||||||
|
import org.compiere.util.Evaluator;
|
||||||
|
import org.compiere.util.Msg;
|
||||||
|
import org.compiere.util.ValueNamePair;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tab Model.
|
* Tab Model.
|
||||||
|
@ -1576,12 +1588,14 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
||||||
*/
|
*/
|
||||||
Object[] arguments = new Object[5];
|
Object[] arguments = new Object[5];
|
||||||
boolean filled = false;
|
boolean filled = false;
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
//
|
//
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
pstmt = DB.prepareStatement(sql.toString(), null);
|
||||||
pstmt.setInt(1, Record_ID);
|
pstmt.setInt(1, Record_ID);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
{
|
{
|
||||||
// {0} - Number of lines
|
// {0} - Number of lines
|
||||||
|
@ -1601,13 +1615,17 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
||||||
arguments[4] = grandEuro;
|
arguments[4] = grandEuro;
|
||||||
filled = true;
|
filled = true;
|
||||||
}
|
}
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, m_vo.TableName + "\nSQL=" + sql, e);
|
log.log(Level.SEVERE, m_vo.TableName + "\nSQL=" + sql, e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(rs, pstmt);
|
||||||
|
rs = null; pstmt = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (filled)
|
if (filled)
|
||||||
return mf.format (arguments);
|
return mf.format (arguments);
|
||||||
return " ";
|
return " ";
|
||||||
|
@ -1645,11 +1663,13 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
||||||
+ "WHERE S_TimeExpense_ID=?";
|
+ "WHERE S_TimeExpense_ID=?";
|
||||||
|
|
||||||
//
|
//
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(SQL, null);
|
pstmt = DB.prepareStatement(SQL, null);
|
||||||
pstmt.setInt(1, Record_ID);
|
pstmt.setInt(1, Record_ID);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
{
|
{
|
||||||
// {0} - Number of lines
|
// {0} - Number of lines
|
||||||
|
@ -1662,13 +1682,17 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
||||||
arguments[2] = " ";
|
arguments[2] = " ";
|
||||||
filled = true;
|
filled = true;
|
||||||
}
|
}
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, m_vo.TableName + "\nSQL=" + SQL, e);
|
log.log(Level.SEVERE, m_vo.TableName + "\nSQL=" + SQL, e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(rs, pstmt);
|
||||||
|
rs = null; pstmt = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (filled)
|
if (filled)
|
||||||
return mf.format (arguments);
|
return mf.format (arguments);
|
||||||
return " ";
|
return " ";
|
||||||
|
@ -1697,20 +1721,26 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String sql = "SELECT DocSubTypeSO FROM C_DocType WHERE C_DocType_ID=?";
|
String sql = "SELECT DocSubTypeSO FROM C_DocType WHERE C_DocType_ID=?";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql, null);
|
||||||
pstmt.setInt(1, C_DocTyp_ID);
|
pstmt.setInt(1, C_DocTyp_ID);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
Env.setContext(m_vo.ctx, m_vo.WindowNo, "OrderType", rs.getString(1));
|
Env.setContext(m_vo.ctx, m_vo.WindowNo, "OrderType", rs.getString(1));
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, sql, e);
|
log.log(Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DB.close(rs, pstmt);
|
||||||
|
rs = null; pstmt = null;
|
||||||
|
}
|
||||||
|
|
||||||
} // loadOrderInfo
|
} // loadOrderInfo
|
||||||
} // loadDependentInfo
|
} // loadDependentInfo
|
||||||
|
|
||||||
|
@ -2373,7 +2403,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get dependent MFields (may be because of display or dynamic lookup)
|
// Get dependent MFields (may be because of display or dynamic lookup)
|
||||||
ArrayList list = getDependantFields(columnName);
|
ArrayList<GridField> list = getDependantFields(columnName);
|
||||||
for (int i = 0; i < list.size(); i++)
|
for (int i = 0; i < list.size(); i++)
|
||||||
{
|
{
|
||||||
GridField dependentField = (GridField)list.get(i);
|
GridField dependentField = (GridField)list.get(i);
|
||||||
|
|
Loading…
Reference in New Issue