0

There is some error on my SQLite.

03-18 16:12:09.720: E/SQLiteLog(27137): (1) near "type": syntax error
03-18 16:12:09.720: W/dalvikvm(27137): threadid=1: thread exiting with uncaught exception (group=0x40c20450)
03-18 16:12:09.740: E/AndroidRuntime(27137): FATAL EXCEPTION: main
public void onCreate(SQLiteDatabase db) {
    String CREATE_OWNER_TABLE = "CREATE TABLE " + TABLE_BUS + "(" + KEY_ROUTE + " TEXT NOT NULL," + KEY_DESTINATION + " TEXT NOT NULL," + KEY_FEE + " TEXT NOT NULL " + KEY_TYPE + " TEXT NOT NULL " + KEY_VIA1 + " TEXT NOT NULL " + KEY_VIA2 + " TEXT NOT NULL " + KEY_VIA3 + " TEXT NOT NULL );";
    db.execSQL(CREATE_OWNER_TABLE);
}
1
  • is there any field name type u are using ? Commented Mar 18, 2014 at 7:54

3 Answers 3

2

You are missing commas.

public void onCreate(SQLiteDatabase db) {
    String CREATE_OWNER_TABLE = "CREATE TABLE " + TABLE_BUS + "(" + KEY_ROUTE + " TEXT NOT NULL," + KEY_DESTINATION + " TEXT NOT NULL," + KEY_FEE + " TEXT NOT NULL, " + KEY_TYPE + " TEXT NOT NULL, " + KEY_VIA1 + " TEXT NOT NULL, " + KEY_VIA2 + " TEXT NOT NULL, " + KEY_VIA3 + " TEXT NOT NULL );";
    db.execSQL(CREATE_OWNER_TABLE);
}
Sign up to request clarification or add additional context in comments.

3 Comments

This guy is the winner here.
Please don't forget to choose the answer help you most :)
@user3336747, You should accept this answer by ticking green tick mark besides this answer. This helps others as well.
2

There should be a comma between two column declaration like below,

public void onCreate(SQLiteDatabase db) 
{
    String CREATE_OWNER_TABLE = "CREATE TABLE " + TABLE_BUS + "(" + KEY_ROUTE + " TEXT NOT NULL," +
             KEY_DESTINATION + " TEXT NOT NULL," + 
             KEY_FEE + " TEXT NOT NULL ," +   // Missing comma here
             KEY_TYPE + " TEXT NOT NULL ," +  // Missing comma here
             KEY_VIA1 + " TEXT NOT NULL ," +  // Missing comma here
             KEY_VIA2 + " TEXT NOT NULL ," +  // Missing comma here
             KEY_VIA3 + " TEXT NOT NULL );";
    db.execSQL(CREATE_OWNER_TABLE);
}

Comments

0

please insert commas as below,

     public void onCreate(SQLiteDatabase db) {
String CREATE_OWNER_TABLE = "CREATE TABLE " + TABLE_BUS + "(" + KEY_ROUTE + " TEXT NOT NULL," + KEY_DESTINATION + " TEXT NOT NULL," + KEY_FEE + " TEXT NOT NULL, " + KEY_TYPE + " TEXT NOT NULL ," + KEY_VIA1 + " TEXT NOT NULL ," + KEY_VIA2 + " TEXT NOT NULL, " + KEY_VIA3 + " TEXT NOT NULL );";
db.execSQL(CREATE_OWNER_TABLE);

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.