private static RuntimeException getSqliteException(final String message, final int baseErrorCode) { // Mapping is from throw_sqlite3_exception in android_database_SQLiteCommon.cpp switch (baseErrorCode) { case SQLiteConstants.SQLITE_ABORT: return new SQLiteAbortException(message); case SQLiteConstants.SQLITE_PERM: return new SQLiteAccessPermException(message); case SQLiteConstants.SQLITE_RANGE: return new SQLiteBindOrColumnIndexOutOfRangeException(message); case SQLiteConstants.SQLITE_TOOBIG: return new SQLiteBlobTooBigException(message); case SQLiteConstants.SQLITE_CANTOPEN: return new SQLiteCantOpenDatabaseException(message); case SQLiteConstants.SQLITE_CONSTRAINT: return new SQLiteConstraintException(message); case SQLiteConstants.SQLITE_NOTADB: // fall through case SQLiteConstants.SQLITE_CORRUPT: return new SQLiteDatabaseCorruptException(message); case SQLiteConstants.SQLITE_BUSY: return new SQLiteDatabaseLockedException(message); case SQLiteConstants.SQLITE_MISMATCH: return new SQLiteDatatypeMismatchException(message); case SQLiteConstants.SQLITE_IOERR: return new SQLiteDiskIOException(message); case SQLiteConstants.SQLITE_DONE: return new SQLiteDoneException(message); case SQLiteConstants.SQLITE_FULL: return new SQLiteFullException(message); case SQLiteConstants.SQLITE_MISUSE: return new SQLiteMisuseException(message); case SQLiteConstants.SQLITE_NOMEM: return new SQLiteOutOfMemoryException(message); case SQLiteConstants.SQLITE_READONLY: return new SQLiteReadOnlyDatabaseException(message); case SQLiteConstants.SQLITE_LOCKED: return new SQLiteTableLockedException(message); case SQLiteConstants.SQLITE_INTERRUPT: return new OperationCanceledException(message); default: return new android.database.sqlite.SQLiteException(message + ", base error code: " + baseErrorCode); } } }
e.printStackTrace(); Log.i(TAG, "friend_request:insert:EE1:" + e.getMessage());
private void insertContentValues(ContentValues cv, FormIndex index) { synchronized(mScrollActions) { try { while ( !mScrollActions.isEmpty() ) { ContentValues scv = mScrollActions.removeFirst(); mDb.insert(DATABASE_TABLE, null, scv); } if ( cv != null ) { String idx = ""; if ( index != null ) { idx = getXPath(index); } cv.put(QUESTION,idx); mDb.insert(DATABASE_TABLE, null, cv); } } catch (SQLiteConstraintException e) { System.err.println("Error: " + e.getMessage()); } } }
/** * Every time user creates a new thing, id and location of header should plus 1. * By doing this, EverythingDone can use old id/location of header as that of * the new thing created by user(like a new {@link Thing.NOTE}) * or app itself(like a new {@link Thing.NOTIFY_EMPTY_NOTE}). */ public void updateHeader(int addSize) { final String SQL = "update " + Def.Database.TABLE_THINGS + " set id=id+" + addSize + ",location=location+" + addSize + " where type=" + Thing.HEADER; try { db.execSQL(SQL); } catch (SQLiteConstraintException e) { e.printStackTrace(); updateHeader(addSize); } }
public static void deleteALL() { try { SQLiteUtils.execSql("delete from CalibrationRequest"); SQLiteUtils.execSql("delete from Calibration"); Log.d(TAG, "Deleting all Calibration"); } catch (android.database.sqlite.SQLiteConstraintException e) { Log.wtf(TAG, "Resetting database due to foreign key constraint: " + e.toString()); ListenerService.resetDatabase(); } catch (Exception e) { Log.e(TAG, "Got exception running deleteALL " + e.toString()); } }
public boolean update(AppRule appRule) { ContentValues contentValues = new ContentValues(); contentValues.put(natDBHelper.COLUMN_APPNAME, appRule.getPkgName()); contentValues.put(natDBHelper.COLUMN_APPUID, String.valueOf(appRule.getAppUID())); contentValues.put(natDBHelper.COLUMN_ONIONTYPE, appRule.getOnionType()); contentValues.put(natDBHelper.COLUMN_LOCALHOST, appRule.getLocalHost()?1:0); contentValues.put(natDBHelper.COLUMN_LOCALNETWORK, appRule.getLocalNetwork()?1:0); String filter = natDBHelper.COLUMN_APPUID + "=?"; String[] filterArgs = {String.valueOf(appRule.getAppUID())}; SQLiteDatabase db = this.dbHelper.getWritableDatabase(); int nb_row = 0; try { nb_row = db.update(natDBHelper.NAT_TABLE_NAME, contentValues, filter, filterArgs); } catch (SQLiteConstraintException e) { Log.e(TAG, "Constraint exception"); Log.e(TAG, e.getMessage()); } db.close(); return (nb_row == 1); }
private RuntimeException getSqliteException(String message, int baseErrorCode) { // Mapping is from throw_sqlite3_exception in android_database_SQLiteCommon.cpp switch (baseErrorCode) { case SQLiteConstants.SQLITE_ABORT: return new SQLiteAbortException(message); case SQLiteConstants.SQLITE_PERM: return new SQLiteAccessPermException(message); case SQLiteConstants.SQLITE_RANGE: return new SQLiteBindOrColumnIndexOutOfRangeException(message); case SQLiteConstants.SQLITE_TOOBIG: return new SQLiteBlobTooBigException(message); case SQLiteConstants.SQLITE_CANTOPEN: return new SQLiteCantOpenDatabaseException(message); case SQLiteConstants.SQLITE_CONSTRAINT: return new SQLiteConstraintException(message); case SQLiteConstants.SQLITE_NOTADB: // fall through case SQLiteConstants.SQLITE_CORRUPT: return new SQLiteDatabaseCorruptException(message); case SQLiteConstants.SQLITE_BUSY: return new SQLiteDatabaseLockedException(message); case SQLiteConstants.SQLITE_MISMATCH: return new SQLiteDatatypeMismatchException(message); case SQLiteConstants.SQLITE_IOERR: return new SQLiteDiskIOException(message); case SQLiteConstants.SQLITE_DONE: return new SQLiteDoneException(message); case SQLiteConstants.SQLITE_FULL: return new SQLiteFullException(message); case SQLiteConstants.SQLITE_MISUSE: return new SQLiteMisuseException(message); case SQLiteConstants.SQLITE_NOMEM: return new SQLiteOutOfMemoryException(message); case SQLiteConstants.SQLITE_READONLY: return new SQLiteReadOnlyDatabaseException(message); case SQLiteConstants.SQLITE_LOCKED: return new SQLiteTableLockedException(message); case SQLiteConstants.SQLITE_INTERRUPT: return new OperationCanceledException(message); default: return new android.database.sqlite.SQLiteException(message + ", base error code: " + baseErrorCode); } } }
public TripRecord startTrip() { final String tag = TAG + ".createRecord()"; try { TripRecord record = new TripRecord(); long rowID = db.insertOrThrow(RECORDS_TABLE, null, getContentValues(record)); record.setID((int) rowID); return record; } catch (SQLiteConstraintException e) { Log.e(tag, "SQLiteConstraintException: " + e.getMessage()); } catch (SQLException e) { Log.e(tag, "SQLException: " + e.getMessage()); } return null; }
return false; } catch (SQLiteConstraintException e) { e.printStackTrace(); create(thing, handleNotifyEmpty, handleCurrentLimit); return true;
private RuntimeException getSqliteException(String message, int baseErrorCode) { // Mapping is from throw_sqlite3_exception in android_database_SQLiteCommon.cpp switch (baseErrorCode) { case SQLiteConstants.SQLITE_ABORT: return new SQLiteAbortException(message); case SQLiteConstants.SQLITE_PERM: return new SQLiteAccessPermException(message); case SQLiteConstants.SQLITE_RANGE: return new SQLiteBindOrColumnIndexOutOfRangeException(message); case SQLiteConstants.SQLITE_TOOBIG: return new SQLiteBlobTooBigException(message); case SQLiteConstants.SQLITE_CANTOPEN: return new SQLiteCantOpenDatabaseException(message); case SQLiteConstants.SQLITE_CONSTRAINT: return new SQLiteConstraintException(message); case SQLiteConstants.SQLITE_NOTADB: // fall through case SQLiteConstants.SQLITE_CORRUPT: return new SQLiteDatabaseCorruptException(message); case SQLiteConstants.SQLITE_BUSY: return new SQLiteDatabaseLockedException(message); case SQLiteConstants.SQLITE_MISMATCH: return new SQLiteDatatypeMismatchException(message); case SQLiteConstants.SQLITE_IOERR: return new SQLiteDiskIOException(message); case SQLiteConstants.SQLITE_DONE: return new SQLiteDoneException(message); case SQLiteConstants.SQLITE_FULL: return new SQLiteFullException(message); case SQLiteConstants.SQLITE_MISUSE: return new SQLiteMisuseException(message); case SQLiteConstants.SQLITE_NOMEM: return new SQLiteOutOfMemoryException(message); case SQLiteConstants.SQLITE_READONLY: return new SQLiteReadOnlyDatabaseException(message); case SQLiteConstants.SQLITE_LOCKED: return new SQLiteTableLockedException(message); case SQLiteConstants.SQLITE_INTERRUPT: return new OperationCanceledException(message); default: return new android.database.sqlite.SQLiteException(message + ", base error code: " + baseErrorCode); } } }
/** * DESCRIPTION: * Updates a trip record in the log. * * @param record - the TripRecord to update. * @return boolean flag indicating success/failure (true=success) */ public boolean updateRecord(TripRecord record) { final String tag = TAG + ".updateRecord()"; ASSERT((record.getID() != null), tag, "record id cannot be null"); boolean success = false; try { ContentValues values = getContentValues(record); values.remove(RECORD_ID); String whereClause = RECORD_ID + "=" + record.getID(); int count = db.update(RECORDS_TABLE, values, whereClause, null); success = (count > 0); } catch (SQLiteConstraintException e) { Log.e(tag, "SQLiteConstraintException: " + e.getMessage()); } catch (SQLException e) { Log.e(tag, "SQLException: " + e.getMessage()); } return success; }
private static RuntimeException getSqliteException(final String message, final int baseErrorCode) { // Mapping is from throw_sqlite3_exception in android_database_SQLiteCommon.cpp switch (baseErrorCode) { case SQLiteConstants.SQLITE_ABORT: return new SQLiteAbortException(message); case SQLiteConstants.SQLITE_PERM: return new SQLiteAccessPermException(message); case SQLiteConstants.SQLITE_RANGE: return new SQLiteBindOrColumnIndexOutOfRangeException(message); case SQLiteConstants.SQLITE_TOOBIG: return new SQLiteBlobTooBigException(message); case SQLiteConstants.SQLITE_CANTOPEN: return new SQLiteCantOpenDatabaseException(message); case SQLiteConstants.SQLITE_CONSTRAINT: return new SQLiteConstraintException(message); case SQLiteConstants.SQLITE_NOTADB: // fall through case SQLiteConstants.SQLITE_CORRUPT: return new SQLiteDatabaseCorruptException(message); case SQLiteConstants.SQLITE_BUSY: return new SQLiteDatabaseLockedException(message); case SQLiteConstants.SQLITE_MISMATCH: return new SQLiteDatatypeMismatchException(message); case SQLiteConstants.SQLITE_IOERR: return new SQLiteDiskIOException(message); case SQLiteConstants.SQLITE_DONE: return new SQLiteDoneException(message); case SQLiteConstants.SQLITE_FULL: return new SQLiteFullException(message); case SQLiteConstants.SQLITE_MISUSE: return new SQLiteMisuseException(message); case SQLiteConstants.SQLITE_NOMEM: return new SQLiteOutOfMemoryException(message); case SQLiteConstants.SQLITE_READONLY: return new SQLiteReadOnlyDatabaseException(message); case SQLiteConstants.SQLITE_LOCKED: return new SQLiteTableLockedException(message); case SQLiteConstants.SQLITE_INTERRUPT: return new OperationCanceledException(message); default: return new android.database.sqlite.SQLiteException(message + ", base error code: " + baseErrorCode); } } }
private static RuntimeException getSqliteException(final String message, final int baseErrorCode) { // Mapping is from throw_sqlite3_exception in android_database_SQLiteCommon.cpp switch (baseErrorCode) { case SQLiteConstants.SQLITE_ABORT: return new SQLiteAbortException(message); case SQLiteConstants.SQLITE_PERM: return new SQLiteAccessPermException(message); case SQLiteConstants.SQLITE_RANGE: return new SQLiteBindOrColumnIndexOutOfRangeException(message); case SQLiteConstants.SQLITE_TOOBIG: return new SQLiteBlobTooBigException(message); case SQLiteConstants.SQLITE_CANTOPEN: return new SQLiteCantOpenDatabaseException(message); case SQLiteConstants.SQLITE_CONSTRAINT: return new SQLiteConstraintException(message); case SQLiteConstants.SQLITE_NOTADB: // fall through case SQLiteConstants.SQLITE_CORRUPT: return new SQLiteDatabaseCorruptException(message); case SQLiteConstants.SQLITE_BUSY: return new SQLiteDatabaseLockedException(message); case SQLiteConstants.SQLITE_MISMATCH: return new SQLiteDatatypeMismatchException(message); case SQLiteConstants.SQLITE_IOERR: return new SQLiteDiskIOException(message); case SQLiteConstants.SQLITE_DONE: return new SQLiteDoneException(message); case SQLiteConstants.SQLITE_FULL: return new SQLiteFullException(message); case SQLiteConstants.SQLITE_MISUSE: return new SQLiteMisuseException(message); case SQLiteConstants.SQLITE_NOMEM: return new SQLiteOutOfMemoryException(message); case SQLiteConstants.SQLITE_READONLY: return new SQLiteReadOnlyDatabaseException(message); case SQLiteConstants.SQLITE_LOCKED: return new SQLiteTableLockedException(message); case SQLiteConstants.SQLITE_INTERRUPT: return new OperationCanceledException(message); default: return new android.database.sqlite.SQLiteException(message + ", base error code: " + baseErrorCode); } } }