无法执行此操作,因为已关闭连接池

时间:2017-07-18 02:30:00

标签: java android sqlite

所以我正在申请课程信息检索,这个过程基本上从第一,1。停止/停用词2.阻止3.索引4.计算术语wieghting 5.计数vektor

但每次,在术语加权过程中,它始终坚持这个错误 并且此错误始终显示相同的数据(数据编号为28699)(有大约30K +数据来计算权重)

继承错误

07-18 09:13:00.249 18878-19176/faiznoeris.tbitugaspraktek.temubalikinformasi E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
                                                                                           Process: faiznoeris.tbitugaspraktek.temubalikinformasi, PID: 18878
                                                                                           java.lang.RuntimeException: An error occurred while executing doInBackground()
                                                                                               at android.os.AsyncTask$3.done(AsyncTask.java:309)
                                                                                               at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
                                                                                               at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
                                                                                               at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                                                               at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
                                                                                               at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                                                               at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                                                               at java.lang.Thread.run(Thread.java:818)
                                                                                            Caused by: java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed.
                                                                                               at android.database.sqlite.SQLiteConnectionPool.throwIfClosedLocked(SQLiteConnectionPool.java:962)
                                                                                               at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:599)
                                                                                               at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:348)
                                                                                               at android.database.sqlite.SQLiteSession.acquireConnection(SQLiteSession.java:894)
                                                                                               at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:834)
                                                                                               at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
                                                                                               at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:151)
                                                                                               at android.database.sqlite.SQLiteCursor.onMove(SQLiteCursor.java:123)
                                                                                               at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:236)
                                                                                               at android.database.AbstractCursor.moveToNext(AbstractCursor.java:268)
                                                                                               at stbi.Bobot.doInBackground(Bobot.java:113)
                                                                                               at stbi.Bobot.doInBackground(Bobot.java:23)
                                                                                               at android.os.AsyncTask$2.call(AsyncTask.java:295)
                                                                                               at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                                               at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
                                                                                               at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                                                                                               at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
                                                                                               at java.lang.Thread.run(Thread.java:818) 

继承我的 DBHelper.java

public boolean updateTbIndex_Bobot(double bobot, int id) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();
    try {
        contentValues.put(DATA_COLUMN_BOBOT, bobot);
        db.update(DATA_INDEX_TABLE_NAME, contentValues, DATA_COLUMN_ID + " = " + id, null);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
    } /*finally {
        //db.close();
    }*/
    return false;
}

public Cursor getAllDataIndex() {
    SQLiteDatabase db = this.getWritableDatabase();
    try {
        //Cursor res = db.rawQuery("SELECT * FROM " + DATA_INDEX_TABLE_NAME + " ORDER BY " + DATA_COLUMN_ID, null);

        Cursor res = db.rawQuery(QUERY_GET_ALL_DATA_INDEX, null);
        return res;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

继承我的 Bobot.java

@Override
protected Void doInBackground(Void... params) {
    //db = new DBHelper(context);
    //n = db.getTotalDataIndex();

    db = new DBHelper(context);
    Cursor rs = db.getAllDataIndex();

    if (rs.moveToFirst()) {
        while (!rs.isAfterLast()) {
            //db.openDataBase();
            str_term = rs.getString(rs.getColumnIndex(DBHelper.DATA_COLUMN_TERM));

            id = rs.getInt(rs.getColumnIndex(DBHelper.DATA_COLUMN_ID));
            index_count = rs.getInt(rs.getColumnIndex(DBHelper.DATA_COLUMN_COUNTINDEX));
            Nterm = db.getWordFreq(str_term);

            Log.d(TAG_LOG_D, "BEFORE COUNT: N: " + n + " | NTERM: " + Nterm + " | INDEX_COUNT: " + index_count + " | LOG: " + String.valueOf(Math.log10((n / Nterm))) + " FOR TERM: " + str_term);

            hasilbobot = index_count * Math.log10((n / Nterm));

            if (db.updateTbIndex_Bobot(hasilbobot, id)) {
                Log.d(TAG_LOG_D, "TERM: " + str_term + " | BOBOT: " + hasilbobot + " WORD KE: " + counterLoadingBar + " / " + loadingMax);
            }

            counterLoadingBar++;
            progressHandler.post(new Runnable() {
                @Override
                public void run() {
                    loadingBar.setProgress(counterLoadingBar);
                    tvInfo.setText("Current Progress = Bobot | " + counterLoadingBar + " / " + loadingMax + " term");
                }
            });

            rs.moveToNext();
        }
    }
    return null;
}

0 个答案:

没有答案