Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在java中为长时间运行的查询分发oracle事务_Java_Oracle_Transactions_Snapshot_Long Running Processes - Fatal编程技术网

如何在java中为长时间运行的查询分发oracle事务

如何在java中为长时间运行的查询分发oracle事务,java,oracle,transactions,snapshot,long-running-processes,Java,Oracle,Transactions,Snapshot,Long Running Processes,我在下面的java代码中尝试使用select查询获取数据,然后将这些数据导入json格式 问题是目前我得到的错误 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 我

我在下面的java代码中尝试使用select查询获取数据,然后将这些数据导入json格式

问题是目前我得到的错误

    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
我认为这个错误是因为长时间运行的查询。由于我不擅长java,所以我想知道java中是否有其他用于事务处理的流程,我可以在其中分发事务并运行此查询,或者是否有其他方式可以在java代码中处理此类事务以避免此问题

@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;
        });
    }

}
@服务
公共类信息支持{
public final static Logger log=LoggerFactory.getLogger(InformerSupp.class);
@自动连线
私有名称ParameterJDBCTemplate名称ParameterJDBCTemplate;
@自动连线
私有字符串队列名称;
@自动连线
私有JmsTemplate JmsTemplate;
私有对象映射器映射器;
@施工后
public void afterPropertieSet()引发异常{
映射器=新的ObjectMapper();
}
公共布尔传输数据(){
最终列表映射=NamedParameterJdbcTemplate
.queryForList(格式(“从isi_trt c中选择*”),空映射);
用于(地图条目:地图){
字符串json=null;
试一试{
json=mapper.writeValueAsString(条目);
传输消息(json);
}捕获(JME){
log.error(String.format(“未能创建JSON消息:%s”,条目),e);
返回false;
}捕获(JsonProcessingException e){
log.error(String.format(“未能将消息:%s传输到%s”,json,queueName),e);
返回false;
}
}
返回true;
}
私有void transportMessage(最终字符串json)引发JMSException{
log.info(String.format(“发送消息:%s”,json));
发送(队列名称,会话->{
TextMessage=session.createTextMessage();
int ccsid=_L.coalesce(((MQSession)session).getIntProperty(WMQ_QMGR_ccsid),0);
setIntProperty(WMQ_CCSID,CCSID);
setIntProperty(JMS\u IBM\u字符集,ccsid);
setText(json);
返回文本消息;
});
}
}

阅读本文-我已经阅读了这篇文章,并且还增加了撤销保留大小,但我正在考虑一种方法,如果我可以在Java中处理这个问题,您需要定期执行提交,但这意味着您无法在发生错误时撤销所有操作