BF [ 2548216 ] Process Param Panel is not showing any parameter if error

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

ProcessModalDialog, ProcessDialog: close resultset and preparedstatement in a finally block
This commit is contained in:
teo_sarca 2009-01-30 08:27:29 +00:00
parent d1c1d8996a
commit ef1b9a5fd7
3 changed files with 28 additions and 17 deletions

View File

@ -34,6 +34,7 @@ import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.exceptions.DBException;
import org.compiere.print.ReportCtl;
import org.compiere.print.ReportEngine;
import org.compiere.process.ProcessInfo;
@ -231,13 +232,15 @@ public class ProcessDialog extends CFrame
+ "FROM AD_Process p, AD_Process_Trl t "
+ "WHERE p.AD_Process_ID=t.AD_Process_ID"
+ " AND p.AD_Process_ID=? AND t.AD_Language=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_AD_Process_ID);
if (trl)
pstmt.setString(2, Env.getAD_Language(Env.getCtx()));
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
m_Name = rs.getString(1);
@ -255,14 +258,15 @@ public class ProcessDialog extends CFrame
if (!rs.wasNull())
m_messageText.append("<p>").append(s).append("</p>");
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
return false;
throw new DBException(e, sql);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
if (m_Name == null) {

View File

@ -31,6 +31,7 @@ import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import org.adempiere.exceptions.DBException;
import org.compiere.process.ProcessInfo;
import org.compiere.swing.CButton;
import org.compiere.swing.CDialog;
@ -233,13 +234,15 @@ public class ProcessModalDialog extends CDialog
+ "FROM AD_Process p, AD_Process_Trl t "
+ "WHERE p.AD_Process_ID=t.AD_Process_ID"
+ " AND p.AD_Process_ID=? AND t.AD_Language=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_AD_Process_ID);
if (trl)
pstmt.setString(2, Env.getAD_Language(m_ctx));
ResultSet rs = pstmt.executeQuery();
rs = pstmt.executeQuery();
if (rs.next())
{
m_Name = rs.getString(1);
@ -257,14 +260,15 @@ public class ProcessModalDialog extends CDialog
if (!rs.wasNull())
m_messageText.append("<p>").append(s).append("</p>");
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
return false;
throw new DBException(e, sql);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
if (m_Name == null)

View File

@ -32,6 +32,7 @@ import java.util.logging.Level;
import javax.swing.Box;
import javax.swing.JLabel;
import org.adempiere.exceptions.DBException;
import org.compiere.grid.ed.VEditor;
import org.compiere.grid.ed.VEditorFactory;
import org.compiere.model.GridField;
@ -49,10 +50,12 @@ import org.compiere.util.Env;
* - Embedded in ProcessDialog
* - checks, if parameters exist and inquires and saves them
*
* @author Low Heng Sin
* @author Low Heng Sin
* @author Juan David Arboleda (arboleda), GlobalQSS, [ 1795398 ] Process
* Parameter: add display and readonly logic
* @version 2006-12-01
* @author Teo Sarca, www.arhipac.ro
* <li>BF [ 2548216 ] Process Param Panel is not showing any parameter if error
* @version 2006-12-01
*/
@SuppressWarnings("serial")
public class ProcessParameterPanel extends CPanel implements VetoableChangeListener, IProcessParameter {
@ -225,7 +228,7 @@ public class ProcessParameterPanel extends CPanel implements VetoableChangeListe
}
catch(SQLException e)
{
log.log(Level.SEVERE, sql, e);
throw new DBException(e, sql);
}
finally
{