ItemReader 无法通过 PrestoDriver 读取行
ItemReader unable to read rows via PrestoDriver
以下 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.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();
}
知道为什么会这样吗?或者一些解决方法将不胜感激。
谢谢
默认情况下,JdbcCursorItemReader
在每个已处理的行之后验证游标的位置。此检查涉及 call to ResultSet#getRow() which does not seem to be supported as mentioned in the .
您可以使用 JdbcCursorItemReader#setVerifyCursorPosition
禁用此检查,直到 Presto 驱动程序支持此功能。
以下 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.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();
}
知道为什么会这样吗?或者一些解决方法将不胜感激。
谢谢
默认情况下,JdbcCursorItemReader
在每个已处理的行之后验证游标的位置。此检查涉及 call to ResultSet#getRow() which does not seem to be supported as mentioned in the
您可以使用 JdbcCursorItemReader#setVerifyCursorPosition
禁用此检查,直到 Presto 驱动程序支持此功能。