I have created a test task which inserts a record in a database table. When I was testing, realised that even though I have introduced a deliberate error in the sql statement, the overall schedule exit is still marked as ok hence reported as shown. The error is confirmed from my print statement in the server log
Code: Select all
var conn = system.getDatabaseConnection("MYSQL_EBASE_SAMPLES");
print("AK: system.getDatabaseConnection('MYSQL_EBASE_SAMPLES'): "+ conn);
var stmt;
var rs;
try {
stmt = conn.prepareStatement("INSERT INTO accountmana1gement_timing (`schedular_date`) VALUES(now());" );
rs = stmt.execute(); //returns a boolean to confirm exit status
} catch (err) {
// Parse the error message
var errormsg=String(err);
print("AK: ERROR ENCOUNTERED: "+ errormsg + "!returned!: "+ rs);
} finally {
// it is very important to close any open result sets, statements and connection in this manner
// otherwise there will be a resource leak.
if(rs) rs.close();
if(stmt) stmt.close();
if(conn) conn.close();
}