List of usage examples for org.springframework.batch.core ExitStatus addExitDescription
public ExitStatus addExitDescription(Throwable throwable)
From source file:com.gopivotal.spring.xd.module.jdbc.JdbcTasklet.java
/** * Execute the {@link #setSql(String) SQL query} provided. If the query starts with "select" (case insensitive) the * result is a list of maps, which is logged and added to the step execution exit status. Otherwise the query is * executed and the result is an indication, also in the exit status, of the number of rows updated. *//*www . j ava 2 s. c o m*/ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { StepExecution stepExecution = chunkContext.getStepContext().getStepExecution(); ExitStatus exitStatus = stepExecution.getExitStatus(); String msg = ""; if (StringUtils.hasText(sql)) { msg = runCommand(chunkContext.getStepContext(), sql); } else if (!CollectionUtils.isEmpty(scripts)) { msg = runScripts(chunkContext, scripts, null); } stepExecution.setExitStatus(exitStatus.addExitDescription(msg)); return RepeatStatus.FINISHED; }
From source file:com.springdeveloper.data.jdbc.batch.JdbcTasklet.java
/** * Execute the {@link #setSql(String) SQL query} provided. If the query * starts with "select" (case insensitive) the result is a list of maps, * which is logged and added to the step execution exit status. Otherwise * the query is executed and the result is an indication, also in the exit * status, of the number of rows updated. *//*from www . ja va2 s . c om*/ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { StepExecution stepExecution = chunkContext.getStepContext().getStepExecution(); ExitStatus exitStatus = stepExecution.getExitStatus(); if (sql.trim().toUpperCase().startsWith("SELECT")) { logger.debug("Executing: " + sql); List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new BeanPropertySqlParameterSource(chunkContext.getStepContext())); String msg = "Result: " + result; logger.debug(msg); stepExecution.setExitStatus(exitStatus.addExitDescription(msg)); } else { logger.debug("Updating : " + sql); int updated = jdbcTemplate.update(sql, new BeanPropertySqlParameterSource(chunkContext.getStepContext())); String msg = "Updated: " + updated + " rows"; logger.debug(msg); stepExecution.setExitStatus(exitStatus.addExitDescription(msg)); } return RepeatStatus.FINISHED; }