gpt4 book ai didi

java - SQLite 异常 : near ")": syntax error (code 1 SQLITE_ERROR), 不知道出了什么问题

转载 作者:行者123 更新时间:2023-12-01 19:30:25 24 4
gpt4 key购买 nike

我尝试使用 SQlite 但出现此错误:

E/SQLite Exception: near ")": syntax error (code 1 SQLITE_ERROR): , while compiling: CREATE TABLE IF NOT EXISTS contact ( _id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, organization TEXT, phone INTEGER, address TEXT, email TEXT, web_ad TEXT, inf TEXT, birthday TEXT NULL, )

我想这应该是我的代码的这一部分:

    public static final String SQL_CREATE_ENTRIES = "" +
"CREATE TABLE IF NOT EXISTS " + ContactHelper.TABLE +" ( "+
ContactHelper._ID +" INTEGER PRIMARY KEY AUTOINCREMENT, "+
ContactHelper.COL_NAME +" TEXT, "+
ContactHelper.COL_ORGANIZATION +" TEXT, "+
ContactHelper.COL_PHONE +" INTEGER, "+
ContactHelper.COL_ADDRESS +" TEXT, "+
ContactHelper.COL_EMAIL + " TEXT, " +
ContactHelper.COL_WEB + " TEXT, " +
ContactHelper.COL_INF + " TEXT, " +
ContactHelper.COL_BIRTH + " TEXT NULL, " +
" ) ";

这很奇怪,因为起初 SQL_CREATE_ENTRIES 如下所示,并且没有错误,一旦我添加了更多列,就会出现该错误。

    public static final String SQL_CREATE_ENTRIES = "" +
"CREATE TABLE IF NOT EXISTS " + ContactHelper.TABLE +" ("+
ContactHelper._ID +" INTEGER PRIMARY KEY AUTOINCREMENT, "+
ContactHelper.COL_NAME +" TEXT, "+
ContactHelper.COL_ORGANIZATION +" TEXT NULL, "+
ContactHelper.COL_PHONE +" INTEGER, "+
ContactHelper.COL_ADDRESS +" TEXT NULL"+
")";

我看过类似的问题,他们都说单词前后应该有一个空格,但它不起作用。

最佳答案

在此行查询末尾有额外的 ',' TEXT NULL, )

关于java - SQLite 异常 : near ")": syntax error (code 1 SQLITE_ERROR), 不知道出了什么问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59905428/

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