scheduled task exit code confirm

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

kotinkarwak
Ebase User
Posts: 109
Joined: Mon Sep 21, 2015 9:55 pm

scheduled task exit code confirm

#1

Postby kotinkarwak » Sun Nov 15, 2015 10:10 pm

http://screencast.com/t/hfpaIrTz
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();	
}

0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Mon Nov 16, 2015 9:16 am

In this example you've caught the error in your code. You will only see a failure reported when the scheduled task terminates abnormally.
0 x

kotinkarwak
Ebase User
Posts: 109
Joined: Mon Sep 21, 2015 9:55 pm

#3

Postby kotinkarwak » Mon Nov 16, 2015 12:34 pm

Thanks for clarification. Works fine without try/catch.
0 x


Who is online

Users browsing this forum: No registered users and 14 guests