簡體   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