use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method updateCheckpointData.
/**
* update data in DB table
*
* @param value
* - serializable object to store
* @param key
* - the IPersistenceDataKey object
* @param query
* - SQL statement to execute.
*
* Ex. update tablename set obj = ? where id = ?
*/
protected void updateCheckpointData(Object key, CheckpointData value) {
logger.entering(CLASSNAME, "updateCheckpointData", new Object[] { key, value });
Connection conn = null;
PreparedStatement statement = null;
ByteArrayOutputStream baos = null;
ObjectOutputStream oout = null;
byte[] b;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(UPDATE_CHECKPOINTDATA));
baos = new ByteArrayOutputStream();
oout = new ObjectOutputStream(baos);
oout.writeObject(value);
b = baos.toByteArray();
statement.setBytes(1, b);
statement.setObject(2, key);
statement.executeUpdate();
} catch (SQLException e) {
logger.severe(e.getLocalizedMessage());
throw new PersistenceException(e);
} catch (IOException e) {
logger.severe(e.getLocalizedMessage());
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);
}
logger.exiting(CLASSNAME, "updateCheckpointData");
}
use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method createSubJobInstance.
/*
* (non-Javadoc)
*
* @see com.ibm.jbatch.container.services.IPersistenceManagerService#
* createJobInstance(java.lang.String, java.lang.String, java.lang.String,
* java.util.Properties)
*/
@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), new String[] { "JOBINSTANCEID" });
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 JBatchJDBCPersistenceManager method jobOperatorQueryJobExecutionBatchStatus.
@Override
public String jobOperatorQueryJobExecutionBatchStatus(long key) {
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
String status = null;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(JOB_OPERATOR_QUERY_JOB_EXECUTION_BATCH_STATUS));
statement.setLong(1, key);
rs = statement.executeQuery();
while (rs.next()) {
status = rs.getString(1);
}
} catch (SQLException e) {
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, rs, statement);
}
return status;
}
use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method updateBatchStatusOnly.
@Override
public void updateBatchStatusOnly(long key, BatchStatus batchStatus, Timestamp updatets) {
Connection conn = null;
PreparedStatement statement = null;
ByteArrayOutputStream baos = null;
ObjectOutputStream oout = null;
byte[] b;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(UPDATE_BATCH_STATUS_ONLY));
statement.setString(1, batchStatus.name());
statement.setTimestamp(2, updatets);
statement.setLong(3, 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 updateJobStatus.
/*
* (non-Javadoc)
*
* @see
* com.ibm.jbatch.container.services.IPersistenceManagerService#updateJobStatus
* (long, com.ibm.jbatch.container.status.JobStatus)
*/
@Override
public void updateJobStatus(long instanceId, JobStatus jobStatus) {
logger.entering(CLASSNAME, "updateJobStatus", new Object[] { instanceId, jobStatus });
if (logger.isLoggable(Level.FINE)) {
logger.fine("Updating Job Status to: " + jobStatus.getBatchStatus());
}
Connection conn = null;
PreparedStatement statement = null;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(UPDATE_JOBSTATUS));
statement.setBytes(1, serializeObject(jobStatus));
statement.setLong(2, instanceId);
statement.executeUpdate();
} catch (SQLException e) {
throw new PersistenceException(e);
} catch (IOException e) {
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, null, statement);
}
logger.exiting(CLASSNAME, "updateJobStatus");
}
Aggregations