BF [ 1874419 ] JDBC Statement not close in a finally block - only for SvrProcess
BF [ 1877935 ] SvrProcess.process should catch all throwables FR [ 1877937 ] SvrProcess: added commitEx method * fixed minor java 5 generics warning
This commit is contained in:
parent
a1cc46bf32
commit
2c4be7b8bc
|
@ -26,14 +26,14 @@ import org.compiere.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Server Process Template
|
* Server Process Template
|
||||||
* <p>
|
|
||||||
* Change log:
|
|
||||||
* <ul>
|
|
||||||
* <li>2007-02-05 - teo_sarca - [ 1646891 ] SvrProcess - post process support
|
|
||||||
* </ul>
|
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: SvrProcess.java,v 1.4 2006/08/10 01:00:44 jjanke Exp $
|
* @version $Id: SvrProcess.java,v 1.4 2006/08/10 01:00:44 jjanke Exp $
|
||||||
|
*
|
||||||
|
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||||
|
* <li>FR [ 1646891 ] SvrProcess - post process support
|
||||||
|
* <li>BF [ 1877935 ] SvrProcess.process should catch all throwables
|
||||||
|
* <li>FR [ 1877937 ] SvrProcess: added commitEx method
|
||||||
*/
|
*/
|
||||||
public abstract class SvrProcess implements ProcessCall
|
public abstract class SvrProcess implements ProcessCall
|
||||||
{
|
{
|
||||||
|
@ -132,7 +132,7 @@ public abstract class SvrProcess implements ProcessCall
|
||||||
prepare();
|
prepare();
|
||||||
msg = doIt();
|
msg = doIt();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
msg = e.getLocalizedMessage();
|
msg = e.getLocalizedMessage();
|
||||||
if (msg == null)
|
if (msg == null)
|
||||||
|
@ -210,6 +210,16 @@ public abstract class SvrProcess implements ProcessCall
|
||||||
m_trx.commit();
|
m_trx.commit();
|
||||||
} // commit
|
} // commit
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commit and throw exception if error
|
||||||
|
* @throws SQLException on commit error
|
||||||
|
*/
|
||||||
|
protected void commitEx() throws SQLException
|
||||||
|
{
|
||||||
|
if (m_trx != null)
|
||||||
|
m_trx.commit(true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback
|
* Rollback
|
||||||
*/
|
*/
|
||||||
|
@ -329,23 +339,27 @@ public abstract class SvrProcess implements ProcessCall
|
||||||
if (m_pi.getAD_User_ID() == null || m_pi.getAD_Client_ID() == null)
|
if (m_pi.getAD_User_ID() == null || m_pi.getAD_Client_ID() == null)
|
||||||
{
|
{
|
||||||
String sql = "SELECT AD_User_ID, AD_Client_ID FROM AD_PInstance WHERE AD_PInstance_ID=?";
|
String sql = "SELECT AD_User_ID, AD_Client_ID FROM AD_PInstance WHERE AD_PInstance_ID=?";
|
||||||
|
PreparedStatement pstmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = DB.prepareStatement(sql, get_TrxName());
|
pstmt = DB.prepareStatement(sql, get_TrxName());
|
||||||
pstmt.setInt(1, m_pi.getAD_PInstance_ID());
|
pstmt.setInt(1, m_pi.getAD_PInstance_ID());
|
||||||
ResultSet rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
{
|
{
|
||||||
m_pi.setAD_User_ID (rs.getInt (1));
|
m_pi.setAD_User_ID (rs.getInt (1));
|
||||||
m_pi.setAD_Client_ID (rs.getInt(2));
|
m_pi.setAD_Client_ID (rs.getInt(2));
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (m_pi.getAD_User_ID() == null)
|
if (m_pi.getAD_User_ID() == null)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -419,7 +433,7 @@ public abstract class SvrProcess implements ProcessCall
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Class clazz = Class.forName(className);
|
Class<?> clazz = Class.forName(className);
|
||||||
Object object = clazz.newInstance();
|
Object object = clazz.newInstance();
|
||||||
Method[] methods = clazz.getMethods();
|
Method[] methods = clazz.getMethods();
|
||||||
for (int i = 0; i < methods.length; i++)
|
for (int i = 0; i < methods.length; i++)
|
||||||
|
|
Loading…
Reference in New Issue