First, here is block of code and the `LogCat`` below. Notice the line of the crash.
if (!database.isOpen()) {
open();
}
Cursor c = database.rawQuery(check_for_special, new String[]{String.valueOf(debt_id), sMonth});
if (c.getCount() == 0) { // LINE OF CRASH HERE
c.close();
return BigDecimal.ZERO;
} else {
c.moveToFirst();
BigDecimal amount = new BigDecimal(c.getDouble(c.getColumnIndex("payment")));
c.close();
return amount;
}
LogCat:
05-02 12:33:29.539: E/AndroidRuntime(14318): FATAL EXCEPTION: AsyncTask #5
05-02 12:33:29.539: E/AndroidRuntime(14318): Process: com.kickinglettuce.debtplannerpro, PID: 14318
05-02 12:33:29.539: E/AndroidRuntime(14318): java.lang.RuntimeException: An error occured while executing doInBackground()
05-02 12:33:29.539: E/AndroidRuntime(14318): at android.os.AsyncTask$3.done(AsyncTask.java:300)
05-02 12:33:29.539: E/AndroidRuntime(14318): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
05-02 12:33:29.539: E/AndroidRuntime(14318): at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
05-02 12:33:29.539: E/AndroidRuntime(14318): at java.util.concurrent.FutureTask.run(FutureTask.java:242)
05-02 12:33:29.539: E/AndroidRuntime(14318): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
05-02 12:33:29.539: E/AndroidRuntime(14318): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
05-02 12:33:29.539: E/AndroidRuntime(14318): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
05-02 12:33:29.539: E/AndroidRuntime(14318): at java.lang.Thread.run(Thread.java:818)
05-02 12:33:29.539: E/AndroidRuntime(14318): Caused by: java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed.
05-02 12:33:29.539: E/AndroidRuntime(14318): at android.database.sqlite.SQLiteConnectionPool.throwIfClosedLocked(SQLiteConnectionPool.java:962)
05-02 12:33:29.539: E/AndroidRuntime(14318): at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:599)
05-02 12:33:29.539: E/AndroidRuntime(14318): at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:348)
05-02 12:33:29.539: E/AndroidRuntime(14318): at android.database.sqlite.SQLiteSession.acquireConnection(SQLiteSession.java:894)
05-02 12:33:29.539: E/AndroidRuntime(14318): at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:834)
05-02 12:33:29.539: E/AndroidRuntime(14318): at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
05-02 12:33:29.539: E/AndroidRuntime(14318): at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:144)
05-02 12:33:29.539: E/AndroidRuntime(14318): at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:133)
05-02 12:33:29.539: E/AndroidRuntime(14318): at com.---.---.DebtDataSource.getSpecialPayment(DebtDataSource.java:1389)
05-02 12:33:29.539: E/AndroidRuntime(14318): at com.---.---.DebtDataSource.payoffDebt(DebtDataSource.java:687)
05-02 12:33:29.539: E/AndroidRuntime(14318): at com.---.---.PlannerFragment$PlannerTask.doInBackground(PlannerFragment.java:181)
05-02 12:33:29.539: E/AndroidRuntime(14318): at com.---.---.PlannerFragment$PlannerTask.doInBackground(PlannerFragment.java:145)
05-02 12:33:29.539: E/AndroidRuntime(14318): at android.os.AsyncTask$2.call(AsyncTask.java:288)
05-02 12:33:29.539: E/AndroidRuntime(14318): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
05-02 12:33:29.539: E/AndroidRuntime(14318): ... 4 more
I am not understanding this error. I read in many places that you could remove the close()
call but that does not help. Especially since it crashes before that.
Any thoughts on this?
Aucun commentaire:
Enregistrer un commentaire