繁体   English   中英

修复 SQL 错误不兼容类型:capture#1 of? 无法转换为 int

[英]Fix SQL error incompatible types: capture#1 of ? cannot be converted to int

我有一个 SQL 查询来查询 Ignite 缓存数据库。 但是 select count(column_Name) 给出了以下编译错误。 incompatible types: capture#1 of? cannot be converted to int

这是我的代码。

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

而不是 for 循环,我尝试了count = (int) cursor.getAll().get(0).get(0); 但这也没有用。 任何人都知道这里发生了什么。 谢谢你。

你试过更换? 与实际类型?

    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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM