/ / SQLite Ausnahmesyntaxfehler in der Nähe von "s" - Android, SQL

SQLite Ausnahme Syntaxfehler in der Nähe von "s" - Android, SQL

Es tut mir wirklich leid, wenn dies trivial ist, aber ich habe mich sehr bemüht, den Fehler in dieser Methode zu finden, und bin ziemlich neu in SQL. Ich bin mir nicht sicher, was hier falsch läuft. Wäre echt dankbar für Hilfe

öffentliche Liste getAllTasksbyLocation (String address) {

    List<Task> tasklist = new ArrayList<Task>();
String selectQuery = "SELECT * FROM " + TABLE_TASKS + " tskTble, "
+ TABLE_LOCATIONS + " locTble, " + TABLE_TLRELATIONSHIP
+ " tlRelation WHERE locTble." + KEY_MARKER_ADDRESS + " = ""
+ address + """ + " AND locTble." + KEY_ID + " = "
+ "tlRelation." + KEY_LOCATION_ID + " AND tskTble." + KEY_ID
+ " = " + "tlRelation." + KEY_TASK_ID;

// insert log here

SQLiteDatabase db = this.getReadableDatabase();
Cursor c = db.rawQuery(selectQuery, null);

// looping through all rows and adding to the list

if (c.moveToFirst()) {
do {
Task task = new Task();
task.setID(c.getInt(c.getColumnIndex(KEY_ID)));
task.setTaskTitle(c.getString(c.getColumnIndex(KEY_TASK_TITLE)));
task.setTaskDifficulty(c.getString(c
.getColumnIndex(KEY_TASK_DIFFICULTY)));

task.setDate(c.getString(c.getColumnIndex(KEY_TASK_DATE)));

task.setTime(c.getString(c.getColumnIndex(KEY_TASK_TIME)));
task.setNotes(c.getString(c.getColumnIndex(KEY_TASK_NOTES)));
task.setNotification(c.getString(c
.getColumnIndex(KEY_TASK_NOTIFICATION)));

tasklist.add(task);
} while (c.moveToNext());

}
return tasklist;

}

02-10 00:18:24.785: E/AndroidRuntime(29232): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.prototype3/com.example.prototype3.map.TaskList_Map}: android.database.sqlite.SQLiteException: near "s": syntax error (code 1): , while compiling: SELECT * FROM tasks tskTble, locations locTble, tasks_and_locations tlRelation WHERE locTble.address = "56 Pritchatt"s Rd, Birmingham, United Kingdom" AND locTble.id = tlRelation.location_id AND tskTble.id = tlRelation.task_id
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.app.ActivityThread.access$700(ActivityThread.java:159)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.os.Looper.loop(Looper.java:176)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.app.ActivityThread.main(ActivityThread.java:5419)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at java.lang.reflect.Method.invokeNative(Native Method)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at java.lang.reflect.Method.invoke(Method.java:525)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at dalvik.system.NativeStart.main(Native Method)
02-10 00:18:24.785: E/AndroidRuntime(29232): Caused by: android.database.sqlite.SQLiteException: near "s": syntax error (code 1): , while compiling: SELECT * FROM tasks tskTble, locations locTble, tasks_and_locations tlRelation WHERE locTble.address = "56 Pritchatt"s Rd, Birmingham, United Kingdom" AND locTble.id = tlRelation.location_id AND tskTble.id = tlRelation.task_id
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1118)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:691)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1436)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1375)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at com.example.prototype3.database.DatabaseHelper.getAllTasksbyLocation(DatabaseHelper.java:229)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at com.example.prototype3.map.TaskList_Map.loadTasksToMap(TaskList_Map.java:134)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at com.example.prototype3.map.TaskList_Map.onCreate(TaskList_Map.java:85)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.app.Activity.performCreate(Activity.java:5372)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
02-10 00:18:24.785: E/AndroidRuntime(29232):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
02-10 00:18:24.785: E/AndroidRuntime(29232):    ... 11 more

Antworten:

5 für die Antwort № 1

Die Adresse, die Sie in Ihre Tabelle einfügen möchten, enthält ein "" "(Apostroph ) Es liegt also ein Fehler vor, wenn die Anforderung ausgeführt wird: die Adresse (Zeichenfolge)

"56 Pritchatt"</ strong> s Rd, Birmingham, Vereinigtes Königreich "

Die Adresse für das System lautet 56 Pritchatt Der Rest verursachte einen Fehler

Sie sollten keine Adresse (oder Zeichenfolge) mit verwenden Apostroph in einer Anfrage.