gpt4 book ai didi

java - 插入中的 SQLite 无法识别的 token 异常

转载 作者:行者123 更新时间:2023-12-03 17:27:02 24 4
gpt4 key购买 nike

我得到 unrecognized token error当我尝试包含 Api_key我的插入查询中的列及其值,否则没有它,它工作正常。

这是代码:

public void InsertResult(String apikey,String auditid,String crit_id, int current_chap)
{
String s="INSERT OR IGNORE INTO Results(AuditID,CriteriaID,ChapterID,Api_key) VALUES("+auditid+","+crit_id+","+current_chap+","+apikey+")";

sp.execSQL(s);
}

这是我的日志:
10-11 22:45:09.655: E/AndroidRuntime(8124): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.oxtro.trustea/com.oxtro.trustea.ChapterActivity}: android.database.sqlite.SQLiteException: unrecognized token: "3249f6dc" (code 1): , while compiling: INSERT OR IGNORE INTO Results(AuditID,CriteriaID,ChapterID,Api_key) VALUES(1,13,13,3249f6dc-c3ca-4c8d-a4de-df1834c579c4)

最佳答案

您应该在非数字字符串周围加上刻度线。

String s="INSERT OR IGNORE INTO Results(AuditID,CriteriaID,ChapterID,Api_key) VALUES("+auditid+","+crit_id+","+current_chap+",`"+apikey+"`)";

注意“apikey”周围的`标记

SQLite 看到 -并且很困惑为什么它不在一个字符串中。

关于java - 插入中的 SQLite 无法识别的 token 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19323922/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com