Search in sources :

Example 1 with JobStatus

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

Example 2 with JobStatus

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

the class JBatchJDBCPersistenceManager method getJobStatus.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.ibm.jbatch.container.services.IPersistenceManagerService#getJobStatus
	 * (long)
	 */
@Override
public JobStatus getJobStatus(long instanceId) {
    logger.entering(CLASSNAME, "getJobStatus", instanceId);
    Connection conn = null;
    PreparedStatement statement = null;
    ResultSet rs = null;
    RuntimeJobExecution jobExecution = null;
    String query = queryStrings.get(GET_JOB_STATUS);
    JobStatus jobStatus = null;
    try {
        conn = getConnection();
        statement = conn.prepareStatement(query);
        statement.setLong(1, instanceId);
        rs = statement.executeQuery();
        if (rs.next()) {
            jobStatus = (JobStatus) 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, "getJobStatus", jobStatus);
    return jobStatus;
}
Also used : JobStatus(com.ibm.jbatch.container.status.JobStatus) 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) IOException(java.io.IOException)

Example 3 with JobStatus

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

the class JBatchJDBCPersistenceManager method getJobStatusFromExecution.

@Override
public JobStatus getJobStatusFromExecution(long executionId) {
    Connection conn = null;
    PreparedStatement statement = null;
    ResultSet rs = null;
    JobStatus retVal = null;
    try {
        conn = getConnection();
        statement = conn.prepareStatement(queryStrings.get(GET_JOB_STATUS_FROM_EXECUTIONS));
        statement.setLong(1, executionId);
        rs = statement.executeQuery();
        byte[] buf = null;
        if (rs.next()) {
            buf = rs.getBytes("obj");
        }
        retVal = (JobStatus) deserializeObject(buf);
    } catch (Exception e) {
        throw new PersistenceException(e);
    } finally {
        cleanupConnection(conn, rs, statement);
    }
    logger.exiting(CLASSNAME, "executeQuery");
    return retVal;
}
Also used : JobStatus(com.ibm.jbatch.container.status.JobStatus) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PersistenceException(com.ibm.jbatch.container.exception.PersistenceException) PreparedStatement(java.sql.PreparedStatement) PersistenceException(com.ibm.jbatch.container.exception.PersistenceException) NamingException(javax.naming.NamingException) BatchContainerServiceException(com.ibm.jbatch.container.exception.BatchContainerServiceException) SQLException(java.sql.SQLException) IOException(java.io.IOException) NoSuchJobExecutionException(javax.batch.operations.NoSuchJobExecutionException)

Aggregations

PersistenceException (com.ibm.jbatch.container.exception.PersistenceException)3 JobStatus (com.ibm.jbatch.container.status.JobStatus)3 IOException (java.io.IOException)3 Connection (java.sql.Connection)3 PreparedStatement (java.sql.PreparedStatement)3 SQLException (java.sql.SQLException)3 ResultSet (java.sql.ResultSet)2 BatchContainerServiceException (com.ibm.jbatch.container.exception.BatchContainerServiceException)1 RuntimeJobExecution (com.ibm.jbatch.container.jobinstance.RuntimeJobExecution)1 NoSuchJobExecutionException (javax.batch.operations.NoSuchJobExecutionException)1 NamingException (javax.naming.NamingException)1