RunMyJobs has a very clear datamodel which can be accessed very easily. Queries can be used for several reasons. One reason can be the retrieval of all active (running and waiting jobs). An Iterator can be used to loop through the query-result.
{ // Query the Active (Waiting and Running) Jobs String sqlCmd = "select j.* from Job j where j.Status in ('W','R')" ; for (Iterator it = jcsSession.executeObjectQuery(sqlCmd , null); it.hasNext(); ) { // Get the next available record Job job = (Job) it.next(); jcsOut.println("Job " + job.getDescription() + " has status " + job.getStatus().toString() ) ; } }
Alternative:
{ // Query the Active (Waiting and Running) Jobs String sqlCmd = "select j.* from Job j where j.Status in ('W','R')" ; Iterator itQuery = jcsSession.executeObjectQuery(sqlCmd, null); while (itQuery.hasNext()) { // Get the next available record Job job = (Job) it.next(); jcsOut.println("Job " + job.getDescription() + " has status " + job.getStatus().toString() ) ; } }