Search in sources :

Example 1 with StepStatus

use of com.ibm.jbatch.container.status.StepStatus 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;
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) PersistenceException(com.ibm.jbatch.container.exception.PersistenceException) PreparedStatement(java.sql.PreparedStatement) StepStatus(com.ibm.jbatch.container.status.StepStatus) IOException(java.io.IOException)

Example 2 with StepStatus

use of com.ibm.jbatch.container.status.StepStatus in project Payara by payara.

the class JBatchJDBCPersistenceManager method getStepStatus.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.ibm.jbatch.container.services.IPersistenceManagerService#getStepStatus
	 * (long, java.lang.String)
	 */
@Override
public StepStatus getStepStatus(long instanceId, String stepName) {
    logger.entering(CLASSNAME, "getStepStatus", new Object[] { instanceId, stepName });
    Connection conn = null;
    PreparedStatement statement = null;
    ResultSet rs = null;
    RuntimeJobExecution jobExecution = null;
    String query = queryStrings.get(GET_STEP_STATUS);
    StepStatus stepStatus = null;
    try {
        conn = getConnection();
        statement = conn.prepareStatement(query);
        statement.setLong(1, instanceId);
        statement.setString(2, stepName);
        rs = statement.executeQuery();
        if (rs.next()) {
            stepStatus = (StepStatus) 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, "getStepStatus", stepStatus == null ? "<null>" : stepStatus);
    return stepStatus;
}
Also used : RuntimeJobExecution(com.ibm.jbatch.container.jobinstance.RuntimeJobExecution) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PersistenceException(com.ibm.jbatch.container.exception.PersistenceException) PreparedStatement(java.sql.PreparedStatement) StepStatus(com.ibm.jbatch.container.status.StepStatus) IOException(java.io.IOException)

Aggregations

PersistenceException (com.ibm.jbatch.container.exception.PersistenceException)2 StepStatus (com.ibm.jbatch.container.status.StepStatus)2 IOException (java.io.IOException)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 SQLException (java.sql.SQLException)2 RuntimeJobExecution (com.ibm.jbatch.container.jobinstance.RuntimeJobExecution)1 ResultSet (java.sql.ResultSet)1