Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android SQLite:表[name\u table]没有名为[name\u column]的列_Android_Sql_Sqlite_Syntax Error_Sql Insert - Fatal编程技术网

Android SQLite:表[name\u table]没有名为[name\u column]的列

Android SQLite:表[name\u table]没有名为[name\u column]的列,android,sql,sqlite,syntax-error,sql-insert,Android,Sql,Sqlite,Syntax Error,Sql Insert,我在android中使用sqlite,每次向数据库中添加新项时都会出现此错误。我没有看到任何错误,我不明白发生了什么 数据库类: public class Database { public static final String KEY_SERIE_ID = "id"; public static final String KEY_SERIE_PORTADA = "portada"; public static final String KEY_SERIE_TITUL

我在android中使用sqlite,每次向数据库中添加新项时都会出现此错误。我没有看到任何错误,我不明白发生了什么

数据库类:

public class Database {

    public static final String KEY_SERIE_ID = "id";
    public static final String KEY_SERIE_PORTADA = "portada";
    public static final String KEY_SERIE_TITULO = "titulo";
    public static final String KEY_SERIE_AÑO = "año";
    public static final String KEY_SERIE_GENERO = "genero";
    public static final String KEY_SERIE_DESCRIPCION = "descripcion";
    public static final String KEY_SERIE_TEMPORADAS = "temporadas";


    private final Context mContext;

    private DatabaseHelper mDbHelper;
    private SQLiteDatabase mDb;

    private static final String DATABASE_NAME = "database.db";
    private static final int DATABASE_VERSION = 3;

    private static final String SERIES_TABLE = "SeriesTable";


    private static final String CREATE_SERIES_TABLE =
            "CREATE TABLE " + SERIES_TABLE + " (" +
                    KEY_SERIE_ID + " LONG PRIMARY KEY, "
                    + KEY_SERIE_PORTADA + " BLOB NOT NULL, "
                    + KEY_SERIE_TITULO + "TEXT NOT NULL, "
                    + KEY_SERIE_AÑO + "INTEGER NOT NULL, "
                    + KEY_SERIE_GENERO + "TEXT NOT NULL, "
                    + KEY_SERIE_DESCRIPCION + "TEXT NOT NULL, "
                    + KEY_SERIE_TEMPORADAS + "INTEGER NOT NULL"
                    + ")";


    private static class DatabaseHelper extends SQLiteOpenHelper {
        DatabaseHelper(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }

        public void onCreate(SQLiteDatabase db) {
            db.execSQL(CREATE_SERIES_TABLE);
        }

        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            db.execSQL("DROP TABLE IF EXISTS " + SERIES_TABLE);
            onCreate(db);
        }
    }

    public void Reset() {
        mDbHelper.onUpgrade(this.mDb, 1, 1);
    }

    public Database(Context ctx) {
        mContext = ctx;
        mDbHelper = new DatabaseHelper(mContext);
    }

    public Database open() throws SQLException {
        mDb = mDbHelper.getWritableDatabase();
        return this;
    }

    public void close() {
        mDbHelper.close();
    }

    public void insertSerie(Serie serie) {
        ContentValues cv = new ContentValues();
        cv.put(KEY_SERIE_ID, serie.getId());
        cv.put(KEY_SERIE_PORTADA, serie.getPortada());
        cv.put(KEY_SERIE_TITULO, serie.getTitulo());
        cv.put(KEY_SERIE_AÑO, serie.getAño());
        cv.put(KEY_SERIE_GENERO, serie.getGenero());
        cv.put(KEY_SERIE_DESCRIPCION, serie.getDescripcion());
        cv.put(KEY_SERIE_TEMPORADAS, serie.getTemporadas());
        mDb.insert(SERIES_TABLE, null, cv);
    }
错误消息是:

E/SQLiteLog: (1) table SeriesTable has no column named descripcion
E/SQLiteDatabase: Error inserting descripcion=asdasd temporadas=2 genero=Acción titulo=asdasd id=1538229993236 portada=[B@bfa8a8f año=1980
    android.database.sqlite.SQLiteException: table SeriesTable has no column named descripcion (code 1 SQLITE_ERROR): , while compiling: INSERT INTO SeriesTable(descripcion,temporadas,genero,titulo,id,portada,año) VALUES (?,?,?,?,?,?,?)
        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
        at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:903)
        at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:514)
        at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
        at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
        at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
        at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1562)
        at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1433)
        at marc.borruey.filmmanager.database.Database.insertSerie(Database.java:162)
        at marc.borruey.filmmanager.AddShow$2.onClick(AddShow.java:99)
        at android.view.View.performClick(View.java:6597)
        at android.view.View.performClickInternal(View.java:6574)
        at android.view.View.access$3100(View.java:778)
        at android.view.View$PerformClick.run(View.java:25885)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

我不知道这是否正常。我是sqlite新手。

在以下几个地方,列名及其类型之间缺少空格:

private static final String CREATE_SERIES_TABLE =
    "CREATE TABLE " + SERIES_TABLE + " (" +
            KEY_SERIE_ID + " LONG PRIMARY KEY, "
            + KEY_SERIE_PORTADA + " BLOB NOT NULL, "
            + KEY_SERIE_TITULO + " TEXT NOT NULL, "
              // Here ------------^
            + KEY_SERIE_AÑO + " INTEGER NOT NULL, "
              // Here ---------^
            + KEY_SERIE_GENERO + " TEXT NOT NULL, "
              // Here ------------^
            + KEY_SERIE_DESCRIPCION + " TEXT NOT NULL, "
              // Here -----------------^
            + KEY_SERIE_TEMPORADAS + " INTEGER NOT NULL"
              // Here ----------------^
            + ")";

在以下几个位置,列名及其类型之间缺少空格:

private static final String CREATE_SERIES_TABLE =
    "CREATE TABLE " + SERIES_TABLE + " (" +
            KEY_SERIE_ID + " LONG PRIMARY KEY, "
            + KEY_SERIE_PORTADA + " BLOB NOT NULL, "
            + KEY_SERIE_TITULO + " TEXT NOT NULL, "
              // Here ------------^
            + KEY_SERIE_AÑO + " INTEGER NOT NULL, "
              // Here ---------^
            + KEY_SERIE_GENERO + " TEXT NOT NULL, "
              // Here ------------^
            + KEY_SERIE_DESCRIPCION + " TEXT NOT NULL, "
              // Here -----------------^
            + KEY_SERIE_TEMPORADAS + " INTEGER NOT NULL"
              // Here ----------------^
            + ")";

它工作得很好。非常感谢,先生!它工作得很好。非常感谢,先生!