Search in sources :

Example 46 with PersistenceException

use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.

the class JBatchJDBCPersistenceManager method getJobInstanceIdByExecutionId.

public long getJobInstanceIdByExecutionId(long executionId) throws NoSuchJobExecutionException {
    long instanceId = 0;
    Connection conn = null;
    PreparedStatement statement = null;
    ResultSet rs = null;
    try {
        conn = getConnection();
        statement = conn.prepareStatement(queryStrings.get(JOB_INSTANCE_ID_BY_EXECUTION_ID));
        statement.setObject(1, executionId);
        rs = statement.executeQuery();
        if (rs.next()) {
            instanceId = rs.getLong("jobinstanceid");
        } else {
            String msg = "Did not find job instance associated with executionID =" + executionId;
            logger.fine(msg);
            throw new NoSuchJobExecutionException(msg);
        }
    } catch (SQLException e) {
        throw new PersistenceException(e);
    } finally {
        cleanupConnection(conn, rs, statement);
    }
    return instanceId;
}
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) NoSuchJobExecutionException(javax.batch.operations.NoSuchJobExecutionException)

Aggregations

PersistenceException (com.ibm.jbatch.container.exception.PersistenceException)46 SQLException (java.sql.SQLException)46 Connection (java.sql.Connection)44 PreparedStatement (java.sql.PreparedStatement)43 ResultSet (java.sql.ResultSet)31 IOException (java.io.IOException)24 NoSuchJobExecutionException (javax.batch.operations.NoSuchJobExecutionException)7 TCCLObjectInputStream (com.ibm.jbatch.container.util.TCCLObjectInputStream)6 ObjectInputStream (java.io.ObjectInputStream)6 StepExecutionImpl (com.ibm.jbatch.container.jobinstance.StepExecutionImpl)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 ObjectOutputStream (java.io.ObjectOutputStream)5 Timestamp (java.sql.Timestamp)5 BatchContainerServiceException (com.ibm.jbatch.container.exception.BatchContainerServiceException)4 JobInstanceImpl (com.ibm.jbatch.container.jobinstance.JobInstanceImpl)4 Serializable (java.io.Serializable)4 NamingException (javax.naming.NamingException)4 JobStatus (com.ibm.jbatch.container.status.JobStatus)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ArrayList (java.util.ArrayList)3