[ 1874419 ] JDBC Statement not close in a finally block

This commit is contained in:
Heng Sin Low 2008-02-12 04:55:37 +00:00
parent 2e2baad0b4
commit 42d32cc8f1
1 changed files with 25 additions and 34 deletions

View File

@ -21,7 +21,6 @@ import java.rmi.*;
import java.sql.*; import java.sql.*;
import java.util.logging.*; import java.util.logging.*;
import org.compiere.Adempiere;
import org.compiere.db.*; import org.compiere.db.*;
import org.compiere.interfaces.*; import org.compiere.interfaces.*;
import org.compiere.util.*; import org.compiere.util.*;
@ -121,9 +120,8 @@ public class PO_LOB implements Serializable
{ // See ServerBean { // See ServerBean
success = server.updateLOB (sql.toString(), m_displayType, m_value, SecurityToken.getInstance()); success = server.updateLOB (sql.toString(), m_displayType, m_value, SecurityToken.getInstance());
if (CLogMgt.isLevelFinest()) if (CLogMgt.isLevelFinest())
log.fine("server => " + success); log.fine("server.updateLOB => " + success);
if (success) return success;
return true;
} }
log.log(Level.SEVERE, "AppsServer not found"); log.log(Level.SEVERE, "AppsServer not found");
} }
@ -131,6 +129,7 @@ public class PO_LOB implements Serializable
{ {
log.log(Level.SEVERE, "AppsServer error", ex); log.log(Level.SEVERE, "AppsServer error", ex);
} }
return false;
} }
log.fine("[" + trxName + "] - Local - " + m_value); log.fine("[" + trxName + "] - Local - " + m_value);
@ -162,27 +161,18 @@ public class PO_LOB implements Serializable
int no = pstmt.executeUpdate(); int no = pstmt.executeUpdate();
if (no != 1) if (no != 1)
{ {
log.fine("[" + trxName + "] - Not updated #" + no + " - " + sql); log.warning("[" + trxName + "] - Not updated #" + no + " - " + sql);
success = false; success = false;
} }
//
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Throwable e)
{ {
log.log(Level.SEVERE, "[" + trxName + "] - " + sql, e); log.log(Level.SEVERE, "[" + trxName + "] - " + sql, e);
success = false; success = false;
} }
// Close Statement finally
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{ {
DB.close(pstmt);
pstmt = null; pstmt = null;
} }
@ -199,14 +189,20 @@ public class PO_LOB implements Serializable
try try
{ {
con.commit(); con.commit();
con.close();
con = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, "[" + trxName + "] - commit " , e); log.log(Level.SEVERE, "[" + trxName + "] - commit " , e);
success = false; success = false;
} }
finally
{
try {
con.close();
} catch (SQLException e) {
}
con = null;
}
} }
} }
// Error - roll back // Error - roll back
@ -224,27 +220,22 @@ public class PO_LOB implements Serializable
try try
{ {
con.rollback(); con.rollback();
con.close();
con = null;
} }
catch (Exception ee) catch (Exception ee)
{ {
log.log(Level.SEVERE, "[" + trxName + "] - rollback" , ee); log.log(Level.SEVERE, "[" + trxName + "] - rollback" , ee);
} }
finally
{
try {
con.close();
} catch (SQLException e) {
}
con = null;
}
} }
} }
// Clean Connection
try
{
if (con != null)
con.close();
con = null;
}
catch (Exception e)
{
con = null;
}
return success; return success;
} // save } // save