I have a java service (below) that performs an update to some legacy data. 
If I run the service manually through webtools, the service runs and updates
the database.  If I set the job to run on an automated schedule (nightly),
the job finishes with no errors, but the database is unchanged.  It seams as
if the transactions are getting rolled back but there is no error?

I am running ofbiz 4.0.

Any pointers would be appreciated!  Many thanks in advance,

Chris

public static Map populate(DispatchContext ctx, Map context) {

        LocalDispatcher dispatcher = ctx.getDispatcher();
        Connection conn = null;
        Statement statement = null;       
        try{
                boolean beganTransaction = false;               
                conn = ConnectionFactory.getConnection("dhmssql");
                if (conn == null) {
                        throw new Exception("No dhmssql connection
configured");
                }
                statement = conn.createStatement();
                beganTransaction = TransactionUtil.begin(60 * 60 * 2); //
2hrs
                statement.executeUpdate("delete from
tblMoneyOutstandingReport where clearedDate is not null");
                statement.executeUpdate(
                        "insert into tblMoneyOutstandingReport " +
                        "select " +
                        ... 
                        "where clearedDate is not null"); 
                TransactionUtil.commit(beganTransaction);
                
                beganTransaction = TransactionUtil.begin(60 * 60 * 2); //
2hrs
                statement.executeUpdate("delete from
tblMoneyOutstandingReport where clearedDate is null");
                statement.executeUpdate(
                        "insert into tblMoneyOutstandingReport " +
                        "select " +
                        ... 
                        "where clearedDate is null"); 
                TransactionUtil.commit(beganTransaction);                       
         
                statement.close();
        } catch (Exception e){          
                        Debug.logError(e, "Error running SQL - ",
MoneyOutstandingOfflineReportService.class.getName());
                return ServiceUtil.returnError("Error running SQL - " + e);
        }
        finally {
                if (statement != null)
                        try {
                                statement.close();
                        } catch (Exception e) {}
                if (conn != null)
                        try {
                                conn.close();
                        } catch (Exception e) {}
        }
        return ServiceUtil.returnSuccess(); 
        } 
-- 
View this message in context: 
http://www.nabble.com/manually-scheduled-service-works%2C-scheduled-service-fails-silently--tp25486697p25486697.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Reply via email to