【问题标题】:Caused by: android.database.sqlite.SQLiteException: near "text": syntax error (code 1):引起:android.database.sqlite.SQLiteException:靠近“文本”:语法错误(代码1):
【发布时间】:2017-05-02 19:30:56
【问题描述】:

原因:android.database.sqlite.SQLiteException: near "text": syntax error (code 1): , while compile: create table contacts (id integer primary key , name text , email text , uname text , pass text )

起初认为可能是间距问题,但似乎不是问题。此登录/注册活动一直存在问题。

公共类 DatabaseHelper 扩展 SQLiteOpenHelper {

private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "contacts.db";
private static final String TABLE_NAME = "contacts";
private static final String COLUMN_ID = "id";
private static final String COLUMN_NAME = "name";
private static final String COLUMN_EMAIL = "email";
private static final String COLUMN_UNAME = "uname";
private static final String COLUMN_PASS = "pass";
SQLiteDatabase db;
private static final String TABLE_CREATE ="create table contacts (id integer primary key , name text ," +
        " email text , uname text , pass text ";

【问题讨论】:

  • 换句话说,你在问为什么你没有向我们展示的代码会抛出这个异常。这是一个非常难以回答的问题,您可能希望通过发布您的Minimal, Complete, and Verifiable example 代码和您的问题来使其更容易回答。
  • 嘿抱歉,刚刚编辑了它,现在添加了正在创建的表,我相信这就是错误所在,如果不是我可以添加其余部分。

标签: java android mysql sqlite


【解决方案1】:

您在create table 末尾忘记了)

您发布的异常没有那个问题,并且那里的SQL是有效的。错误消息指向 sqlite 引擎能够看到的最后一个有效令牌,即text

【讨论】:

  • 啊!非常感谢,无法发现它来挽救我的生命!
猜你喜欢
  • 2020-09-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-04
  • 2020-11-29
相关资源
最近更新 更多