*BF [ 1874419 ] JDBC Statement not close in a finally block
organize imports
This commit is contained in:
parent
adeef0ea0f
commit
9cc5602fa6
|
@ -16,14 +16,31 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.db;
|
package org.compiere.db;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.File;
|
||||||
import java.math.*;
|
import java.io.FileWriter;
|
||||||
import java.sql.*;
|
import java.io.PrintWriter;
|
||||||
import java.util.*;
|
import java.math.BigDecimal;
|
||||||
import java.util.logging.*;
|
import java.sql.Connection;
|
||||||
import org.compiere.*;
|
import java.sql.DatabaseMetaData;
|
||||||
import org.compiere.model.*;
|
import java.sql.PreparedStatement;
|
||||||
import org.compiere.util.*;
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.compiere.Adempiere;
|
||||||
|
import org.compiere.model.MColumn;
|
||||||
|
import org.compiere.model.MTable;
|
||||||
|
import org.compiere.model.M_Element;
|
||||||
|
import org.compiere.util.CLogMgt;
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
import org.compiere.util.DBException;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
|
import org.compiere.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to Create a new Adempiere Database from a reference DB.
|
* Class to Create a new Adempiere Database from a reference DB.
|
||||||
|
@ -244,6 +261,7 @@ public class CreateAdempiere
|
||||||
sql += " ORDER BY TableName";
|
sql += " ORDER BY TableName";
|
||||||
//
|
//
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, null);
|
pstmt = DB.prepareStatement (sql, null);
|
||||||
|
@ -258,7 +276,7 @@ public class CreateAdempiere
|
||||||
throw new DBException("No Connection");
|
throw new DBException("No Connection");
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
while (rs.next() && success)
|
while (rs.next() && success)
|
||||||
{
|
{
|
||||||
MTable table = new MTable (m_ctx, rs, null);
|
MTable table = new MTable (m_ctx, rs, null);
|
||||||
|
@ -279,24 +297,16 @@ public class CreateAdempiere
|
||||||
else
|
else
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
rs.close ();
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log (Level.SEVERE, sql, e);
|
log.log (Level.SEVERE, sql, e);
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
try
|
finally
|
||||||
{
|
{
|
||||||
if (pstmt != null)
|
DB.close(rs, pstmt);
|
||||||
pstmt.close ();
|
rs = null; pstmt = null;
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
if (!success)
|
if (!success)
|
||||||
return false;
|
return false;
|
||||||
|
@ -517,10 +527,11 @@ public class CreateAdempiere
|
||||||
// Get Table Data
|
// Get Table Data
|
||||||
String sql = "SELECT * FROM " + mTable.getTableName();
|
String sql = "SELECT * FROM " + mTable.getTableName();
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, mTable.get_TrxName());
|
pstmt = DB.prepareStatement (sql, mTable.get_TrxName());
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
rs = pstmt.executeQuery ();
|
||||||
while (rs.next ())
|
while (rs.next ())
|
||||||
{
|
{
|
||||||
if (createTableDataRow(rs, mTable))
|
if (createTableDataRow(rs, mTable))
|
||||||
|
@ -528,24 +539,16 @@ public class CreateAdempiere
|
||||||
else
|
else
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
rs.close ();
|
}
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log (Level.SEVERE, sql, e);
|
log.log (Level.SEVERE, sql, e);
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
try
|
finally
|
||||||
{
|
{
|
||||||
if (pstmt != null)
|
DB.close(rs, pstmt);
|
||||||
pstmt.close ();
|
rs = null; pstmt = null;
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
pstmt = null;
|
|
||||||
}
|
}
|
||||||
long elapsed = System.currentTimeMillis() - start;
|
long elapsed = System.currentTimeMillis() - start;
|
||||||
log.config("Inserted=" + count + " - Errors=" + errors
|
log.config("Inserted=" + count + " - Errors=" + errors
|
||||||
|
|
Loading…
Reference in New Issue