简体   繁体   English

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

[英]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.

相关问题 不兼容的类型:java.lang.Class<capture#1 of ?> 无法转换为 - Incompatible types: java.lang.Class<capture#1 of ?> cannot be converted to 修复 java 中的错误:不兼容的类型:java.lang.Object 无法转换为 capture#1 of? - Fixing error in java: incompatible types: java.lang.Object cannot be converted to capture#1 of? Java 如何修复“错误:不兼容的类型:列表无法转换为 int[]” - Java How to fix "error: incompatible types: List cannot be converted to int[]" 类型安全合并 Map 与多种类型的值; `不兼容的类型 java.lang.Object 无法转换为捕获 #1 的 ?` - Type safe merging of Map with multiple types for its value; `incompatible types java.lang.Object cannot be converted to capture#1 of ?` 错误:类型不兼容:int [] []无法转换为int - error: incompatible types: int[][] cannot be converted to int EasyMock Java:不兼容的类型:java.lang.ClassLoader无法转换为java.lang.Class <capture#1 of ? extends > - EasyMock java: incompatible types: java.lang.ClassLoader cannot be converted to java.lang.Class<capture#1 of ? extends > 错误:类型不兼容:U无法转换为int - error: incompatible types: U cannot be converted to int 错误:类型不兼容:布尔值无法转换为int - error: incompatible types: boolean cannot be converted to int 错误:不兼容的类型:消息无法转换为 int? - Error: incompatible types: Message cannot be converted to int? 错误:不兼容的类型:字符串无法转换为 int - error: incompatible types: String cannot be converted to int
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM