use of com.ibm.jbatch.container.status.JobStatus in project Payara by payara.
the class JBatchJDBCPersistenceManager method createJobStatus.
/*
* (non-Javadoc)
*
* @see
* com.ibm.jbatch.container.services.IPersistenceManagerService#createJobStatus
* (long)
*/
@Override
public JobStatus createJobStatus(long jobInstanceId) {
logger.entering(CLASSNAME, "createJobStatus", jobInstanceId);
Connection conn = null;
PreparedStatement statement = null;
JobStatus jobStatus = new JobStatus(jobInstanceId);
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(CREATE_JOBSTATUS));
statement.setLong(1, jobInstanceId);
statement.setBytes(2, serializeObject(jobStatus));
statement.executeUpdate();
} catch (SQLException e) {
throw new PersistenceException(e);
} catch (IOException e) {
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, null, statement);
}
logger.exiting(CLASSNAME, "createJobStatus");
return jobStatus;
}
use of com.ibm.jbatch.container.status.JobStatus in project Payara by payara.
the class JBatchJDBCPersistenceManager method getJobStatus.
/*
* (non-Javadoc)
*
* @see
* com.ibm.jbatch.container.services.IPersistenceManagerService#getJobStatus
* (long)
*/
@Override
public JobStatus getJobStatus(long instanceId) {
logger.entering(CLASSNAME, "getJobStatus", instanceId);
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
RuntimeJobExecution jobExecution = null;
String query = queryStrings.get(GET_JOB_STATUS);
JobStatus jobStatus = null;
try {
conn = getConnection();
statement = conn.prepareStatement(query);
statement.setLong(1, instanceId);
rs = statement.executeQuery();
if (rs.next()) {
jobStatus = (JobStatus) deserializeObject(rs.getBytes(1));
}
} catch (SQLException e) {
throw new PersistenceException(e);
} catch (IOException e) {
throw new PersistenceException(e);
} catch (ClassNotFoundException e) {
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, rs, statement);
}
logger.exiting(CLASSNAME, "getJobStatus", jobStatus);
return jobStatus;
}
use of com.ibm.jbatch.container.status.JobStatus in project Payara by payara.
the class JBatchJDBCPersistenceManager method getJobStatusFromExecution.
@Override
public JobStatus getJobStatusFromExecution(long executionId) {
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
JobStatus retVal = null;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(GET_JOB_STATUS_FROM_EXECUTIONS));
statement.setLong(1, executionId);
rs = statement.executeQuery();
byte[] buf = null;
if (rs.next()) {
buf = rs.getBytes("obj");
}
retVal = (JobStatus) deserializeObject(buf);
} catch (Exception e) {
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, rs, statement);
}
logger.exiting(CLASSNAME, "executeQuery");
return retVal;
}
Aggregations