use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method getMostRecentExecutionId.
@Override
public long getMostRecentExecutionId(long jobInstanceId) {
logger.entering(CLASSNAME, "getMostRecentExecutionId", jobInstanceId);
long mostRecentId = -1;
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
String query = queryStrings.get(GET_MOST_RECENT_EXECUTION_ID);
try {
conn = getConnection();
statement = conn.prepareStatement(query);
statement.setLong(1, jobInstanceId);
rs = statement.executeQuery();
if (rs.next()) {
mostRecentId = rs.getLong(1);
}
} catch (SQLException e) {
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, rs, statement);
}
logger.exiting(CLASSNAME, "getMostRecentExecutionId");
return mostRecentId;
}
use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method markJobStarted.
public void markJobStarted(long key, Timestamp startTS) {
Connection conn = null;
PreparedStatement statement = null;
ByteArrayOutputStream baos = null;
ObjectOutputStream oout = null;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(MARK_JOB_STARTED));
statement.setString(1, BatchStatus.STARTED.name());
statement.setTimestamp(2, startTS);
statement.setTimestamp(3, startTS);
statement.setLong(4, key);
statement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
throw new PersistenceException(e);
} finally {
if (baos != null) {
try {
baos.close();
} catch (IOException e) {
throw new PersistenceException(e);
}
}
if (oout != null) {
try {
oout.close();
} catch (IOException e) {
throw new PersistenceException(e);
}
}
cleanupConnection(conn, null, statement);
}
}
use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method createStepStatus.
/*
* (non-Javadoc)
*
* @see
* com.ibm.jbatch.container.services.IPersistenceManagerService#createStepStatus
* (long)
*/
@Override
public StepStatus createStepStatus(long stepExecId) {
logger.entering(CLASSNAME, "createStepStatus", stepExecId);
Connection conn = null;
PreparedStatement statement = null;
StepStatus stepStatus = new StepStatus(stepExecId);
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(CREATE_STEP_STATUS));
statement.setLong(1, stepExecId);
statement.setBytes(2, serializeObject(stepStatus));
statement.executeUpdate();
} catch (SQLException e) {
throw new PersistenceException(e);
} catch (IOException e) {
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, null, statement);
}
logger.exiting(CLASSNAME, "createStepStatus");
return stepStatus;
}
use of com.ibm.jbatch.container.exception.PersistenceException 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.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method updateWithFinalExecutionStatusesAndTimestamps.
@Override
public void updateWithFinalExecutionStatusesAndTimestamps(long key, BatchStatus batchStatus, String exitStatus, Timestamp updatets) {
// TODO Auto-generated methddod stub
Connection conn = null;
PreparedStatement statement = null;
ByteArrayOutputStream baos = null;
ObjectOutputStream oout = null;
byte[] b;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(UPDATE_FINAL_STATUS_AND_TIMESTAMP));
statement.setString(1, batchStatus.name());
statement.setString(2, exitStatus);
statement.setTimestamp(3, updatets);
statement.setTimestamp(4, updatets);
statement.setLong(5, key);
statement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
throw new PersistenceException(e);
} finally {
if (baos != null) {
try {
baos.close();
} catch (IOException e) {
throw new PersistenceException(e);
}
}
if (oout != null) {
try {
oout.close();
} catch (IOException e) {
throw new PersistenceException(e);
}
}
cleanupConnection(conn, null, statement);
}
}
Aggregations