0

以下 ItemReader bean 通过 PrestDriver 读取行。执行批处理时,我收到此错误消息:

org.springframework.batch.core.step.skip.NonSkippableReadException: Non-skippable exception during read
at org.springframework.batch.core.step.item.FaultTolerantChunkProvider.read(FaultTolerantChunkProvider.java:105) ~[spring-batch-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.batch.core.step.item.SimpleChunkProvider$1.doInIteration(SimpleChunkProvider.java:126) ~[spring-batch-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]

......

Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: Attempt to process next row 
failed; SQL [SELECT * FROM ......]; getRow; nested exception is 
java.sql.SQLFeatureNotSupportedException: getRow

ItemReader 代码

@Bean
public ItemReader<ExportDto> itemReader() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName("com.facebook.presto.jdbc.PrestoDriver");
    dataSource.setUrl("jdbc:presto: ");
    dataSource.setUsername("....");
    dataSource.setPassword("....");

    JdbcCursorItemReader<ExportDto> reader = new JdbcCursorItemReader<ExportDto>();
    reader.setDataSource(dataSource);
    reader.setSql("SELECT * FROM .....'");
    BeanPropertyRowMapper<ExportDto> rowMapper = new BeanPropertyRowMapper<>(ExportDto.class);
    reader.setRowMapper(rowMapper);
    return reader;
}

我创建了一个“hello world”应用程序来测试驱动程序,这次使用的是普通的 JDBCDriver。本次测试成功。

 String url = "jdbc:presto:.....";
    Properties properties = new Properties();
    properties.setProperty("user", "....");
    properties.setProperty("password", "....");
    properties.setProperty("SSL", "true");
    try {
        Connection conn = DriverManager.getConnection(url, properties);
        if (conn == null) {
            System.out.print("NULL");
        } else {
            Statement stmt = conn.createStatement();
            String sql = "SELECT distinct .....";
            ResultSet rs = stmt.executeQuery(sql);
            // Extract data from result set
            while (rs.next()) {
                // Retrieve by column name
                String programs = rs.getString("prg");
            }
            // Clean-up environment
            rs.close();
            stmt.close();
            conn.close();
        }

任何想法为什么会发生这种情况?或一些解决方法将不胜感激。

谢谢

4

1 回答 1

0

默认情况下,JdbcCursorItemReader在每个处理的行之后验证游标的位置。此检查涉及对 ResultSet#getRow() 的调用,如上面评论中所述,该调用似乎不受支持。

JdbcCursorItemReader#setVerifyCursorPosition在 Presto 驱动程序支持此功能之前,您可以禁用此检查。

于 2020-10-30T08:45:18.137 回答