【发布时间】:2019-04-12 09:49:36
【问题描述】:
我有一个批处理作业,我正在使用内存 H2 数据库进行测试。我有一个阅读器,可以很好地与我计算机上安装的数据库一起工作。但是当我使用 H2 测试它时,我得到了这个错误:
org.springframework.jdbc.BadSqlGrammarException:尝试处理下一行失败;错误的 SQL 语法 [从 myTable 中选择名称、年龄、状态、COUNT(STATUS)];嵌套异常是 org.h2.jdbc.JdbcSQLException:找不到列“COUNT(status)” [42122-197]
这是我的读者。我不知道为什么我会遇到错误。
JdbcCursorItemReader<myObject> reader = new JdbcCursorItemReader<>();
reader.setSql("select name, age, status, COUNT(STATUS) from myTable
where name="something",
group by name, age, status
order by name, age, status);
【问题讨论】:
-
您的分组依据不是有效的 SQL。阅读:stackoverflow.com/questions/41887460/…
-
@MadhurBhaiya 嗨,感谢您的回复。实际查询很长而且正确。我发布了这个查询只是作为一个例子。
标签: mysql database spring-boot mariadb h2