[英]Fix SQL error incompatible types: capture#1 of ? cannot be converted to int
I have a SQL query to query an Ignite cache database.我有一个 SQL 查询来查询 Ignite 缓存数据库。 But select count(column_Name) gives following compilation error.但是 select count(column_Name) 给出了以下编译错误。 incompatible types: capture#1 of? cannot be converted to int
here is my code.这是我的代码。
private static final String sql = "Select count(_val) from Annotations where orderId = ? and timestamp <= ? and timestamp >= ? ";
SqlFieldsQuery sqlQ = new SqlFieldsQuery(sql).setArgs(id, t1, t2);
int count = 0;
try (QueryCursor<List<?>> cursor = cache.query(sqlQ)) {
for (List<?> row : cursor) {
count = (int) row.get(0);
}
Instead of the for loop, I tried count = (int) cursor.getAll().get(0).get(0);
而不是 for 循环,我尝试了count = (int) cursor.getAll().get(0).get(0);
But that also didn't work.但这也没有用。 Anyone have an idea what's happening here.任何人都知道这里发生了什么。 Thank You.谢谢你。
Have you tried replacing ?
你试过更换?
with actual type?与实际类型?
try (QueryCursor<List<Integer>> cursor = cache.query(sqlQ)) {
for (List<Integer> row : cursor)
count = row.get(0);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.