use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method updateStepStatus.
/*
* (non-Javadoc)
*
* @see
* com.ibm.jbatch.container.services.IPersistenceManagerService#updateStepStatus
* (long, com.ibm.jbatch.container.status.StepStatus)
*/
@Override
public void updateStepStatus(long stepExecutionId, StepStatus stepStatus) {
logger.entering(CLASSNAME, "updateStepStatus", new Object[] { stepExecutionId, stepStatus });
if (logger.isLoggable(Level.FINE)) {
logger.fine("Updating StepStatus to: " + stepStatus.getBatchStatus());
}
Connection conn = null;
PreparedStatement statement = null;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(UPDATE_STEP_STATUS));
statement.setBytes(1, serializeObject(stepStatus));
statement.setLong(2, stepExecutionId);
statement.executeUpdate();
} catch (SQLException e) {
throw new PersistenceException(e);
} catch (IOException e) {
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, null, statement);
}
logger.exiting(CLASSNAME, "updateStepStatus");
}
use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method jobOperatorQueryJobExecutionExitStatus.
@Override
public String jobOperatorQueryJobExecutionExitStatus(long key) {
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
String status = null;
try {
conn = getConnection();
statement = conn.prepareStatement(queryStrings.get(JOB_OPERATOR_QUERY_JOB_EXECUTION_EXIT_STATUS));
statement.setLong(1, key);
rs = statement.executeQuery();
while (rs.next()) {
status = rs.getString(1);
}
} catch (SQLException e) {
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, rs, statement);
}
return status;
}
use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method purge.
@Override
public void purge(String apptag) {
logger.entering(CLASSNAME, "purge", apptag);
String deleteJobs = queryStrings.get(DELETE_JOBS);
String deleteJobExecutions = queryStrings.get(DELETE_JOB_EXECUTIONS);
String deleteStepExecutions = queryStrings.get(DELETE_STEP_EXECUTIONS);
Connection conn = null;
PreparedStatement statement = null;
try {
conn = getConnection();
statement = conn.prepareStatement(deleteStepExecutions);
statement.setString(1, apptag);
statement.executeUpdate();
statement = conn.prepareStatement(deleteJobExecutions);
statement.setString(1, apptag);
statement.executeUpdate();
statement = conn.prepareStatement(deleteJobs);
statement.setString(1, apptag);
statement.executeUpdate();
} catch (SQLException e) {
throw new PersistenceException(e);
} finally {
cleanupConnection(conn, null, statement);
}
logger.exiting(CLASSNAME, "purge");
}
use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method getConnectionToDefaultSchema.
/**
* @return the database connection. The schema is set to whatever default is
* used by the datasource.
* @throws SQLException
*/
protected Connection getConnectionToDefaultSchema() throws SQLException {
logger.finest("Entering getConnectionToDefaultSchema");
Connection connection = null;
logger.finest("Java EE mode, getting connection from data source");
try {
connection = dataSource.getConnection();
} catch (SQLException e) {
logException("FAILED GETTING DATABASE CONNECTION", e);
throw new PersistenceException(e);
}
logger.finest("autocommit=" + connection.getAutoCommit());
logger.finest("Exiting from getConnectionToDefaultSchema, conn= " + connection);
return connection;
}
use of com.ibm.jbatch.container.exception.PersistenceException in project Payara by payara.
the class JBatchJDBCPersistenceManager method cleanupConnection.
/**
* closes connection, result set and statement
*
* @param conn
* - connection object to close
* @param rs
* - result set object to close
* @param statement
* - statement object to close
*/
protected void cleanupConnection(Connection conn, ResultSet rs, PreparedStatement statement) {
logger.logp(Level.FINEST, CLASSNAME, "cleanupConnection", "Entering", new Object[] { conn, rs == null ? "<null>" : rs, statement == null ? "<null>" : statement });
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
throw new PersistenceException(e);
}
}
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
throw new PersistenceException(e);
}
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
throw new PersistenceException(e);
} finally {
try {
conn.close();
} catch (SQLException e) {
throw new PersistenceException(e);
}
}
}
logger.logp(Level.FINEST, CLASSNAME, "cleanupConnection", "Exiting");
}
Aggregations