當前位置: 首頁>>代碼示例>>Java>>正文


Java SQLiteBindOrColumnIndexOutOfRangeException類代碼示例

本文整理匯總了Java中android.database.sqlite.SQLiteBindOrColumnIndexOutOfRangeException的典型用法代碼示例。如果您正苦於以下問題:Java SQLiteBindOrColumnIndexOutOfRangeException類的具體用法?Java SQLiteBindOrColumnIndexOutOfRangeException怎麽用?Java SQLiteBindOrColumnIndexOutOfRangeException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SQLiteBindOrColumnIndexOutOfRangeException類屬於android.database.sqlite包,在下文中一共展示了SQLiteBindOrColumnIndexOutOfRangeException類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onSqliteError

import android.database.sqlite.SQLiteBindOrColumnIndexOutOfRangeException; //導入依賴的package包/類
private void onSqliteError(SQLiteException e) {
    if (
        e instanceof SQLiteBindOrColumnIndexOutOfRangeException ||
        e instanceof SQLiteConstraintException ||
        e instanceof SQLiteDatabaseCorruptException ||
        e instanceof SQLiteDatatypeMismatchException
    ) {
        // If a migration did not go well, the best we can do is drop the database and re-create
        // it from scratch. This is hackish but should allow more or less graceful recoveries.
        TrackHelper.track().event("Office", "cache.db.error").name("critical").value(1f).with(tracker);
        Log.e(TAG, "Critical database error. Droping + Re-creating", e);
        close();
        ctx.deleteDatabase(DB_NAME);
    } else {
        // Generic error. Close + re-open
        Log.e(TAG, "Datable "+e.getClass().getName()+". Closing + re-opening", e);
        TrackHelper.track().event("Office", "cache.db.error").name(e.getClass().getName()).value(1f).with(tracker);
        close();
    }
}
 
開發者ID:HackMyChurch,項目名稱:aelf-dailyreadings,代碼行數:21,代碼來源:AelfCacheHelper.java

示例2: bindArguments

import android.database.sqlite.SQLiteBindOrColumnIndexOutOfRangeException; //導入依賴的package包/類
private void bindArguments(PreparedStatement statement, Object[] bindArgs) {
    final int count = bindArgs != null ? bindArgs.length : 0;
    if (count != statement.mNumParameters) {
        String message = "Expected " + statement.mNumParameters + " bind arguments but "
            + count + " were provided.";
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            throw new SQLiteBindOrColumnIndexOutOfRangeException(message);
        } else {
            throw new SQLiteException(message);
        }
    }
    if (count == 0) {
        return;
    }

    final long statementPtr = statement.mStatementPtr;
    for (int i = 0; i < count; i++) {
        final Object arg = bindArgs[i];
        switch (getTypeOfObject(arg)) {
            case Cursor.FIELD_TYPE_NULL:
                nativeBindNull(mConnectionPtr, statementPtr, i + 1);
                break;
            case Cursor.FIELD_TYPE_INTEGER:
                nativeBindLong(mConnectionPtr, statementPtr, i + 1,
                        ((Number)arg).longValue());
                break;
            case Cursor.FIELD_TYPE_FLOAT:
                nativeBindDouble(mConnectionPtr, statementPtr, i + 1,
                        ((Number)arg).doubleValue());
                break;
            case Cursor.FIELD_TYPE_BLOB:
                nativeBindBlob(mConnectionPtr, statementPtr, i + 1, (byte[])arg);
                break;
            case Cursor.FIELD_TYPE_STRING:
            default:
                if (arg instanceof Boolean) {
                    // Provide compatibility with legacy applications which may pass
                    // Boolean values in bind args.
                    nativeBindLong(mConnectionPtr, statementPtr, i + 1, (Boolean) arg ? 1 : 0);
                } else {
                    nativeBindString(mConnectionPtr, statementPtr, i + 1, arg.toString());
                }
                break;
        }
    }
}
 
開發者ID:requery,項目名稱:sqlite-android,代碼行數:47,代碼來源:SQLiteConnection.java


注:本文中的android.database.sqlite.SQLiteBindOrColumnIndexOutOfRangeException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。