Android SQLITE数据库损坏

时间:2014-05-02 07:35:07

标签: android sqlite android-sqlite greendao

我有一个使用sqlite数据库的应用程序,可以直接从应用程序访问数据库,也可以通过后台运行的服务将数据发送到服务器。

但有时我收到此错误

05-06 09:47:01.799: W/System.err(12291): 

android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5)
05-06 09:47:02.074: W/System.err(12291):    at android.database.sqlite.SQLiteConnection.nativeExecute(Native Method)
05-06 09:47:02.074: W/System.err(12291):    at android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:704)
05-06 09:47:02.074: W/System.err(12291):    at android.database.sqlite.SQLiteSession.beginTransactionUnchecked(SQLiteSession.java:323)
05-06 09:47:02.074: W/System.err(12291):    at android.database.sqlite.SQLiteSession.beginTransaction(SQLiteSession.java:298)
05-06 09:47:02.074: W/System.err(12291):    at android.database.sqlite.SQLiteDatabase.beginTransaction(SQLiteDatabase.java:505)
05-06 09:47:02.074: W/System.err(12291):    at android.database.sqlite.SQLiteDatabase.beginTransaction(SQLiteDatabase.java:416)
05-06 09:47:02.074: W/System.err(12291):    at de.greenrobot.dao.AbstractDao.executeInsertInTx(AbstractDao.java:259)
05-06 09:47:02.074: W/System.err(12291):    at de.greenrobot.dao.AbstractDao.insertInTx(AbstractDao.java:221)
05-06 09:47:02.074: W/System.err(12291):    at de.greenrobot.dao.AbstractDao.insertInTx(AbstractDao.java:197)
05-06 09:47:02.074: W/System.err(12291):    at com. me.solution.helpers.DataManager$59.onGetResourceSuccess(DataManager.java:1572)
05-06 09:47:02.074: W/System.err(12291):    at com. me.solution.connectionHandlers.AsyncRestHelper$1.onPostExecute(AsyncRestHelper.java:117)
05-06 09:47:02.074: W/System.err(12291):    at com. me.solution.connectionHandlers.AsyncRestHelper$1.onPostExecute(AsyncRestHelper.java:1)
05-06 09:47:02.079: W/System.err(12291):    at android.os.AsyncTask.finish(AsyncTask.java:631)
05-06 09:47:02.079: W/System.err(12291):    at android.os.AsyncTask.access$600(AsyncTask.java:177)
05-06 09:47:02.079: W/System.err(12291):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
05-06 09:47:02.079: W/System.err(12291):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-06 09:47:02.079: W/System.err(12291):    at android.os.Looper.loop(Looper.java:137)
05-06 09:47:02.079: W/System.err(12291):    at android.app.ActivityThread.main(ActivityThread.java:4921)
05-06 09:47:02.079: W/System.err(12291):    at java.lang.reflect.Method.invokeNative(Native Method)
05-06 09:47:02.079: W/System.err(12291):    at java.lang.reflect.Method.invoke(Method.java:511)
05-06 09:47:02.079: W/System.err(12291):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
05-06 09:47:02.079: W/System.err(12291):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
05-06 09:47:02.079: W/System.err(12291):    at dalvik.system.NativeStart.main(Native Method)
05-06 09:47:02.124: E/SQLiteLog(12422): (11) database corruption at line 50806 of [00bb9c9ce4]
05-06 09:47:02.124: E/SQLiteLog(12422): (11) database corruption at line 50845 of [00bb9c9ce4]
05-06 09:47:02.124: E/SQLiteLog(12422): (11) statement aborts at 7: [UPDATE SURVEY_COLLECTION_QUESTION_ANSWER SET '_id'=?,'SURVEY_COLLECTION_ANSWER_ID'=?,'SURVEY_ANSWER_ID'=?,'OBJECT_TYPE'=?,'OBJECT_CODE'=?,'ANSWER'=?,'COMMENT'=?,'IS_PROCESSED'=?,'DATE_A
05-06 09:47:02.124: E/DefaultDatabaseErrorHandler(12422): Corruption reported by sqlite on database: /data/data/com. me.solution/databases/ meDB_U0001
05-06 09:47:02.129: E/SQLiteLog(12422): (11) database corruption at line 50284 of [00bb9c9ce4]
05-06 09:47:02.129: E/SQLiteLog(12422): (11) database corruption at line 50806 of [00bb9c9ce4]
05-06 09:47:02.129: E/SQLiteLog(12422): (11) database corruption at line 50845 of [00bb9c9ce4]
05-06 09:47:02.129: E/SQLiteDatabase(12422): PRAGMA integrity_check on /data/data/com. me.solution/databases/ meDB_U0001 returned: *** in database main ***
05-06 09:47:02.129: E/SQLiteDatabase(12422): Failed to read ptrmap key=75
05-06 09:47:02.134: I/SQLiteConnectionPool(12422): The connection pool for +data+data+com_ me_solution+databases+ meDB_U0001 has been closed but there are still 1 connections in use.  They will be closed as they are released back to the pool.
05-06 09:47:02.134: E/DefaultDatabaseErrorHandler(12422): !@ make .back file
05-06 09:47:02.149: E/DefaultDatabaseErrorHandler(12422): !@ DB Corruption has happened before this
05-06 09:47:02.169: W/System.err(12422): java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/data/com. me.solution/databases/ meDB_U0001
05-06 09:47:02.179: W/System.err(12422):    at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55)
05-06 09:47:02.179: W/System.err(12422):    at android.database.sqlite.SQLiteDatabase.endTransaction(SQLiteDatabase.java:520)
05-06 09:47:02.179: W/System.err(12422):    at de.greenrobot.dao.AbstractDao.update(AbstractDao.java:658)
05-06 09:47:02.179: W/System.err(12422):    at com. me.solution.helpers.DataManager$3.onGetResourceSuccess(DataManager.java:1028)
05-06 09:47:02.179: W/System.err(12422):    at com. me.solution.connectionHandlers.AsyncRestHelper$3.onPostExecute(AsyncRestHelper.java:217)
05-06 09:47:02.179: W/System.err(12422):    at com. me.solution.connectionHandlers.AsyncRestHelper$3.onPostExecute(AsyncRestHelper.java:1)
05-06 09:47:02.179: W/System.err(12422):    at android.os.AsyncTask.finish(AsyncTask.java:631)
05-06 09:47:02.179: W/System.err(12422):    at android.os.AsyncTask.access$600(AsyncTask.java:177)
05-06 09:47:02.179: W/System.err(12422):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
05-06 09:47:02.179: W/System.err(12422):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-06 09:47:02.184: W/System.err(12422):    at android.os.Looper.loop(Looper.java:137)
05-06 09:47:02.184: W/System.err(12422):    at android.app.ActivityThread.main(ActivityThread.java:4921)
05-06 09:47:02.184: W/System.err(12422):    at java.lang.reflect.Method.invokeNative(Native Method)
05-06 09:47:02.184: W/System.err(12422):    at java.lang.reflect.Method.invoke(Method.java:511)
05-06 09:47:02.184: W/System.err(12422):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
05-06 09:47:02.184: W/System.err(12422):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
05-06 09:47:02.184: W/System.err(12422):    at dalvik.system.NativeStart.main(Native Method)
05-06 09:47:02.184: W/System.err(12422): java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/data/com. me.solution/databases/ meDB_U0001
05-06 09:47:02.189: W/System.err(12422):    at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55)
05-06 09:47:02.189: W/System.err(12422):    at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:990)
05-06 09:47:02.189: W/System.err(12422):    at de.greenrobot.dao.internal.TableStatements.getUpdateStatement(TableStatements.java:71)
05-06 09:47:02.189: W/System.err(12422):    at de.greenrobot.dao.AbstractDao.update(AbstractDao.java:644)
05-06 09:47:02.189: W/System.err(12422):    at com. me.solution.helpers.DataManager$3.onGetResourceSuccess(DataManager.java:1042)
05-06 09:47:02.189: W/System.err(12422):    at com. me.solution.connectionHandlers.AsyncRestHelper$3.onPostExecute(AsyncRestHelper.java:217)
05-06 09:47:02.189: W/System.err(12422):    at com. me.solution.connectionHandlers.AsyncRestHelper$3.onPostExecute(AsyncRestHelper.java:1)
05-06 09:47:02.189: W/System.err(12422):    at android.os.AsyncTask.finish(AsyncTask.java:631)
05-06 09:47:02.189: W/System.err(12422):    at android.os.AsyncTask.access$600(AsyncTask.java:177)
05-06 09:47:02.189: W/System.err(12422):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
05-06 09:47:02.189: W/System.err(12422):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-06 09:47:02.194: W/System.err(12422):    at android.os.Looper.loop(Looper.java:137)
05-06 09:47:02.194: W/System.err(12422):    at android.app.ActivityThread.main(ActivityThread.java:4921)
05-06 09:47:02.194: W/System.err(12422):    at java.lang.reflect.Method.invokeNative(Native Method)
05-06 09:47:02.194: W/System.err(12422):    at java.lang.reflect.Method.invoke(Method.java:511)
05-06 09:47:02.194: W/System.err(12422):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
05-06 09:47:02.194: W/System.err(12422):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
05-06 09:47:02.194: W/System.err(12422):    at dalvik.system.NativeStart.main(Native Method)
05-06 09:47:02.199: W/System.err(12422): java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/data/com. me.solution/databases/ meDB_U0001
05-06 09:47:02.199: W/System.err(12422):    at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55)
05-06 09:47:02.199: W/System.err(12422):    at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:990)
05-06 09:47:02.214: D/PostResourceAtPath URL(12291): http://192.168.1.50:15711/QWS/service.asmx/closeSyncSession
05-06 09:47:02.214: W/System.err(12422):    at de.greenrobot.dao.internal.TableStatements.getUpdateStatement(TableStatements.java:71)
05-06 09:47:02.214: W/System.err(12422):    at de.greenrobot.dao.AbstractDao.update(AbstractDao.java:644)
05-06 09:47:02.214: W/System.err(12422):    at com. me.solution.helpers.DataManager$3.onGetResourceSuccess(DataManager.java:1086)
05-06 09:47:02.214: W/System.err(12422):    at com. me.solution.connectionHandlers.AsyncRestHelper$3.onPostExecute(AsyncRestHelper.java:217)
05-06 09:47:02.214: W/System.err(12422):    at com. me.solution.connectionHandlers.AsyncRestHelper$3.onPostExecute(AsyncRestHelper.java:1)
05-06 09:47:02.214: W/System.err(12422):    at android.os.AsyncTask.finish(AsyncTask.java:631)
05-06 09:47:02.219: W/System.err(12422):    at android.os.AsyncTask.access$600(AsyncTask.java:177)
05-06 09:47:02.219: W/System.err(12422):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
05-06 09:47:02.219: W/System.err(12422):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-06 09:47:02.219: W/System.err(12422):    at android.os.Looper.loop(Looper.java:137)
05-06 09:47:02.219: W/System.err(12422):    at android.app.ActivityThread.main(ActivityThread.java:4921)
05-06 09:47:02.219: W/System.err(12422):    at java.lang.reflect.Method.invokeNative(Native Method)
05-06 09:47:02.219: W/System.err(12422):    at java.lang.reflect.Method.invoke(Method.java:511)
05-06 09:47:02.219: W/System.err(12422):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
05-06 09:47:02.219: W/System.err(12422):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
05-06 09:47:02.219: W/System.err(12422):    at dalvik.system.NativeStart.main(Native Method)
05-06 09:47:02.224: W/System.err(12422): java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/data/com. me.solution/databases/ meDB_U0001
05-06 09:47:02.224: W/System.err(12422):    at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55)
05-06 09:47:02.224: W/System.err(12422):    at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:990)
05-06 09:47:02.224: I/Choreographer(12291): Skipped 235 frames!  The application may be doing too much work on its main thread.
05-06 09:47:02.229: W/System.err(12422):    at de.greenrobot.dao.internal.TableStatements.getUpdateStatement(TableStatements.java:71)
05-06 09:47:02.229: W/System.err(12422):    at de.greenrobot.dao.AbstractDao.update(AbstractDao.java:644)
05-06 09:47:02.229: W/System.err(12422):    at com. me.solution.helpers.DataManager$3.onGetResourceSuccess(DataManager.java:1055)
05-06 09:47:02.229: W/System.err(12422):    at com. me.solution.connectionHandlers.AsyncRestHelper$3.onPostExecute(AsyncRestHelper.java:217)
05-06 09:47:02.229: W/System.err(12422):    at com. me.solution.connectionHandlers.AsyncRestHelper$3.onPostExecute(AsyncRestHelper.java:1)
05-06 09:47:02.229: W/System.err(12422):    at android.os.AsyncTask.finish(AsyncTask.java:631)
05-06 09:47:02.229: W/System.err(12422):    at android.os.AsyncTask.access$600(AsyncTask.java:177)
05-06 09:47:02.229: W/System.err(12422):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
05-06 09:47:02.229: W/System.err(12422):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-06 09:47:02.234: W/System.err(12422):    at android.os.Looper.loop(Looper.java:137)
05-06 09:47:02.234: W/System.err(12422):    at android.app.ActivityThread.main(ActivityThread.java:4921)
05-06 09:47:02.234: W/System.err(12422):    at java.lang.reflect.Method.invokeNative(Native Method)
05-06 09:47:02.234: W/System.err(12422):    at java.lang.reflect.Method.invoke(Method.java:511)
05-06 09:47:02.234: W/System.err(12422):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
05-06 09:47:02.234: W/System.err(12422):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
05-06 09:47:02.234: W/System.err(12422):    at dalvik.system.NativeStart.main(Native Method)

如何解决此问题以及如何从.back file generated by android恢复sqlite数据库? 注意:我使用greenDAO作为ROM。 真诚的;

0 个答案:

没有答案