*BF [ 1874419 ] JDBC Statement not close in a finally block

*Organize imports
This commit is contained in:
Redhuan D. Oon 2008-02-08 08:43:21 +00:00
parent 4d6fcf009b
commit 37bfc101b5
3 changed files with 54 additions and 41 deletions

View File

@ -16,13 +16,16 @@
*****************************************************************************/
package org.compiere;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.*;
import org.compiere.model.*;
import org.compiere.print.*;
import org.compiere.model.MProductDownload;
import org.compiere.print.PrintFormatUtil;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
/**
* Migrate Data
@ -65,10 +68,11 @@ public class MigrateData
+ "FROM M_Product "
+ "WHERE DownloadURL IS NOT NULL";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
int AD_Client_ID = rs.getInt(1);
@ -97,24 +101,17 @@ public class MigrateData
else
log.warning("Product Download not created M_Product_ID=" + M_Product_ID);
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log (Level.SEVERE, sql, e);
}
try
finally
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
log.info("#" + count);
} // release252c

View File

@ -16,14 +16,33 @@
*****************************************************************************/
package org.compiere.apps;
import java.awt.event.*;
import java.sql.*;
import java.util.logging.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.logging.Level;
import org.compiere.model.*;
import org.compiere.swing.*;
import org.compiere.util.*;
import javax.swing.JComponent;
import javax.swing.JPopupMenu;
import org.compiere.model.GridTab;
import org.compiere.model.MAsset;
import org.compiere.model.MBPartner;
import org.compiere.model.MCampaign;
import org.compiere.model.MInOut;
import org.compiere.model.MInvoice;
import org.compiere.model.MOrder;
import org.compiere.model.MPayment;
import org.compiere.model.MProduct;
import org.compiere.model.MProject;
import org.compiere.model.MQuery;
import org.compiere.model.MRMA;
import org.compiere.model.MUser;
import org.compiere.swing.CMenuItem;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
/**
@ -113,10 +132,11 @@ public class ARequest implements ActionListener
+ " GROUP BY Processed "
+ "ORDER BY Processed DESC";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, null);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
while (rs.next ())
{
if ("Y".equals(rs.getString(1)))
@ -124,9 +144,6 @@ public class ARequest implements ActionListener
else
activeCount += rs.getInt(2);
}
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
@ -142,7 +159,12 @@ public class ARequest implements ActionListener
{
pstmt = null;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
//
if (activeCount > 0)
{

View File

@ -131,33 +131,27 @@ public abstract class Config
{
String sql = "SELECT WebContext FROM W_Store WHERE IsActive='Y'";
Statement stmt = null;
ResultSet rs = null;
StringBuffer result = new StringBuffer();
try
{
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
rs = stmt.executeQuery(sql);
while (rs.next ())
{
if (result.length() > 0)
result.append(",");
result.append(rs.getString(1));
}
rs.close ();
stmt.close ();
stmt = null;
}
catch (Exception e)
{
log.severe(e.toString());
}
try
{
if (stmt != null)
stmt.close ();
stmt = null;
}
catch (Exception e)
finally
{
DB.close(rs, stmt);
rs = null;
stmt = null;
}
return result.toString();