0

I have below java code where i am trying to fetch data using select query and then import this data into json format.

The problem is currently i am getting error

    ORA-02063: preceding line from ABSTP
    ; nested exception is java.sql.SQLException: 
ORA-01555: snapshot too old: rollback segment number 14 with name "_SYSSMU14_1823253467$" too small

This error i believe is because of long running query. As i am not good in java so i would like to know is there any other process in java for transaction handling where i can distribute the transaction and run this query or is there any other way where i can handle such transactions in java code to avoid this issue?

@Service
public class InformerSupp {
    public final static Logger log = LoggerFactory.getLogger(InformerSupp.class);

    @Autowired
    private NamedParameterJdbcTemplate NamedParameterJdbcTemplate;

    @Autowired
    private String queueName;

    @Autowired
    private JmsTemplate jmsTemplate;

    private ObjectMapper mapper;

    @PostConstruct
    public void afterPropertiesSet() throws Exception {
        mapper = new ObjectMapper();
    }

    public boolean transportData() {
        final List<Map<String, Object>> maps = NamedParameterJdbcTemplate
                .queryForList(format("select * from isi_trt c"),EMPTY_MAP);

        for (Map<String, Object> entry : maps) {
            String json = null;
            try {
                json = mapper.writeValueAsString(entry);
                transportMessage(json);
            } catch (JMSException e) {
                log.error(String.format("Failed to create a JSON message : %s", entry), e);
                return false;
            } catch (JsonProcessingException e) {
                log.error(String.format("Failed to transport message :  %s  to %s", json, queueName), e);
                return false;
            }
        }
        return true;
    }

    private void transportMessage(final String json) throws JMSException {
        log.info(String.format("send message : %s ",json));
        jmsTemplate.send(queueName, session -> {
            TextMessage textMessage = session.createTextMessage();
            int ccsid = _L.coalesce(((MQSession) session).getIntProperty(WMQ_QMGR_CCSID),0);
            textMessage.setIntProperty(WMQ_CCSID, ccsid);
            textMessage.setIntProperty(JMS_IBM_CHARACTER_SET, ccsid);
            textMessage.setText(json);
            return textMessage;
        });
    }

}
Andrew
  • 3,632
  • 24
  • 64
  • 113

0 Answers0