use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class PostgresPersistenceManager method createSubJobInstance.
@Override
public JobInstance createSubJobInstance(String name, String apptag) {
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
JobInstanceImpl jobInstance = null;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(CREATE_SUB_JOB_INSTANCE), statement.RETURN_GENERATED_KEYS);
statement.setString(1, name);
statement.setString(2, apptag);
statement.executeUpdate();
rs = statement.getGeneratedKeys();
if (rs.next()) {
long jobInstanceID = rs.getLong(1);
jobInstance = new JobInstanceImpl(jobInstanceID);
jobInstance.setJobName(name);
}
} catch (SQLException e) {
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, rs, statement);
}
return jobInstance;
}
use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class PostgresPersistenceManager method createRuntimeJobExecutionEntry.
@Override
protected long createRuntimeJobExecutionEntry(JobInstance jobInstance, Properties jobParameters, BatchStatus batchStatus, Timestamp timestamp) {
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
long newJobExecutionId = 0L;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(CREATE_JOB_EXECUTION_ENTRY), statement.RETURN_GENERATED_KEYS);
statement.setLong(1, jobInstance.getInstanceId());
statement.setTimestamp(2, timestamp);
statement.setTimestamp(3, timestamp);
statement.setString(4, batchStatus.name());
statement.setObject(5, serializeObject(jobParameters));
statement.executeUpdate();
rs = statement.getGeneratedKeys();
if (rs.next()) {
newJobExecutionId = rs.getLong(1);
}
} catch (SQLException e) {
throw new PersistenceException(e);
} catch (IOException e) {
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, rs, statement);
}
return newJobExecutionId;
}
use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method jobOperatorQueryJobExecutionJobInstanceId.
@Override
public long jobOperatorQueryJobExecutionJobInstanceId(long executionID) throws NoSuchJobExecutionException {
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
long jobinstanceID = 0;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(JOB_OPERATOR_QUERY_JOB_EXECUTION_JOB_ID));
statement.setLong(1, executionID);
rs = statement.executeQuery();
if (rs.next()) {
jobinstanceID = rs.getLong("jobinstanceid");
} else {
String msg = "Did not find job instance associated with executionID =" + executionID;
logger.fine(msg);
throw new NoSuchJobExecutionException(msg);
}
} catch (SQLException e) {
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, rs, statement);
}
return jobinstanceID;
}
use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method getStepExecutionByStepExecutionId.
@Override
public StepExecution getStepExecutionByStepExecutionId(long stepExecId) {
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
long jobexecid = 0;
long stepexecid = 0;
String stepname = null;
String batchstatus = null;
String exitstatus = null;
Exception ex = null;
long readCount = 0;
long writeCount = 0;
long commitCount = 0;
long rollbackCount = 0;
long readSkipCount = 0;
long processSkipCount = 0;
long filterCount = 0;
long writeSkipCount = 0;
Timestamp startTS = null;
Timestamp endTS = null;
StepExecutionImpl stepEx = null;
ObjectInputStream objectIn = null;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(STEP_EXECUTIONS_BY_STEP_ID));
statement.setLong(1, stepExecId);
rs = statement.executeQuery();
while (rs.next()) {
jobexecid = rs.getLong("jobexecid");
stepexecid = rs.getLong("stepexecid");
stepname = rs.getString("stepname");
batchstatus = rs.getString("batchstatus");
exitstatus = rs.getString("exitstatus");
readCount = rs.getLong("readcount");
writeCount = rs.getLong("writecount");
commitCount = rs.getLong("commitcount");
rollbackCount = rs.getLong("rollbackcount");
readSkipCount = rs.getLong("readskipcount");
processSkipCount = rs.getLong("processskipcount");
filterCount = rs.getLong("filtercount");
writeSkipCount = rs.getLong("writeSkipCount");
startTS = rs.getTimestamp("startTime");
endTS = rs.getTimestamp("endTime");
// get the object based data
Serializable persistentData = null;
byte[] pDataBytes = rs.getBytes("persistentData");
if (pDataBytes != null) {
objectIn = new TCCLObjectInputStream(new ByteArrayInputStream(pDataBytes));
persistentData = (Serializable) objectIn.readObject();
}
stepEx = new StepExecutionImpl(jobexecid, stepexecid);
stepEx.setBatchStatus(BatchStatus.valueOf(batchstatus));
stepEx.setExitStatus(exitstatus);
stepEx.setStepName(stepname);
stepEx.setReadCount(readCount);
stepEx.setWriteCount(writeCount);
stepEx.setCommitCount(commitCount);
stepEx.setRollbackCount(rollbackCount);
stepEx.setReadSkipCount(readSkipCount);
stepEx.setProcessSkipCount(processSkipCount);
stepEx.setFilterCount(filterCount);
stepEx.setWriteSkipCount(writeSkipCount);
stepEx.setStartTime(startTS);
stepEx.setEndTime(endTS);
stepEx.setPersistentUserData(persistentData);
logger.fine("stepExecution BatchStatus: " + batchstatus + " StepName: " + stepname);
}
} 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);
}
return stepEx;
}
use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method createRuntimeJobExecutionEntry.
protected long createRuntimeJobExecutionEntry(JobInstance jobInstance, Properties jobParameters, BatchStatus batchStatus, Timestamp timestamp) {
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
long newJobExecutionId = 0L;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(CREATE_JOB_EXECUTION_ENTRY), new String[] { "JOBEXECID" });
statement.setLong(1, jobInstance.getInstanceId());
statement.setTimestamp(2, timestamp);
statement.setTimestamp(3, timestamp);
statement.setString(4, batchStatus.name());
statement.setObject(5, serializeObject(jobParameters));
statement.executeUpdate();
rs = statement.getGeneratedKeys();
if (rs.next()) {
newJobExecutionId = rs.getLong(1);
}
} catch (SQLException e) {
throw new PersistenceException(e);
} catch (IOException e) {
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, rs, statement);
}
return newJobExecutionId;
}
Aggregations