njdart / botanyAppRepo

Second Year Group Project (Formally Botany App Project)
http://users.aber.ac.uk/daw54/final
2 stars 0 forks source link

Plant table insertion (and creation?) fails #7

Closed njdart closed 9 years ago

njdart commented 9 years ago

The Plants table fails at insertion of data. Creation (aparently) succeeds however inserion returns error=1, plant table not found. Stack trace below:

I/System.out(14260): SQL Query CREATE TABLE site (siteId INTEGER PRIMARY KEY AUTOINCREMENT, siteName TEXT, siteDate DOUBLE, osRef TEXT); CREATE TABLE plants (plantId INTEGER PRIMARY KEY AUTOINCREMENT, plantName TEXT);

E/SQLiteLog(14260): (1) no such table: plants E/SQLiteDatabase(14260): Error inserting plantName=FooBar E/SQLiteDatabase(14260): android.database.sqlite.SQLiteException: no such table: plants (code 1): , while compiling: INSERT INTO plants(plantName) VALUES (?) E/SQLiteDatabase(14260): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) E/SQLiteDatabase(14260): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1118) E/SQLiteDatabase(14260): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:691) E/SQLiteDatabase(14260): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) E/SQLiteDatabase(14260): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58) E/SQLiteDatabase(14260): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31) E/SQLiteDatabase(14260): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1589) E/SQLiteDatabase(14260): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1461) E/SQLiteDatabase(14260): at uk.ac.aber.cs221.group2.utils.PlantDataSource.create(PlantDataSource.java:46) E/SQLiteDatabase(14260): at uk.ac.aber.cs221.group2.LaunchActivity.onCreate(LaunchActivity.java:48) E/SQLiteDatabase(14260): at android.app.Activity.performCreate(Activity.java:5372) E/SQLiteDatabase(14260): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104) E/SQLiteDatabase(14260): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257) E/SQLiteDatabase(14260): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349) E/SQLiteDatabase(14260): at android.app.ActivityThread.access$700(ActivityThread.java:159) E/SQLiteDatabase(14260): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) E/SQLiteDatabase(14260): at android.os.Handler.dispatchMessage(Handler.java:99) E/SQLiteDatabase(14260): at android.os.Looper.loop(Looper.java:176) E/SQLiteDatabase(14260): at android.app.ActivityThread.main(ActivityThread.java:5419) E/SQLiteDatabase(14260): at java.lang.reflect.Method.invokeNative(Native Method) E/SQLiteDatabase(14260): at java.lang.reflect.Method.invoke(Method.java:525) E/SQLiteDatabase(14260): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) E/SQLiteDatabase(14260): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) E/SQLiteDatabase(14260): at dalvik.system.NativeStart.main(Native Method)

njdart commented 9 years ago

Split queries into separate transactions and cleared the app cache/reinstalled app seemed to work? Made an array of sql creation queries