Search in sources :

Example 1 with IJobExecution

use of com.ibm.jbatch.container.services.IJobExecution 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;
}
Also used : 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) IJobExecution(com.ibm.jbatch.container.services.IJobExecution) ObjectInputStream(java.io.ObjectInputStream) TCCLObjectInputStream(com.ibm.jbatch.container.util.TCCLObjectInputStream)

Example 2 with IJobExecution

use of com.ibm.jbatch.container.services.IJobExecution in project Payara by payara.

the class JBatchJDBCPersistenceManager method jobOperatorGetJobExecutions.

@Override
public List<IJobExecution> jobOperatorGetJobExecutions(long jobInstanceId) {
    Connection conn = null;
    PreparedStatement statement = null;
    ResultSet rs = null;
    List<IJobExecution> data = new ArrayList<IJobExecution>();
    ObjectInputStream objectIn = null;
    try {
        conn = getConnection();
        statement = conn.prepareStatement(queryStrings.get(JOB_OPERATOR_GET_JOB_EXECUTIONS));
        statement.setLong(1, jobInstanceId);
        rs = statement.executeQuery();
        while (rs.next()) {
            data.add(readJobExecutionRecord(rs));
        }
    } 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 data;
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) PersistenceException(com.ibm.jbatch.container.exception.PersistenceException) PreparedStatement(java.sql.PreparedStatement) IOException(java.io.IOException) IJobExecution(com.ibm.jbatch.container.services.IJobExecution) ObjectInputStream(java.io.ObjectInputStream) TCCLObjectInputStream(com.ibm.jbatch.container.util.TCCLObjectInputStream)

Aggregations

PersistenceException (com.ibm.jbatch.container.exception.PersistenceException)2 IJobExecution (com.ibm.jbatch.container.services.IJobExecution)2 TCCLObjectInputStream (com.ibm.jbatch.container.util.TCCLObjectInputStream)2 IOException (java.io.IOException)2 ObjectInputStream (java.io.ObjectInputStream)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)1