use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method jobOperatorGetJobInstanceCount.
@Override
public int jobOperatorGetJobInstanceCount(String jobName, String appTag) {
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
int count;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(JOBOPERATOR_GET_JOB_INSTANCE_COUNT));
statement.setString(1, jobName);
statement.setString(2, appTag);
rs = statement.executeQuery();
rs.next();
count = rs.getInt("jobinstancecount");
} catch (SQLException e) {
logger.severe(e.getLocalizedMessage());
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, rs, statement);
}
return count;
}
use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method jobOperatorQueryJobExecutionTimestamp.
@Override
public Timestamp jobOperatorQueryJobExecutionTimestamp(long key, TimestampType timestampType) {
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
Timestamp createTimestamp = null;
Timestamp endTimestamp = null;
Timestamp updateTimestamp = null;
Timestamp startTimestamp = null;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(JOB_OPERATOR_QUERY_JOB_EXECUTION_TIMESTAMP));
statement.setObject(1, key);
rs = statement.executeQuery();
while (rs.next()) {
createTimestamp = rs.getTimestamp(1);
endTimestamp = rs.getTimestamp(2);
updateTimestamp = rs.getTimestamp(3);
startTimestamp = rs.getTimestamp(4);
}
} catch (SQLException e) {
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, rs, statement);
}
if (timestampType.equals(TimestampType.CREATE)) {
return createTimestamp;
} else if (timestampType.equals(TimestampType.END)) {
return endTimestamp;
} else if (timestampType.equals(TimestampType.LAST_UPDATED)) {
return updateTimestamp;
} else if (timestampType.equals(TimestampType.STARTED)) {
return startTimestamp;
} else {
throw new IllegalArgumentException("Unexpected enum value.");
}
}
use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method jobOperatorGetJobExecution.
@Override
public IJobExecution jobOperatorGetJobExecution(long jobExecutionId) {
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
IJobExecution jobEx = null;
ObjectInputStream objectIn = null;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(JOB_OPERATOR_GET_JOB_EXECUTION));
statement.setLong(1, jobExecutionId);
rs = statement.executeQuery();
jobEx = (rs.next()) ? readJobExecutionRecord(rs) : null;
} catch (SQLException e) {
throw new PersistenceException(e);
} catch (IOException e) {
throw new PersistenceException(e);
} catch (ClassNotFoundException e) {
throw new PersistenceException(e);
} finally {
if (objectIn != null) {
try {
objectIn.close();
} catch (IOException e) {
throw new PersistenceException(e);
}
}
cleanupConnection(conn, rs, statement);
}
return jobEx;
}
use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method getTagName.
/*
* (non-Javadoc)
*
* @see
* com.ibm.jbatch.container.services.IPersistenceManagerService#getTagName
* (long)
*/
@Override
public String getTagName(long jobExecutionId) {
logger.entering(CLASSNAME, "getTagName", jobExecutionId);
String apptag = null;
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
String query = queryStrings.get(GET_TAGNAME);
try {
conn = getConnection();
statement = conn.prepareStatement(query);
statement.setLong(1, jobExecutionId);
rs = statement.executeQuery();
if (rs.next()) {
apptag = rs.getString(1);
}
} catch (SQLException e) {
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, rs, statement);
}
logger.exiting(CLASSNAME, "getTagName");
return apptag;
}
use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method queryCheckpointData.
/**
* select data from DB table
*
* @param key
* - the IPersistenceDataKey object
* @return List of serializable objects store in the DB table
*
* Ex. select id, obj from tablename where id = ?
*/
protected CheckpointData queryCheckpointData(Object key) {
logger.entering(CLASSNAME, "queryCheckpointData", new Object[] { key, SELECT_CHECKPOINTDATA });
CheckpointData data = null;
try (Connection connection = getConnection()) {
try (PreparedStatement statement = connection.prepareStatement(queryStrings.get(SELECT_CHECKPOINTDATA))) {
statement.setObject(1, key);
ResultSet resultSet = statement.executeQuery();
if (resultSet.next()) {
data = (CheckpointData) deserializeObject(resultSet.getBytes("obj"));
}
}
} catch (SQLException | IOException | ClassNotFoundException e) {
throw new PersistenceException(e);
}
logger.exiting(CLASSNAME, "queryCheckpointData");
return data;
}
Aggregations