2013-09-28 59 views
0

請, 我真的是SQLite的新手。SQLiteException:接近「引用」:語法錯誤:CREATE TABLE引用(_id INTEGER PRIMARY KEY AUTOINCREMENT,class TEXT,requestCode TEXT)

我不明白爲什麼我這個錯誤。

此,我想,是罪魁禍首,當SQLiteOpenHelper嘗試創建表

public class PendingiIntentsDatabaseHandler extends SQLiteOpenHelper { 

private static final int DATABASE_VERSION = 1; 

// Database Name 
private static final String DATABASE_NAME = "pendingintents"; 

// Contacts table name 
private static final String TABLE_REFERENCES = "references"; 

// Contacts Table Columns names 
private static final String KEY_CLASS = "class"; 
private static final String KEY_REQUESTCODE = "requestCode"; 


public PendingiIntentsDatabaseHandler(Context context) { 
    super(context, DATABASE_NAME, null, DATABASE_VERSION); 
} 

// Creating Tables 
@Override 
public void onCreate(SQLiteDatabase db) { 
    String CREATE_EVENTS_TABLE = "CREATE TABLE " + TABLE_REFERENCES + "(" 
      + "_id" + " INTEGER PRIMARY KEY AUTOINCREMENT," 
      + KEY_CLASS + " TEXT," 
      + KEY_REQUESTCODE + " TEXT" 
      + 
      ")"; 
    db.execSQL(CREATE_EVENTS_TABLE); 
} 

這是logcat的:

09-28 18:25:27.703: E/AndroidRuntime(2213): FATAL EXCEPTION: IntentService[ScheduledService] 
09-28 18:25:27.703: E/AndroidRuntime(2213): android.database.sqlite.SQLiteException: near "references": syntax error: CREATE TABLE references(_id INTEGER PRIMARY KEY AUTOINCREMENT,class TEXT,requestCode TEXT) 
09-28 18:25:27.703: E/AndroidRuntime(2213):  at android.database.sqlite.SQLiteDatabase.native_execSQL(Native Method) 
09-28 18:25:27.703: E/AndroidRuntime(2213):  at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1763) 
09-28 18:25:27.703: E/AndroidRuntime(2213):  at com.examples.android.calendar.scheduler.PendingiIntentsDatabaseHandler.onCreate(PendingiIntentsDatabaseHandler.java:44) 
09-28 18:25:27.703: E/AndroidRuntime(2213):  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:126) 
09-28 18:25:27.703: E/AndroidRuntime(2213):  at com.examples.android.calendar.scheduler.PendingiIntentsDatabaseHandler.addPendingIntentReference(PendingiIntentsDatabaseHandler.java:63) 
09-28 18:25:27.703: E/AndroidRuntime(2213):  at com.examples.android.calendar.scheduler.Scheduler.schedule(Scheduler.java:50) 
09-28 18:25:27.703: E/AndroidRuntime(2213):  at com.examples.android.calendar.crisismate2.OnBootService.onHandleIntent(OnBootService.java:43) 
09-28 18:25:27.703: E/AndroidRuntime(2213):  at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59) 
09-28 18:25:27.703: E/AndroidRuntime(2213):  at android.os.Handler.dispatchMessage(Handler.java:99) 
09-28 18:25:27.703: E/AndroidRuntime(2213):  at android.os.Looper.loop(Looper.java:130) 
09-28 18:25:27.703: E/AndroidRuntime(2213):  at android.os.HandlerThread.run(HandlerThread.java:60) 
+0

你可以做[引用],而其他開發者,包括你自己下週將感謝你沒有用關鍵詞命名你的東西。 –

回答

4

'引用' 是保留名稱在SQL

相關問題