2017-11-25 128 views
0

即時得到以下錯誤:點燃查詢異常

Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "SELECT 
""standard_item_cache"".""STANDARDITEM""._KEY, 
""standard_item_cache"".""STANDARDITEM""._VAL FROM 
""standard_item_cache"".""STANDARDITEM"" WHERE ITEMID[*] == ? "; SQL statement: 
SELECT "standard_item_cache"."STANDARDITEM"._KEY, 
"standard_item_cache"."STANDARDITEM"._VAL FROM 
"standard_item_cache"."STANDARDITEM" WHERE itemId == ? [42000-196] 

當我試圖執行一個簡單的查詢:

String itemId = params.get(Params.PARAM_ITEM_ID); 

SqlQuery<String, StandardItem> sql = new SqlQuery<>(StandardItem.class, "itemid == ?"); 

try (QueryCursor<Cache.Entry<String, StandardItem>> cursor = standardItemIgniteCache.query(sql.setArgs(itemId))) { 
    logger.info("publish standard items from cache"); 

    for (Cache.Entry<String, StandardItem> entry : cursor) { 
     logger.info("publish standard item: " + entry.getValue().toString()); 
    } 

    logger.info("publishing standard items from cache done"); 

    cursor.close(); 
} 

哪裏錯了嗎? Im doint完全像它在apache ignite中描述的例子:https://apacheignite.readme.io/v1.0/docs/cache-queries

回答

3

錯誤在於這個小字符串:itemid == ?。使用==代替=。 SQL相等運算符是一個單獨的=